Skip to main content
Any python function can be used as a tool by an Agent. For example, here’s how to use a get_top_hackernews_stories function as a tool:
hn_agent.py

Accessing built-in parameters in Tools

Agno automatically injects some built-in parameters into your tool functions, so you can easily gain access to important information and objects in your tools. These built-in parameters are:
  • run_context: The run context object from where you can access the session state, dependencies, metadata, etc.
  • agent: The agent object.
  • team: The team object.
  • images: The images object.
  • videos: The videos object.
  • audios: The audios object.
  • files: The files object.
For example to access agent in a tool, you can do:
See Tool Built-in Parameters for more details on run_context, agent, team, and media parameters.

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. False by default. The result of the tool call is always 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
See the @tool Decorator Reference for more details.