getTool

View as MarkdownOpen in Claude

Look up a registered SwaigFunction by name.

Parameters

name
stringRequired

The tool name to search for.

Returns

SwaigFunction | undefined — The SwaigFunction instance, or undefined if not found or not a SwaigFunction.

Example

1import { AgentBase } from '@signalwire/sdk';
2
3const agent = new AgentBase({ name: 'assistant', route: '/assistant' });
4agent.defineTool({
5 name: 'get_weather',
6 description: 'Get the current weather',
7 parameters: {
8 type: 'object',
9 properties: { city: { type: 'string' } },
10 },
11 handler: async (args) => ({ response: `Weather in ${args.city}: sunny` }),
12});
13
14const tool = agent.getTool('get_weather');
15if (tool) {
16 console.log(tool.description); // "Get the current weather"
17}