Skip to main content
In most production cases, you will need to write your own tools. Which is why we’re focused on provide the best tool-use experience in Agno. The rule is simple:
  • Any Python function can be used as a tool by an Agent.
  • Use the @tool decorator to modify what happens before and after this tool is called.

Python Functions as Tools

For example, here’s how to use a get_top_hackernews_stories function as a tool:
hn_agent.py

Magic of the @tool decorator

To modify the behavior of a tool, use the @tool decorator. Some notable features:
  • requires_confirmation=True: Requires user confirmation before execution.
  • requires_user_input=True: Requires user input before execution. Use user_input_fields to specify which fields require user input.
  • external_execution=True: The tool will be executed outside of the agent’s control.
  • show_result=True: Show the output of the tool call in the Agent’s response, True by default. Without this flag, the result of the tool call is sent to the model for further processing.
  • stop_after_tool_call=True: Stop the agent run after the tool call.
  • tool_hooks: Run custom logic before and after this tool call.
  • cache_results=True: Cache the tool result to avoid repeating the same call. Use cache_dir and cache_ttl to configure the cache.
Here’s an example that uses many possible parameters on the @tool decorator.
advanced_tool.py

@tool Parameters Reference

Writing your own Toolkit

Many advanced use-cases will require writing custom Toolkits. Here’s the general flow:
  1. Create a class inheriting the agno.tools.Toolkit class.
  2. Add your functions to the class.
  3. Important: Include all the functions in the tools argument to the Toolkit constructor.
Now your Toolkit is ready to use with an Agent. For example:
shell_toolkit.py