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 forparameters 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
enumfor fixed sets. requiredonly for fields the tool truly can’t function without; otherwise the model interrogates the user.
enum, examples, pattern, format) can go on each property here.
Returning tool results
Sendtool.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).
- Call
flush_if_idle()from thetool.callhandler. Your tool may return afterreply.donealready fired. - Update
last_eventonreply.started/input.speech.startedso results that become available mid-turn are held until that turn ends.
Errors that help the agent recover
Theerror field is read verbatim by the model. Weak errors cause guessing loops; specific errors get clean recoveries.
Weak (agent re-asks for everything):
Going further
The shared mechanics live on the Tools overview: execution modes (interactive vs hold), progressive tool reveal, per-agent patterns, and debugging.