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

import { AgentBase } from '@signalwire/sdk';
const agent = new AgentBase({ name: 'assistant', route: '/assistant' });
agent.defineTool({
name: 'get_weather',
description: 'Get the current weather',
parameters: {
type: 'object',
properties: { city: { type: 'string' } },
},
handler: async (args) => ({ response: `Weather in ${args.city}: sunny` }),
});
const tool = agent.getTool('get_weather');
if (tool) {
console.log(tool.description); // "Get the current weather"
}