tool / FunctionTool
tool / FunctionTool
tool
Creates a FunctionTool definition that can be passed into an Agent’s tools map.
The tool() function mirrors llm.tool() from @livekit/agents-js.
When the underlying SignalWire agent is built, each tool is registered as a SWAIG
function via defineTool().
Parameters
description
A description of what the tool does. This is sent to the LLM so it knows when to invoke the tool.
parameters
JSON Schema describing the tool’s parameters, or a Zod schema object. If omitted, the tool accepts no parameters.
execute
The function to run when the tool is invoked. Receives the parsed parameters and
a context object containing the RunContext. Can return a string,
an object (serialized to JSON), or a FunctionResult.
Returns
FunctionTool — A tool definition object. The name field is empty and
gets filled in when the tool is assigned to a key in Agent.tools.
Examples
FunctionTool Interface
The FunctionTool interface represents a tool definition that can be registered on
an Agent.
name
The tool name. When created via tool(), this is initially empty and is set
automatically when the tool is added to an Agent’s tools map (the map key
becomes the name).
description
A description of what the tool does.
parameters
JSON Schema or Zod schema describing the tool’s accepted parameters.
execute
The handler function invoked when the LLM calls this tool.