The arguments the LLM produced for this call, already parsed from JSON.
The tool's result as a string, at most 15 KiB (the LiveKit RPC response limit; a larger result fails the call). Return JSON: the server parses it, and passes other text on as it is. A synchronous handler may return the string directly; the SDK awaits the result either way.
agentManager.registerClientTool('get_cart_total', async args => {
const total = await cart.total(args.currency as string);
return JSON.stringify({ total });
});
// Nothing to await: the string is enough.
agentManager.registerClientTool('get_locale', () => JSON.stringify({ locale: navigator.language }));
A client tool's implementation: the function that runs in the browser when the agent calls it.
Register it with registerClientTool(), under the tool name defined in the agent's configuration. The SDK parses the arguments the agent's LLM produced and passes them in; whatever the handler resolves with is sent back to the agent as the tool's result. Throwing rejects the call, and the error message (at most 256 bytes) is forwarded to the agent. The server gives a handler 10 seconds unless the tool's configuration sets a
timeout. Expressive (V4) agents only: registerClientTool() throws a ValidationError on a Talks (V2) or Clips (V3) agent.