Structured Visual Agents
A simple agent hands the model a prompt, some tools, and a knowledge base, and lets it decide what to do. A structured visual agent replaces that open loop with an explicit graph of typed blocks — routing, LLM calls, tool calls, state, output — so you control exactly how the agent responds. Use it when you need determinism, inspectability, or a fixed multi-step procedure rather than free-form tool use.
Any simple agent converts losslessly to a structured one: it becomes a single Agentic Loop block that behaves identically. Start structured only when you outgrow the single loop.
Agent kinds
Agent Builder offers three kinds:
| Kind | Runtime |
|---|---|
| Visual | The block graph described on this page. |
| Code | A Python function you write — see Code agents. |
| Plugin | Packaged agent from a plugin (backend runtime pending — shown "Coming soon"). |
The block graph
A structured agent is a graph of blocks executed by the block-graph runtime. State flows between blocks; edges can carry conditions. The block kinds:
| Group | Blocks |
|---|---|
| Control flow | routing, core_loop (agentic loop), for_each, parallel, reflection |
| LLM & tools | llm_request, tool_call, delegate (call another agent) |
| State & memory | set_state, set_scratchpad, context_compression, memory_retrieve, memory_store |
| Output | output (CEL / Jinja template), generate_artifact, python |
| Feedback | feedback_use, feedback_detect |
Routing
A routing block chooses the next block from its conditions. Conditions are recursive AND/OR trees evaluated with CEL, so you can express "if the question is about revenue AND the period is closed, go to the revenue branch." On a follow-up turn, smart subsequent-turn mode lets the model pick the entry block from the graph's catalog rather than always restarting at the root.
CEL expressions
Edge conditions and output templates use a small Common Expression Language engine. It is sandboxed by construction — a pure AST walk with no eval, no dunder access, and no imports — and guards against pathological inputs (e.g. sequence-repetition blow-ups). Use it for conditions (answer.rows > 0) and for shaping the final string.
State, scratchpad & memory
set_state / set_scratchpad write into the run's working state, which persists on chat_sessions.agent_state. context_compression summarizes prior context to stay under the token budget. memory_retrieve / memory_store read and write the agent's conversational and semantic memory.
Output templates
An output block renders the final answer from a template. Two template types: a CEL expression, or a Jinja "Emit-Output" template rendered in a SandboxedEnvironment with StrictUndefined (a missing variable errors loudly rather than emitting an empty string).
The Design view
The graph is authored in a visual flow-graph Design view (rich node cards, edge condition labels). Turn on drag-to-wire editing (the editable toggle) to connect, rewire, and remove edges directly on the canvas. Tools appear as first-class nodes.
Code agents
The Code agent kind runs Python you write. Define:
def agent(query, context):
# return a string, or yield strings to stream
return f"You asked: {query}"
Your function returns a str (or an Iterator[str] to stream token-by-token). It runs subprocess-isolated with a 60-second wall-clock timeout, and is served on both /chat and /chat/stream.
See also
- Agents overview
- Guardrails — run as part of the graph on input and output
- Agent Tools — the
tool_call/delegateblock targets