Skip to navigation

getTools

View as MarkdownOpen in Claude

Get every SwaigFunction registered on the agent. Runs the agent’s defineTools() hook first if it hasn’t run yet, so tools a subclass defines there are included. Only SwaigFunction instances are returned: functions registered as raw SWAIG definitions, such as DataMap tools, are left out. For summaries of every registered tool, use getRegisteredTools().

Returns

SwaigFunction[] — The registered tools.

Example

import { AgentBase, FunctionResult } from '@signalwire/sdk';
const agent = new AgentBase({ name: 'dispatch', route: '/dispatch' });
agent.setPromptText('You are Ada, the dispatcher for Bayview Taxi.');
agent.defineTool({
name: 'get_eta',
description: 'Get the pickup ETA for a booking',
parameters: { type: 'object', properties: { booking_id: { type: 'string' } } },
handler: () => new FunctionResult('The driver is 8 minutes away.'),
});
for (const tool of agent.getTools()) {
console.log(tool.name);
}