A prompt for your coding agent#
Paste this one line into the agent that works in your repository, then tell it what to decide: "route new tickets in support/inbox.ts with DecisionNode". The agent fetches the setup guide and follows it: your key from the environment, the docs MCP server, the llms files, the SDK for your language or plain HTTPS, the endpoint and the request and response shapes, the rules that keep the integration acting on its own, and one call to check it all works.
Set up DecisionNode for me: fetch and follow this guide https://decisionnode.com/agent-setup.mdGive your agents a decide tool#
Agents act on judgments: is this email a refund request, is this command safe to run, does this reply answer the question. Expose DecisionNode as a tool and the agent gets a typed, calibrated answer instead of its own guess. Most agent runtimes accept a tool described with JSON Schema, like this one.
{
"name": "decide",
"description": "Ask DecisionNode a typed question about some input, optionally with images. Returns a choice, a score, the probability that a statement is true, or a number on a grid, all calibrated. Use it before acting on a judgment.",
"input_schema": {
"type": "object",
"properties": {
"state": {
"type": "string",
"description": "The text or JSON to decide about"
},
"question": {
"type": "string",
"description": "What to decide, in one sentence"
},
"type": {
"type": "string",
"enum": ["choice", "score", "truth", "number"]
},
"options": {
"type": "array",
"items": { "type": "string" },
"description": "Options for choice, levels low to high for score"
},
"min": {
"type": "number",
"description": "Number only: the lowest value"
},
"max": {
"type": "number",
"description": "Number only: the highest value"
},
"images": {
"type": "array",
"description": "Up to 16 images to read with the state, each as base64 data or an https url, with a short name as its id. The question names an image by its id in backticks, or by its number from 1 in this order",
"items": {
"type": "object",
"properties": {
"id": { "type": "string" },
"media_type": {
"type": "string",
"enum": ["image/jpeg", "image/png", "image/webp"]
},
"data": {
"type": "string",
"description": "Base64 bytes, no data: prefix"
},
"url": {
"type": "string",
"description": "An https URL, instead of data"
}
},
"required": ["id"]
}
}
},
"required": ["state", "question", "type"]
}
}type DecideInput = {
state: string;
question: string;
type: "choice" | "score" | "truth" | "number";
options?: string[];
min?: number;
max?: number;
images?: { id: string; media_type?: string; data?: string; url?: string }[];
};
function questionOf(input: DecideInput) {
const base = { type: input.type, instructions: input.question };
switch (input.type) {
case "choice":
return { ...base, criteria: Object.fromEntries((input.options ?? []).map((o) => [o, o])) };
case "score":
return { ...base, criteria: input.options ?? [] };
case "number":
return { ...base, min: input.min, max: input.max };
default:
return base;
}
}
export async function decide(input: DecideInput, apiKey: string) {
const response = await fetch("https://api.decisionnode.com/v1/decide", {
method: "POST",
headers: { Authorization: `Bearer ${apiKey}`, "Content-Type": "application/json" },
body: JSON.stringify({
model: "decisionnode-flash",
state: input.state,
images: input.images,
questions: { answer: questionOf(input) },
}),
signal: AbortSignal.timeout(10_000),
});
if (!response.ok) {
// the agent sees why, and can fix its own call on a 400 or 422
const reason = response.headers.get("x-decisionnode-error") ?? "";
throw new Error(`decide failed: ${response.status} ${reason}`);
}
const { answers } = await response.json();
return answers.answer; // the typed answer goes back to the agent as the tool result
}Fields the agent leaves out reach the API as missing, which is the same as null: a number question without min and max uses the 0 to 255 grid, and a call without images is a text-only call. Run the handler on your server, where the key lives; retries belong in the code around it, as in Errors. For an MCP client, the DecisionNode MCP server already exposes these tools; an MCP server of your own exposes this one the same way: register decide with this schema and answer each call with the handler.
Ask before you act#
The most useful place for the tool is right before an agent does something it cannot undo. Pass the proposed action as the state and ask a Truth question; run it only when the probability clears your bar. Guardrails has the full recipe.