Skip to navigation
AgentsAgentBase

define_native_tool

View as MarkdownOpen in Claude

Define a function that the platform implements itself, such as end_call, under your own description and parameters. The function is sent with web_hook_url: "native", so the platform runs its own implementation by name and calls no webhook. Use it to describe a platform function in your own words, or so that a step’s function list can name it.

A tool from define_tool() always gets the agent’s webhook URL, so it can’t be a native function. To turn on the platform’s built-in functions without your own description, use set_native_functions().

Parameters

name
strRequired

The function’s name, one the platform implements.

description
strRequired

The description the model reads.

parameters
dict[str, Any] | NoneDefaults to None

The JSON Schema of its arguments, as the platform’s implementation reads them. None sends an empty object schema.

**swaig_fields
Any

Other SWAIG function fields, such as fillers.

Returns

AgentBase — Self for method chaining.

Example

from signalwire import AgentBase
agent = AgentBase(name="frontline", route="/frontline")
agent.prompt_add_section("Role", "You answer questions.")
agent.define_native_tool("end_call", "End the call once the caller says goodbye.")
agent.serve()

The rendered function:

{
"function": "end_call",
"description": "End the call once the caller says goodbye.",
"parameters": {"type": "object", "properties": {}},
"web_hook_url": "native"
}