Skip to main content

Handoff Configuration

This page provides comprehensive documentation for configuring handoffs in PraisonAI, including handoff filters, delegation strategies, routing rules, and advanced orchestration patterns.

Handoff System Overview

The handoff system enables agents to delegate tasks to other agents based on expertise, availability, or specific conditions. This creates flexible multi-agent workflows with intelligent task routing.

Basic Handoff Configuration

YAML Configuration

Configure handoffs directly in YAML files using the nested handoff: block:

Handoff Policy Options

Context sharing (Python API)

HandoffConfig controls what context the target sees. The filtered messages are seeded onto the target agent’s chat_history for the duration of the handoff, then restored on exit. The context_policy, max_context_messages, and preserve_system knobs live on HandoffConfig; input_filter is passed to handoff() (or Handoff) directly.
HandoffConfig fields: input_filter is a handoff() / Handoff argument — a callable (or list of callables) applied to the shared messages before they reach the target.
A handoff’s seeded history is invocation-scoped — it does not leak into subsequent chats or later handoffs that reuse the same target, and sequential handoffs do not accumulate context. See Handoff Filters.
On releases before PR #4213, context_policy, max_context_messages, preserve_system, and input_filter had no runtime effect — every handoff behaved as if there were no context sharing. If you “tuned” these on an older release and saw no change, they now take effect.

Handoff Filters

Filter Types and Configuration

Composite Filters

Dynamic Filter Functions

Advanced Delegation Settings

Per-Instance Concurrency (max_concurrent)

max_concurrent caps how many copies of a single handoff run in parallel. Each Handoff enforces its own limit — different handoffs on the same coordinator can carry different limits, each enforced independently.
As of PR #3515, max_concurrent is enforced per Handoff. Previously the semaphore was class-level, so only the first handoff’s limit took effect and every subsequent handoff silently shared it regardless of its own max_concurrent.
Handoffs and asyncio: the concurrency semaphore is now created per instance and rebound when the running event loop changes. Repeated asyncio.run() calls in the same process — common in test suites and notebooks — no longer raise RuntimeError: … bound to a different event loop.

Delegation Strategies

Conditional Handoffs

Handoff Chains and Workflows

Handoff Routing Rules

Static Routing

Dynamic Routing

Rule-Based Routing

Tool Policy

HandoffConfig.tool_policy (HandoffToolPolicy) enforces tool boundaries when one agent hands off to another. Default mode is intersect (secure): the target receives only tools shared with the source, minus any blocked_tools.
The handoff() factory also accepts shorthand kwargs: See Handoff Tool Policy for modes, patterns, and migration guidance.

Handoff Security and Validation

Tool policy (HandoffConfig.tool_policy) is the primary tool-level security mechanism during handoffs. The settings below cover transport, authorisation, and payload validation.

Performance Optimization

Caching and Optimization

Complete Handoff Configuration Example

Environment Variables

Best Practices

  1. Use appropriate filters to ensure tasks are routed to capable agents
  2. Implement fallback mechanisms for handling failures
  3. Monitor handoff performance and adjust strategies accordingly
  4. Cache routing decisions for frequently occurring patterns
  5. Set reasonable timeouts to prevent indefinite waiting
  6. Implement circuit breakers for unreliable agents
  7. Use batching for high-volume scenarios
  8. Maintain audit trails for compliance and debugging

See Also