docs/content/Agents/nodes.mdx
DocsGPT workflows are composed of Nodes that are connected to form a processing graph. These nodes interact with a Shared State—a global dictionary of variables that persists throughout the execution of the workflow.
Every workflow run maintains a state object (a JSON-like dictionary).
query) and chat history (chat_history).node_<node_id>_output.Which syntax a field takes depends on the field, so check this table before
typing {{ }} anywhere:
| Field | Node | Syntax |
|---|---|---|
| Prompt Template | AI Agent | Template — {{variable_name}} |
| Output Template | End | Template — {{variable_name}} |
| Expression | Set State | CEL — bare variable_name |
| Expression | Condition | CEL — bare variable_name |
Template fields substitute {{variable_name}} into surrounding text, so
Analysis: {{analysis_result}} produces a string.
Expression fields are evaluated as Common Expression
Language, where a bare name is the variable. Write
query, not {{query}} — the braces are a syntax error there, and saving a
workflow that contains one is rejected with the correction.
The AI Agent Node is the core processing unit. It uses a Large Language Model (LLM) to generate text, answer questions, or perform tasks using tools.
The primary input is the Prompt Template. This field supports variable substitution.
"Summarize the following text: {{user_input_text}}"{{query}}).When the agent completes its task, it stores the result in the shared state.
node_{node_id}_output.summary or translated_text.An agent node can receive documents as inputs. Choose which documents the node sees:
For how a chosen document reaches the model, the node can pass it natively (send the file to a model that accepts files) or extract it to text first. The default picks automatically based on the model and the file type.
The Set State Node allows you to manipulate variables within the shared state directly without calling an LLM. This is useful for initialization, formatting, or control flow logic.
You can define multiple operations in a single node. Each operation has two parts:
Reference state variables by bare name. {{ }} is template syntax and does
not work here — an operation must supply both parts, or it is rejected
when you save.
| Goal | Target Variable | Expression |
|---|---|---|
| Initialize a counter | retry_count | 0 |
| Increment a counter | retry_count | retry_count + 1 |
| Copy a node's output to a stable name | context | node_search_1_output |
| Build a string | formatted_response | "Analysis: " + analysis_result |
| Append to a list | history_list | history_list + [last_result] |
| Derive a boolean | needs_review | size(context) < 100 |
CEL supports arithmetic, string concatenation with +, comparisons,
&&/||, ternaries (cond ? a : b), and built-ins such as size(),
startsWith(), and contains().
retry_count to 0 before a loop, then set it
to retry_count + 1 inside the loop.history_list + [last_result].context, expression node_search_1_output) so later nodes can use one
standard variable.The Condition Node branches the workflow. Each case pairs a CEL Expression with an outgoing branch; the first case whose expression is true wins, and execution follows that branch.
{{ }}.| Goal | Expression |
|---|---|
| Route on a previous answer | node_classify_1_output == "refund" |
| Guard on retrieved context | size(context) > 0 |
| Combine checks | needs_review && retry_count < 3 |
| Match text | query.contains("invoice") |
A case whose expression fails to evaluate at run time is skipped and the next case is tried, so a workflow that always lands on else usually means an expression is referencing a variable that no earlier node writes.
The Code Node runs a script in a sandboxed session bound to the workflow run. Use it to transform data, parse files, cross-check documents, or build a report that later nodes consume.
Runs are sandboxed and have a fixed time limit, so keep each step focused. See Artifacts and Code Execution for the sandbox backends and configuration.