defineTool
Imperatively register a SWAIG tool with this skill. The tool definition is
merged with the skill’s swaigFields (explicit fields on toolDef take
precedence) and then appended to the internal dynamic tool list. The default
getTools() implementation returns these dynamic tools at
SWML render time.
Use defineTool() from setup() when the tool shape depends on config
evaluated at setup time (e.g., an API key that changes the available
actions). Skills with a static tool list should override getTools()
directly instead.
Parameters
toolDef
The tool definition. Must include at minimum name, description,
parameters, and handler.
toolDef.name
Tool name exposed to the AI.
toolDef.description
One-sentence summary the AI sees when choosing whether to call the tool.
toolDef.parameters
JSON-Schema-style parameter description.
toolDef.handler
Async function invoked when the AI calls the tool.
toolDef.secure
Whether to require token validation on tool calls. Tools are secure by
default: the rendered webhook URL carries a per-tool token. Pass false
only to expose the tool on the shared, unauthenticated webhook URL.
toolDef.gates
1 to 8 semantic gates that must pass before the tool runs. They
take precedence over gates in the skill’s swaigFields. Checked when the
skill is added to an agent.
toolDef.gate_fillers
What the AI says while the gates are checked, shaped like fillers.
Returns
void