Programmatically define a SWAIG function (tool) that the AI can invoke during a conversation.
Tool definitions map to SWML SWAIG function entries. See the SWML SWAIG functions reference for the full specification.
For cleaner typed handler signatures with automatic parameter inference, consider
using defineTypedTool()
instead.
Tool definition object.
Tool name. Must be unique within the agent. The AI uses this name to invoke the function.
Human-readable description of what the tool does. The AI reads this to decide when to call the tool.
JSON Schema describing the tool’s parameters. The AI generates arguments conforming to this schema.
Callback invoked when the AI calls this tool. Receives
(args: Record<string, unknown>, rawData: Record<string, unknown>) and should
return a FunctionResult.
Whether to require token validation on tool calls. Recommended for production.
Language-specific filler phrases spoken while the tool executes.
Format: { 'en-US': ['Looking that up...', 'One moment...'] }.
URL of an audio file to play while the tool executes.
Number of times to loop the wait file.
List of required parameter names from the JSON Schema.
External webhook URL. When set, the tool is treated as externally-hosted and the tool call is forwarded to this URL instead of being dispatched to a local handler.
Additional fields merged into the SWAIG function definition. Equivalent to
Python’s **swaig_fields kwargs (e.g., meta_data).
AgentBase — Returns this for method chaining.