AgentsAgentBase

define_tools

View as MarkdownOpen in Claude

Returns the list of SWAIG functions registered on this agent. The default implementation collects all tools added via define_tool(), the @tool decorator, or register_swaig_function().

Override this method in a subclass to dynamically filter, reorder, or inject tools at SWML generation time.

In most cases you do not need to override this method. Use define_tool() or the @tool decorator to register tools instead.

Parameters

None.

Returns

list[SWAIGFunction | dict] — List of SWAIGFunction objects and/or raw dictionaries (for DataMap-based tools).

Example

from signalwire import AgentBase
from signalwire.core.function_result import FunctionResult
class FilteredAgent(AgentBase):
def __init__(self):
super().__init__(name="filtered", route="/filtered")
self.set_prompt_text("You are a helpful assistant.")
self._disabled_tools = set()
@AgentBase.tool(description="Check the weather")
def check_weather(self, args, raw_data=None):
return FunctionResult("It's sunny and 72F.")
def define_tools(self):
"""Filter out any disabled tools before SWML generation."""
all_tools = super().define_tools()
return [
t for t in all_tools
if getattr(t, 'name', None) not in self._disabled_tools
]
agent = FilteredAgent()
agent.run()