Tools
Last updated
Was this helpful?
Last updated
Was this helpful?
Tools allow enhancing an agent's capabilities by allowing it to call external functions. Tools enable the creation of agents that can perform actions, retrieve information, and make decisions based on real-time data.
Custom tools are defined as regular python functions, and can be async or sync.
To use the tool, add the function to the tools
list in the @workflowai.agent
decorator.
It must be possible to determine the schema of a tool from the function signature. This means that
the function must have type annotations and use standard types or BaseModel
only for now.
If an agent has access to tools
, and the model
deems that tools are needed for a particular run, the agent will:
call all tools in parallel
wait for all tools to complete
reply to the run with the tool outputs
continue with the next step of the run, and re-execute tools if needed
...
until either no tool calls are requested, the max iteration (10 by default) or the agent has run to completion
It's important to understand that there are actually two runs created in a single agent run
call:
the first run returns an empty output with a tool call request with a timezone
the second run returns the current time in the given timezone
Only the last run is returned to the caller.
Another example:
This section is not up to date.
WorkflowAI hosts a few tools:
@browser-text
allows fetching the content of a web page (text-only)
@google-search
allows performing a web search using Google's search API
@perplexity-sonar-pro
allows performing a web search using Perplexity's Sonar Pro model
Hosted tools tend to be faster because there is no back and forth between the client and the WorkflowAI API. Instead, if a tool call is needed, the WorkflowAI API will call it within a single request.
A single run will be created for all tool iterations.
To use a tool, simply add it's handles to the instructions (the function docstring):
You can not directly use the web to test custom tools, since the tools execution is done through your code.