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.

Any python function can be used as a tool

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. 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