Handoff Tool Policy
Secure tool boundaries when one agent hands off to another
Tool policy limits which tools the target agent can use during a handoff — so a low-trust gatekeeper cannot escalate privileges by handing off to a powerful automation agent.
graph LR
subgraph "Handoff Tool Policy"
Request[📋 User Request] --> Process[⚙️ Handoff Tool Policy]
Process --> Result[✅ Result]
end
classDef input fill:#6366F1,stroke:#7C90A0,color:#fff
classDef process fill:#189AB4,stroke:#7C90A0,color:#fff
classDef output fill:#10B981,stroke:#7C90A0,color:#fff
class Request input
class Process process
class Result outputfrom praisonaiagents import Agent, handoff, tool
@tool
def search_tool(query: str) -> str:
"""Search the knowledge base."""
return f"Results for: {query}"
gatekeeper = Agent(name="Gatekeeper", tools=[search_tool])
automation = Agent(name="Automation", tools=[search_tool])
triage = Agent(
name="Triage",
handoffs=[handoff(automation)],
)
triage.start("Find policy docs and hand off to automation")The user asks the triage agent; tool policy limits what the target can run during handoff.
graph LR
GK["Gatekeeper Agent<br/>search_tool"] --> POLICY{"HandoffToolPolicy<br/>mode: intersect"}
POLICY --> AUTO["Automation Agent<br/>search_tool only"]
POLICY -.->|blocked| BLOCK["execute_code ❌"]
classDef agent fill:#8B0000,color:#fff
classDef tool fill:#189AB4,color:#fff
classDef allowed fill:#10B981,color:#fff
classDef blocked fill:#F59E0B,color:#fff
class GK,AUTO agent
class POLICY tool
class AUTO allowed
class BLOCK blockedQuick Start
- Secure by default
No extra configuration needed —
handoff(target)already enforces intersect mode.python from praisonaiagents import Agent, handoff, tool @tool def search_tool(query: str) -> str: """Search the knowledge base.""" return f"Results for: {query}" @tool def execute_code(code: str) -> str: """Run code in a sandbox.""" return "executed" gatekeeper = Agent(name="Gatekeeper", tools=[search_tool]) automation = Agent(name="Automation", tools=[search_tool, execute_code]) triage = Agent( name="Triage", handoffs=[handoff(automation)], # automation only gets search_tool during handoff ) - Block dangerous tools
Always strip specific tool names regardless of mode.
python from praisonaiagents import Agent, handoff triage = Agent( name="Triage", handoffs=[handoff(automation, blocked_tools=["execute_code"])], ) - Opt into legacy passthrough
python from praisonaiagents import Agent, handoff triage = Agent( name="Triage", handoffs=[ handoff( automation, tool_policy_mode="passthrough", blocked_tools=["execute_code"], ), ], ) - Full HandoffConfig
python from praisonaiagents import Agent, handoff, HandoffConfig, HandoffToolPolicy config = HandoffConfig( tool_policy=HandoffToolPolicy( mode="intersect", blocked_tools=["execute_code", "shell_access"], ), ) triage = Agent( name="Triage", handoffs=[handoff(automation, config=config)], )HandoffConfigalso carriesmax_concurrent, enforced independently per handoff — see Per-Instance Concurrency.
How It Works
sequenceDiagram
participant Source as Source Agent
participant Policy as HandoffToolPolicy
participant Target as Target Agent
Source->>Policy: handoff invoked
Policy->>Policy: intersect source ∩ target tools
Policy->>Policy: strip blocked_tools
Policy->>Target: effective tool set
Target->>Target: invoke only allowed toolsError semantics
A failed handoff returns a dict, so hooks, telemetry, and retry logic treat it as a failed tool call.
{"error": "Handoff cycle detected - ...", "handoff_failed": True}
{"error": "Maximum handoff depth exceeded - ...", "handoff_failed": True}
{"error": "Error during handoff to Billing: ...", "handoff_failed": True}| Key | Meaning |
|---|---|
error | Human-readable reason (cycle, depth, or exception text) |
handoff_failed | Always True on failure |
Modes
| Mode | Default? | Target tool set | Use when |
|---|---|---|---|
intersect | ✅ Yes | Tools both agents have, minus blocked_tools | Multi-agent systems with mixed trust levels (recommended) |
passthrough | No (opt-in) | Target’s own tools minus blocked_tools | Legacy code, or intentional capability delegation |
flowchart TD
START["Need handoff tool policy?"] --> TRUST{"Source and target<br/>same trust level?"}
TRUST -->|No| INTERSECT["Use intersect (default)"]
TRUST -->|Yes, intentional delegation| LEGACY{"Migrating legacy code?"}
LEGACY -->|Yes| PASS["Use passthrough + blocked_tools"]
LEGACY -->|No| INTERSECT
INTERSECT --> BLOCK["Add blocked_tools for dangerous tools"]
PASS --> BLOCK
classDef agent fill:#8B0000,color:#fff
classDef tool fill:#189AB4,color:#fff
class START,TRUST,LEGACY agent
class INTERSECT,PASS,BLOCK toolConfiguration Options
HandoffToolPolicy
| Option | Type | Default | Description |
|---|---|---|---|
mode | Literal["intersect", "passthrough"] | "intersect" | How tools are filtered during handoff |
blocked_tools | List[str] | [] | Tool names always stripped regardless of mode |
handoff() shorthand kwargs
| Parameter | Type | Default | Description |
|---|---|---|---|
tool_policy_mode | Optional[Literal["intersect","passthrough"]] | None | Shorthand for config.tool_policy.mode |
blocked_tools | Optional[List[str]] | None | Shorthand for config.tool_policy.blocked_tools |
Common Patterns
Gatekeeper → automation (secure default)
from praisonaiagents import Agent, handoff, tool
@tool
def search_tool(query: str) -> str:
return f"Results for: {query}"
@tool
def execute_code(code: str) -> str:
return "executed"
gatekeeper = Agent(name="Gatekeeper", tools=[search_tool])
automation = Agent(name="Automation", tools=[search_tool, execute_code])
router = Agent(name="Router", handoffs=[handoff(automation)])Always block destructive tools
router = Agent(
name="Router",
handoffs=[
handoff(
automation,
blocked_tools=["execute_code", "shell_access", "delete_file"],
),
],
)Passthrough with selective block list
router = Agent(
name="Router",
handoffs=[
handoff(
automation,
tool_policy_mode="passthrough",
blocked_tools=["execute_code"],
),
],
)Best Practices
Default to intersect for least-privilege
Leave tool_policy_mode unset unless you have a specific reason to use passthrough. Intersect mode prevents silent privilege escalation.
Always block known dangerous tools
Even in intersect mode, add blocked_tools for tools like execute_code or shell_access if they appear in the shared set.
Fix the source toolset, not the policy
If intersect mode leaves the target without a needed tool, add that tool to the source agent rather than switching to passthrough.
Test handoff boundaries in security tests
Verify that a gatekeeper handoff cannot invoke tools the source agent does not hold.