operations is the ordered list that runs, top to bottom, when the model calls
the tool. Each entry is an operation whose kind decides its other fields; an
if holds two more lists, then and else.
operations replaces the whole tree. PATCH /v1/tools/{tool_id}
leaves omitted fields alone, but a tree you send is the entire tree: read it,
change it, send it back.
The twelve kinds
Fields on an operation
Each kind accepts only its own fields. A field from another kind —then on an
http, publish_fields on a say — is rejected with a 422, not ignored.
background_execution with publish_fields on the same operation is a publish
error. silent still waits and still publishes; background_execution does
neither.
on_error
Under
continue, the failed operation publishes nothing, so later templates
that read its values resolve to empty. Validation cannot catch this: it checks
what an operation declares, not whether it ran.
On an if, continue means a condition that could not be evaluated runs
neither branch and ends the tree, because nothing can follow an if.
Terminal operations and branches
if, handoff, end_call and transfer must be the last operation in their
chain — the top-level list or any then / else list. A tree with an
operation after one is refused at save, naming the operations that follow it.
Branches never rejoin. There is no point after an if that both paths
reach, so:
- work needed on both paths is written into both;
- a third path is a second
ifas the only operation in the first one’selse; - an early exit puts the exit in one branch and the rest of the flow in the other.
end_call or transfer.
What the model is told
After the tree runs, the model is handed one of:
A tool is silent whenever no operation in it can return a response, whatever
its own
silent flag says. Only http, code and frontend_rpc return
responses, and one with silent: true or background_execution: true does not
count. So a tool that is a silent lookup plus a say speaks the say line and
nothing else. This is derived at publish and cannot be turned off; to have the
model add a line, add a generate_reply.
Timeouts
Every timeout in a tree is in seconds.
For an endpoint that is genuinely slow, set
long_running_task on the tool so the agent
keeps talking while it runs, rather than raising a timeout.
Where a kind is refused
Some kinds only work in some places. Each rule is enforced where it can first be known.
The run-time rules cannot be checked at publish because one tool can be attached
to a phone agent and a chat agent. A failure there is an ordinary operation
failure, handled by
on_error.
Next
Templating and data
Template roots,
tooldata vs userdata, and publish_fields.Conditionals
The
if operators and nested branches.Patterns
Complete trees to start from.