Skip to main content
External tool execution gives you complete control over when and how certain tools actually run. Instead of letting the agent execute the tool directly, it pauses and waits for you to handle the execution yourself. This is incredibly useful when you need:
  • Enhanced security: Execute sensitive operations in a controlled environment
  • External service calls: Integrate with services that require special handling
  • Database operations: Run queries through your own connection management
  • Custom execution logic: Add validation, logging, or rate limiting before execution
  • Sandboxed environments: Execute potentially dangerous operations safely

How It Works

When you mark a tool with @tool(external_execution=True), your agent will:
  1. Pause execution when the tool is about to be called
  2. Set is_paused to True on the run response
  3. Populate tools_awaiting_external_execution with tools that need external handling
  4. Wait for you to execute the tool and set its result
  5. Continue execution once you call continue_run() with the result
The key difference from other HITL patterns is that the agent never actually calls the function—you’re responsible for the entire execution.
In this example, the agent identifies that it needs to run execute_shell_command but doesn’t actually execute it. Instead, it pauses and gives you the tool name and arguments. You then execute it yourself (or something completely different!) and provide the result back.

Understanding External Tool Execution Requirements

When a run is paused for external execution, the returned RunOutput will contain a list of requirement objects. These requirement objects will contain the tool executions that need to run outside of the agent’s run. You can find the tool related to each requirement in requirement.tool_execution. Each tool execution object contains:
  • tool_name: The name of the tool that was called
  • tool_args: A dictionary of arguments the agent wants to pass to the tool
  • external_execution_required: A boolean flag set to True
  • result: Where you set the execution result (initially None)
You can iterate through these requirements, execute the tools however you want, and set their results:
Important: You must resolve all external tool execution requirements before calling continue_run(). An external tool execution requirement is considered resolved when you set requirement.external_execution_result.Else Agno will raise a ValueError, letting you know that not all requirements have been resolved.

Using Toolkits with External Execution

If you’re using a Toolkit, you can specify which tools require external execution using the external_execution_required_tools parameter:
This lets you mix external and internal tools in the same toolkit—perfect when you only need special handling for specific operations.

Mixed Tool Scenarios

You can absolutely have a mix of regular tools and external execution tools in the same agent. When the agent wants to call multiple tools, only the ones marked with @tool(external_execution=True) will cause a pause:

Async Support

External execution works seamlessly with async operations. Use arun() and acontinue_run() for async flows:

Streaming Support

You can also use external execution with streaming responses:

Best Practices

  1. Always set results: Make sure you set requirement.external_execution_result for all requirements before continuing
  2. Error handling: Wrap your external execution in try-catch blocks and provide meaningful error messages as results
  3. Security validation: Use external execution to add extra security checks before running sensitive operations
  4. Logging: Log all external executions for audit trails
  5. Timeouts: Consider adding timeouts to your external execution logic to prevent hanging
Remember that external execution tools marked with @tool(external_execution=True) are mutually exclusive with @tool(requires_confirmation=True) and @tool(requires_user_input=True).A tool can only use one of these patterns at a time.

Usage Examples

Basic External Execution

Execute tools outside the agent’s control

Async External Execution

Using external execution with async agents

Streaming External Execution

External execution with streaming responses

Toolkit External Execution

Using external execution with toolkits

Developer Resources