Skip to main content
Declare tools inline in session.tools when the logic must run in your own code: local state, in-memory lookups, or anything you don’t want to expose as an HTTP endpoint. The agent emits a tool.call; you run the tool and reply with a tool.result when reply.done is the latest event you’ve received.
If your tool just calls an HTTP API, prefer a server-side HTTP tool: AssemblyAI makes the request for you and your client never handles the round trip.

Quick start

Defining function tools

Function tools use a JSON Schema for parameters and carry "type": "function". HTTP tools use the same JSON-Schema parameters; description, execution_mode, and timeout_seconds work the same way for both.
session.tools updates replace the previous array (not merge). See Progressive tool reveal.

Parameters

  • Lead with format (“E.164”, “ISO-8601 date”, “lowercase”).
  • Always include an example.
  • Use enum for fixed sets.
  • required only for fields the tool truly can’t function without; otherwise the model interrogates the user.
The same accuracy hints (enum, examples, pattern, format) can go on each property here.
parameters is not validated at session.update time. Malformed schemas (missing type: "object", broken enum) are accepted silently and break tool calling at runtime. Validate locally.

Returning tool results

Send tool.result when reply.done is the latest event you’ve received. Not earlier (agent is still mid-transition-phrase), not later (a new turn has started).
Two non-obvious bits:
  • Call flush_if_idle() from the tool.call handler. Your tool may return after reply.done already fired.
  • Update last_event on reply.started / input.speech.started so results that become available mid-turn are held until that turn ends.

Errors that help the agent recover

The error field is read verbatim by the model. Weak errors cause guessing loops; specific errors get clean recoveries. Weak (agent re-asks for everything):
Strong (agent re-asks only for the field that failed):
Patterns: name the failing field, say what did work so the agent doesn’t re-ask for it, tell the agent what to ask for next.

Going further

The shared mechanics live on the Tools overview: execution modes (interactive vs hold), progressive tool reveal, per-agent patterns, and debugging.