HTTP or client?
Defining one
location on the parameters — nothing is being placed into an HTTP request.
Handling one
With the SDK, register a handler by name. Invocation matching, results, and errors are handled for you — you never see aninvocationId:
{ result, responseType }. Throwing is reported
back to the agent as a tool failure, so it can explain and move on rather than
stalling.
Register several at once:
The name you register must match the tool’s
modelToolName exactly. A
mismatch is the most common reason a correctly-defined client tool never
fires.Without the SDK
On a raw WebSocket you handle the exchange yourself. The message types areclient_tool_invocation inbound and client_tool_result outbound, matched on
invocationId:
Worth doing
- Keep them fast. This runs mid-conversation. Anything slow belongs behind an HTTP tool with the deferred pattern.
- Return something the agent can say.
{ "status": "highlighted", "name": "Blue Kettle" }lets it confirm naturally. A baretruegives it nothing to work with. - Never trust parameters blindly. They came from speech. Validate an ID before you act on it.
- Keep secrets out. Anything the browser can reach, the user can read. Real credentials belong in an HTTP tool.