AgentsSkillBase

define_tool

View as MarkdownOpen in Claude

Register a tool with the parent agent, automatically merging any swaig_fields configured for this skill. Skills should use this method instead of calling self.agent.define_tool() directly.

Parameters

**kwargs
AnyRequired

All arguments supported by agent.define_tool(): name, description, parameters, handler, secure, fillers, wait_file, etc. Explicit values take precedence over swaig_fields.

Returns

None

Example

1from signalwire.core.skill_base import SkillBase
2from signalwire import FunctionResult
3
4class SearchSkill(SkillBase):
5 SKILL_NAME = "search"
6 SKILL_DESCRIPTION = "Search the web for information"
7
8 def setup(self) -> bool:
9 return True
10
11 def register_tools(self):
12 self.define_tool(
13 name="search_web",
14 description="Search the web for information",
15 handler=self._handle_search,
16 parameters={
17 "type": "object",
18 "properties": {
19 "query": {"type": "string", "description": "Search query"}
20 },
21 "required": ["query"]
22 },
23 secure=True,
24 fillers={"en-US": ["Let me search for that..."]}
25 )
26
27 def _handle_search(self, args, raw_data):
28 query = args.get("query", "")
29 return FunctionResult(f"Results for: {query}")