> ## Documentation Index
> Fetch the complete documentation index at: https://docs.canary.effectiveai.app/llms.txt
> Use this file to discover all available pages before exploring further.

# agent node

> Start one agent session with instructions and typed input, and wait for its typed result.

An `agent` node starts one new agent session, gives it instructions and typed input, and waits for
one result that matches a schema. Use it for judgment on unstructured material, such as reading a
notice or a loss run. Use a [`task`](https://docs.canary.effectiveai.app/procedures/reference/nodes/task) when a person must decide,
and a [`call`](https://docs.canary.effectiveai.app/procedures/reference/nodes/call) when the rule must always give the same answer.

## Syntax

```yaml agent id=research-claim theme={"languages":{"custom":["languages/rsl.tmLanguage.json"]}}
title: Research claim {{ $inputs.claim.claimNumber }}
instructions: |
  Research the claimant's litigation history for claim
  {{ $inputs.claim.claimNumber }} and summarize what you find.
input:
  schema: claim-input
  value: $inputs.claim
result:
  schema: research-result
agent:
  preset: general-agent
  model: claude-opus-5-5
  effort: high
  data_sources:
    - courtlistener
  tools:
    enabled:
      - web-search
    disabled:
      - shell:agent-spawn
  plugins:
    system_context:
      namespaces:
        - claims
attachments: $inputs.claim.documents
labels:
  - claims-research
tags:
  - claims
output: claim_research
```

This block shows every field. The model and tool names are illustrative; which ones you can use
depends on your organization. Most agent nodes need only `title`, `instructions`, `input`,
`result`, `agent.preset` and `output`.

## Fields

| Field | Type | Required | Default | What it does |
| - | - | - | - | - |
| `title` | string | Yes | None | The title of the agent's task and session. One line, not empty. Can interpolate values with `{{ }}` |
| `instructions` | Markdown string | Yes | None | What the agent session is asked to do. Can interpolate values with `{{ }}` |
| `input.schema` | schema id | Yes | None | An object schema for the agent's input |
| `input.value` | data expression | Yes | None | The input itself: a reference or a built object. It must match `input.schema`. The agent session reads it as `task.input` |
| `result.schema` | schema id | Yes | None | The schema the agent's result must match. `result` takes no other field |
| `agent` | object | Yes | None | The session's settings. See [Agent settings](#agent-settings) |
| `attachments` | expression | No | None | Up to 100 unique, nonempty strings: IDs of files or records to show the agent as inputs |
| `labels` | list of strings | No | None | Unique, nonempty labels on the agent's task |
| `tags` | list of strings | No | None | Unique, nonempty tags on the agent session |
| `output` | name | Yes | None | A new name for the [result envelope](#the-result-envelope) |

The fence takes no attributes after `id`, and its body takes no other fields. There is no
assignee, session ID, timeout or idempotency key: Effective creates the session and derives the
step's identity itself.

### Agent settings

| Field | Type | Required | Default | What it does |
| - | - | - | - | - |
| `agent.preset` | string | `preset`, `model` or both | `general-agent` if only `model` is set | A named agent configuration. `general-agent` is generally available. Prefer a preset |
| `agent.model` | string | `preset`, `model` or both | The preset's model | Overrides the preset's model. Compiling warns with `PROC-AGENT-002`; where the model is checked against the models Effective knows, an unknown model is an error with the same code. See the warning below |
| `agent.effort` | string | No | None | One of `low`, `medium`, `high`, `xhigh` or `max` |
| `agent.data_sources` | list of strings | No | None | Unique values from `edgar` and `courtlistener` |
| `agent.tools.enabled` | list of strings | No | None | Unique tool names to turn on for the session |
| `agent.tools.disabled` | list of strings | No | None | Unique tool names to turn off. A tool can't be both enabled and disabled. `shell:agent-spawn` stops the session from starting other agent sessions; it can still research and submit its result |
| `agent.plugins.system_context.namespaces` | list of strings | No | None | A unique, nonempty list of system-context namespaces for the session |

At least one of `preset` and `model` is required. With `model` and no `preset`, the session uses
`general-agent`, and the model must be compatible with it.

Your organization decides which presets, models, tools, data sources and plugins agent steps can
use. Compiling checks the shape of these settings. Effective checks what your organization allows
when you publish and again when a run starts.

> [!WARNING]
>
> Prefer leaving out `model` and letting the preset choose. A model is checked again when the run
> reaches the step. If that model isn't available to your organization or doesn't work with the
> preset, the agent session may fail to start, and the run can keep waiting without reporting an
> error.

### Instructions and input

`title` and `instructions` use the same `{{ $name.path }}` interpolation as other text fields. Each
interpolated value must be a required string, number or boolean. Interpolation doesn't recurse,
and prose elsewhere in the document never becomes part of the instructions.

`input.value` uses the same data expressions as a [`value`](https://docs.canary.effectiveai.app/procedures/reference/nodes/value)
node. `$inputs` and named values mean the same thing here as anywhere else. If the agent needs
derived data, compute it in an earlier step and pass the result.

## The result envelope

The agent's output is an envelope, not the bare result. Read the typed result through
`$output.value`, for example `$claim_research.value.summary`.

| Member | Type | What it holds |
| - | - | - |
| `value` | per `result.schema` | The result, checked against `result.schema` |
| `taskId` | string | The ID of the agent's task |
| `submissionId` | string | The ID of the submission that completed it |
| `note` | string or null | The note sent with the submission |
| `attachments` | list of strings | IDs the submitter attached as supporting outputs |
| `outputArtifactId` | string or null | The ID of the primary output file, if the submitter named one |
| `actor.type` | string or null | The kind of actor that submitted |
| `actor.id` | string or null | The submitter's ID |
| `actor.label` | string or null | The submitter's display name |
| `actor.sessionId` | string or null | The submitting agent session's ID |
| `submittedAt` | string | When the result was submitted |

The fence's `attachments` are inputs shown to the agent. The envelope's `attachments` and
`outputArtifactId` are outputs that the agent attached when it submitted. The procedure can read
them but can't set them. If later steps need a file the agent produced, have the agent put the
file's ID in its typed result as well.

## Example

An agent session checks a draft cancellation notice before it goes to the mail vendor. The policy
number and file ID are illustrative.

````markdown notice-review.procedure.md theme={"languages":{"custom":["languages/rsl.tmLanguage.json"]}}
---
kind: procedure@v0
id: notice-review
inputs:
  policy_number: { type: string }
  notice_uri: { schema: file-uri }
outputs:
  review: { schema: notice-review-result }
---

# Notice review

Ask an agent session to check a draft cancellation notice before it is mailed.

## Review the draft notice

The agent reads the attached draft and returns whether it is ready to mail.

```yaml agent id=review-notice
title: Review cancellation notice for {{ $inputs.policy_number }}
instructions: |
  Read the attached draft cancellation notice for policy
  {{ $inputs.policy_number }}. Check that the effective date, the reason and
  the state-required wording are present. Return `ready: true` only if all
  three are correct, and list every problem you find.
input:
  schema: notice-review-input
  value:
    policyNumber: $inputs.policy_number
    noticeUri: $inputs.notice_uri
result:
  schema: notice-review-result
agent:
  preset: general-agent
  effort: medium
  tools:
    disabled:
      - shell:agent-spawn
attachments: [$inputs.notice_uri]
labels:
  - cancellation-notice
tags:
  - notices
output: notice_review
```

## Return the review

```yaml complete id=finish
output: review
value: $notice_review.value
```

## Resources

```yaml schema id=notice-review-input
type: object
additionalProperties: false
required: [policyNumber, noticeUri]
properties:
  policyNumber: { type: string }
  noticeUri: { type: string, minLength: 1 }
```

```yaml schema id=notice-review-result
type: object
additionalProperties: false
required: [ready, problems]
properties:
  ready: { type: boolean }
  problems:
    type: array
    items: { type: string }
```

```yaml schema id=file-uri
type: string
minLength: 1
```
````

When it runs with `policy_number: NW-100234`, the run ends with the agent's result, such as
`{ "ready": false, "problems": ["The effective date is missing."] }`. A later step could route on
`$notice_review.value.ready` with a [`choice`](https://docs.canary.effectiveai.app/procedures/reference/nodes/choice).

## On retry and resume

* **Input is fixed once.** Effective evaluates `input.value` and `attachments` once, checks them,
  and stores them with the agent's task. A resume doesn't evaluate them again.
* **One session per step.** The agent's task and session are created once for the step. A
  resumed run doesn't start a second session. Inside a [`repeat`](https://docs.canary.effectiveai.app/procedures/reference/nodes/repeat)
  or [`for-each`](https://docs.canary.effectiveai.app/procedures/reference/nodes/for-each), each round or item is its own step and
  starts its own session.
* **The first valid result wins.** The first submitted result that matches `result.schema`
  becomes the step's result. A duplicate or late submission can't move the run forward twice.
* **The record doesn't change.** The task ID, submission ID, submitter and time in the envelope
  are recorded and never rewritten.
* **The agent's task can't be reassigned.** Effective assigns it to the session the step starts.
  A change to its assignees by hand is refused.

## Common errors

| Code | Cause | Fix |
| - | - | - |
| `PROC-AGENT-001` | The body has an unknown or missing field, `agent` has neither `preset` nor `model` (`agent requires a nonempty preset or model`), a list repeats a value, or a tool is both enabled and disabled | Use only the fields above. Add `preset: general-agent` |
| `PROC-AGENT-002` | `model` overrides the preset's model. A warning for a known model; an error for a model Effective doesn't know, where it checks | Remove `model` unless you need that model |
| `PROC-SCHEMA-004` | `input.schema` or `result.schema` doesn't name a schema, or the input schema isn't an object | Declare the schema with a `schema` fence and give the input an object schema |
| `PROC-SCHEMA-005` | `input.value` doesn't match `input.schema`, or an attachment may be empty (`agent task attachments rejects it because source schema does not satisfy target constraints`) | Make the value match. Give attachment strings `minLength: 1` |
| `PROC-DATA-003` to `PROC-DATA-005` | A reference in `input`, `title` or `instructions` is malformed, unknown or optional | Point at a required member of an earlier step's output or an input |
| `PROC-GRAPH-005` | `output` reuses a name that is already declared | Pick a new name |
| `PROC-GRAPH-006` | A referenced value isn't produced before the agent node on every path | Move the producing step earlier, or out of a branch that doesn't always run |

## See also

* [task node](https://docs.canary.effectiveai.app/procedures/reference/nodes/task.md): the same envelope, answered by a person
* [choice node](https://docs.canary.effectiveai.app/procedures/reference/nodes/choice.md): route on the agent's result
* [wait node](https://docs.canary.effectiveai.app/procedures/reference/nodes/wait.md)
* [People and agents](https://docs.canary.effectiveai.app/procedures/concepts/people-and-agents.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.