AI Agent
ai_agent · Nodes · AI
Runs an AI model with configured prompt and tools.
AI Agent#
Runs an LLM against workflow input. Supports tools, structured output, images, files, and intermediate status events.
Memory input is structural. Wire memory_recall.output into ai_agent.memory; the node formats those memory items into prompt context at runtime.
Required model setup#
Model selection is one object field:
{ "model": { "connection_id": "<connection_id from list_models>", "model_id": "glm-5.1" } }
Use list_models. Select model.connection_id, then select model.model_id from that connection's models[].
Inputs#
| Name | Type | Required | Description |
|---|---|---|---|
input |
Any | Yes | Node input for interpolating into the user prompt via template syntax. |
memory |
Array or null | No | Structured memory items. Wire memory_recall.output here. |
schema |
Object | No | JSON Schema for structured output. When provided, the AI will output valid JSON matching this schema. |
images |
Array | No | Optional array of images. Accepts URLs, object descriptors, NodeData::Binary, or {binary, mime_type, filename} payloads. Binary payloads are converted to inline data URLs for the provider — no Upload Media required. Default: []. |
files |
Array | No | Optional array of files. Accepts URLs, object descriptors, NodeData::Binary, or {binary, mime_type, filename} payloads. Binary payloads are converted to inline data URLs for the provider — no Upload Media required. Default: []. |
Structured output with tools#
On models with native structured output, tools and schema can be wired together. Tool-calling turns do not need a schema payload; the final answer supplies it through structured. Invalid JSON in an answering turn still fails the run.
Outputs#
| Name | Type | Description |
|---|---|---|
response |
String | The LLM response. |
artifacts |
Array | Generated file artifacts from the LLM. |
metrics |
Object | Final model identity, cumulative {prompt, completion, total} token counts, nullable cost in micro-USD, and latest {used, limit} context-window occupancy. |
structured |
Any | Parsed JSON output when a schema is provided. Also carries the tool call that ended the run when a Yield Tool was called — a yielded call is the run's final message, so it leaves through this socket. Null when there is neither. |
structured_error |
Object | Error details when structured output parsing/validation fails. Null on success. |
intermediate |
Object | Triggers an embedded body during agent execution. The final socket value is null; the body receives {event}. Branch on event.kind: assistant_message, tool_call, tool_result, response_finished, transcript_entry_finished, run_finished. Token deltas are deliberately excluded — the body is a nested run per event. See AI Conversation for payload shapes. |
metrics has this shape:
{
"model": { "provider": "anthropic", "id": "claude-sonnet-4-6" },
"tokens": { "prompt": 18000, "completion": 1200, "total": 19200 },
"cost": { "microusd": 8250, "currency": "USD", "kind": "estimated" },
"context": { "used": 18000, "limit": 200000 }
}
cost is null when catalog pricing is unavailable. Context occupancy describes the latest model turn; token and cost values cover the complete node run. Calculate context percentage as context.used / context.limit when needed.
Configuration#
| Field | Description |
|---|---|
model |
Object containing connection_id and model_id. Select model.connection_id, then select model.model_id from that connection's models[] returned by list_models. |
system_prompt |
System instructions. |
agent_base |
Boolean, default off. Puts the Agent Base beneath system_prompt. See Agent Base. |
user_prompt |
User prompt with template support. |
max_tokens |
Optional maximum output token cap. Disable/unset to use the provider/model maximum. Explicit low caps may truncate structured output or tool calls. |
temperature |
Optional sampling temperature (0-2). Off uses the model's own value. |
top_p |
Optional nucleus sampling top-p (0-1). Off uses the model's own value. |
top_k |
Optional top-k sampling limit (1 or more). Off uses the model's own value. |
max_turns |
Maximum tool-use turns. |
Agent Base#
agent_base sends working principles beneath system_prompt: finish the whole task, keep to the requested scope, adjust after a failed tool call instead of repeating it, and report only what it observed. Where the two differ, system_prompt wins. It is off by default, and a workflow saved without the field loads with it off.
Media Input#
The images and files sockets accept inline binary data from upstream nodes (Read Media, ProcessImage, Telegram Download, etc.). When NodeData::Binary or {binary} payloads are received, the node converts them to inline data URLs (data:mime/type;base64,...) and passes them directly to the provider. No Upload Media step is required for binary-feed chains.
For persisted media, provide a {object_id: "..."} reference or a direct URL.
Common fixes#
- Invalid model: call
list_models; selectmodel.connection_id, then selectmodel.model_idfrom that connection'smodels[]. - Missing auth: call
list_models, then select a connection with usable credentials.
Inputs
inputRequiredmemoryOptionaltoolsOptionalschemaOptionalimagesOptionalfilesOptional
Outputs
responseartifactsmetricsstructuredstructured_errorintermediate
Configuration
| Field | Type | Required | Description |
|---|---|---|---|
model | model | Yes | Choose an AI connection and model. |
fallback_models | array<model> | No | Tried in order when the model above cannot answer: its quota is used up, its key is rejected, or it stays unavailable after retries. The run stays on the model it moved to. Each entry is a connection and model; the same model on another connection works as a backup key. |
system_prompt | text_block | No | System prompt to set the AI's behavior and context. |
agent_base | boolean | No | Put the Agent Base beneath the system prompt: working principles that finish the whole task, keep to its scope, adjust after a failed tool call instead of repeating it, and report only what was observed. The system prompt still wins where the two differ. |
user_prompt | text_block | Yes | User prompt with template support. Use {{ path.to.value }} to interpolate from input JSON. |
max_tokens | nullable<integer> | No | Set an explicit maximum output token cap. Disable to use the provider/model maximum. Too-low values can truncate structured output and tool calls. |
temperature | nullable<number> | No | Sampling temperature, sent only when enabled. Off uses the model's own temperature. |
top_p | nullable<number> | No | Nucleus sampling top-p, sent only when enabled. Off uses the model's own top-p. |
top_k | nullable<integer> | No | Top-k sampling limit, sent only when enabled. Off uses the model's own top-k. |
max_turns | integer | No | Maximum agent turns/rounds. Limits how many times the agent can call tools before stopping. |
auto_compact | boolean | No | Automatically compact context when approaching the context window limit. This summarizes older messages to make room. Note: Lossy operation. |
compaction_threshold | number | No | Trigger compaction at this percentage of context window (e.g., 0.8 = 80%) |
base_config | record | No | Shared node configuration. failure_mode decides what a failure of this node does to the workflow; leave it at the default stop unless the workflow handles the failure itself on the node's error output (route_to_error) or the node is a rare emergency kill switch (stop_workflow). |