Learn how to create custom tools in Agency Swarm framework.
@function_tool
decorator with async functions; however, the BaseTool approach is still supported.Add Import Statements
Define Args Schema
Create the Tool Function
@function_tool
decorator.ctx
, are treated as input parameters and included in the tool’s schema.For example, in the tool above, the input model CalculatorArgs
is passed as the args
parameter, so the input JSON would look like:args
is an example name, you can name your input parameters however you like, and you may define more than one input parameter if needed.Test the Tool
Add Tool to Agent