[FEATURE] Agent Handoffs/Delegation
Problem Statement
Customers have asked for a simple way for agents to delegate requests to specialized sub-agents with complete handoff. They want to simplify the developer experience for common delegation patterns:
- Graph/Swarm: Customers want simpler setup for hierarchical delegation use cases that don't require complex orchestration
- Agents as Tools: For use cases where the sub-agent's response doesn't need additional LLM processing, customers want to avoid the extra step of main agent → sub-agent → main agent processing → final response
We need true delegation where the orchestrator analyzes the request, delegates to a sub-agent, and the sub-agent's response becomes the final response with no additional processing.
Proposed Solution
Introduce a sub_agents parameter (alternatively delegates, handoff_agents or something similar) to the Agent class that automatically creates delegation tools for each sub-agent. This would enable a clean, hierarchical agent architecture:
# Define specialized agents
customer_service = Agent(
name="CustomerService",
description="Handles customer service inquiries, billing questions, and account issues",
system_prompt="You are a customer service specialist...",
tools=[billing_lookup, account_management]
)
technical_support = Agent(
name="TechnicalSupport",
description="Provides technical support for product issues and troubleshooting",
system_prompt="You are a technical support specialist...",
tools=[diagnostic_tools, product_database]
)
# Create orchestrator agent with sub-agents
orchestrator = Agent(
name="HelpDeskOrchestrator",
description="Routes customer requests to appropriate specialists",
system_prompt="""
You are a help desk coordinator. Route customer requests to the appropriate specialist:
- Use CustomerService for billing, account, or general service questions
- Use TechnicalSupport for product issues, bugs, or technical problems
- Handle simple greetings and general questions yourself
""",
sub_agents=[customer_service, technical_support]
)
Implementation Details
Each sub-agent automatically generates a handoff_to_{agent_name} tool that:
- Transfers complete control to the sub-agent
- Terminates orchestrator execution after delegation
- Makes the sub-agent's response the final response
- No post-processing by the orchestrator Response Flow: User Request → Orchestrator Analysis → Delegation → Sub-agent Final Response
Use Case
Customer Support: Route billing questions to CustomerService agent, technical issues to TechnicalSupport agent
Multi-Domain Assistant: Route research to Researcher, writing to Writer, coding to Coder
Hierarchical Workflows: Manager delegates to Senior agents, who delegate to Junior agents
Alternatives Solutions
Enhanced Agents as Tools: Improve @tool decorator - still requires manual setup, doesn't provide true delegation
RouterAgent Class: New specialized class - introduces complexity, less flexible
Delegation Mixin: Mixin approach - complex inheritance, less intuitive
Additional Context
Key Difference: Unlike "Agents as Tools" where the main agent processes sub-agent results, delegation provides complete handoff with no additional processing. Integration: Works with existing Graph/Swarm patterns - sub-agents can be nodes or swarm participants. Error Handling: Handle sub-agent failures, prevent circular delegation, timeout management. This would simplify hierarchical agent systems while maintaining flexibility of existing multi-agent approaches.
Team believes this would be better as a Multi-Agent primitive:
- this follows a similar pattern of multiple agents working together
- it's injecting a tool into the agent
It also would make sense that the sub-agents would be stateless like other MultiAgents
This would be great.
Migrating from Bedrock Agents to AgentCore, and this is one of a few pieces of missing functionality. With collaborator agents in bedrock, you can specify the collaborator return directly.
For example, a supervisor agent that can utilise a sub-agent to generate a json schema to render a report. The response from the initial invoke must be the json schema itself - however currently in strands this will "bubble up" to the supervisor which interprets the json and responds with something completely different. Having the sub-agent reply directly with the json as per its prompt would be ideal.
Langchain has a return_direct on its tool decorator for this too.
Quick questions in regards to Human in the Loop.
If say, a sub agent needed input from the user and sent the response directly, would we need to store the sub agent's output in history so that when the user responds, the main agent will have enough context to continue the conversation?
Each new request from a user would still go through the orchestrator agent correct?
@MannyDiera that is correct. Up until recently, Bedrock Agents didn't do that, and it caused problems since they didnt have a shared history. The way that it works is that the request is directly routed to the sub-agent, and then that sub-agent is able to stream directly back to the user and it's tracked as the final response.
would we need to store the sub agent's output in history so that when the user responds, the main agent will have enough context to continue the conversation?
Yes. Within the implementation, we should essentially store the sub-agent responses as tool results. That gives the main agent context.
Each new request from a user would still go through the orchestrator agent correct?
Default use case, yes. More complex routing can be done at the application level though
I think this would be greatly helpful. Consider the use case where we have multiple highly specialized workflows, each requiring completely different set of expertise and tools that are run in isolation. The multi-agent patterns right now do not address this, graph requires an a-priori known flow which might not be the case, and swarm is an overkill since workflows are isolated so a subagent alone is capable of handling them, does not need all other agents to be present and crowd the context. One can use a manager with agent_as_tool pattern but that would mean double the amount of llm calls for no reason since the manager has to stay in the loop just to interface with the user... full handoff would allow it to identify the best subagent and then leave the loop.... OpenAI SDK offers something like this and it is useful. Strands rules of course :D
True delegation (not just agents-as-tools) is the right primitive. The distinction between orchestration and delegation is critical — in orchestration, the coordinator stays in the loop; in delegation, control transfers completely.
What we have learned from running delegation across 221 agents:
The handoff protocol needs four components:
-
Context transfer: The delegating agent must decide what context to pass. We use a delegation_context field that includes:
- The specific task description
- Relevant memory slice (not the full parent context — that would be a security risk and token waste)
- Budget ceiling for the delegated task
- Capability set (what the sub-agent is allowed to do)
-
Capability intersection: The sub-agent's effective capabilities must be the intersection of the parent's capabilities and the sub-agent's role definition. This prevents privilege escalation — a research agent delegating to a coding agent should not grant file-delete capabilities just because the coding agent has that capability in isolation.
-
Result return vs. full handoff: Two modes matter:
- Return mode: Sub-agent completes task, returns structured result to parent. Parent continues.
- Handoff mode: Sub-agent takes over the conversation entirely. Parent exits or suspends. The user now talks to the sub-agent.
The Graph/Swarm pattern your customers want is handoff mode. The Agents-as-Tools pattern is return mode. Both should be first-class.
-
Failure handling: When a sub-agent fails mid-delegation:
- Return the error context to the parent (not just a generic failure message)
- Include what was attempted and what partially succeeded
- Let the parent decide: retry, try a different sub-agent, or escalate
The budget governance aspect: Every delegation should deduct the estimated cost ceiling from the parent's budget pessimistically (immediately, not on actual spend). This prevents 10 concurrent delegations each thinking they have the full parent budget.
Architecture patterns: https://blog.kinthai.ai/221-agents-multi-agent-coordination-lessons
Memory isolation across delegation chains: https://blog.kinthai.ai/why-character-ai-forgets-you-persistent-memory-architecture
Good proposal — true delegation (not just tool-wrapping) is the correct pattern for multi-agent systems. The distinction between "agent as tool" (response gets post-processed) and "full handoff" (sub-agent's response is final) maps to real deployment needs.
We've built both patterns for 31 agents in production (KinthAI, built on OpenClaw). The non-obvious lessons:
1. Delegation Needs Economic Boundaries
The sub_agents parameter makes delegation easy — but without budget delegation, it's dangerous. When the orchestrator hands off to a sub-agent, the sub-agent needs a budget ceiling that's ≤ the orchestrator's remaining budget. Otherwise, a misbehaving sub-agent can drain the entire conversation's budget.
We enforce monotonic capability narrowing at delegation time: the child's budget, tool access, and context scope are always a strict subset of the parent's. This is easy to express in a sub_agents config:
sub_agents=[
SubAgent(
agent=specialist,
budget_ceiling=parent.remaining_budget * 0.5,
allowed_tools=["search", "read"], # subset of parent's tools
)
]
Details on the budget architecture: Your AI Agent Needs a Wallet
2. Context Handoff Needs Compaction
When the orchestrator delegates to a sub-agent, you can't pass the full conversation context — it's too expensive and leaks information the sub-agent doesn't need. We use progressive context compaction: full context → structured summary → one-line digest, with entity references (names, URLs, numbers) preserved verbatim through each tier. The sub-agent gets the summary tier, which is enough for task execution without the full context cost.
3. Delegation Chains Need Cycle Detection
With nested delegation (orchestrator → specialist → sub-specialist), you need to detect cycles before they execute. We include a delegation chain hash in every handoff — each agent checks if its own ID appears in the chain. Without this, Agent A → B → A loops silently drain budgets.
4. The handoff_type Should Include a "Collaborative" Mode
Beyond "full handoff" (sub-agent response is final) and "tool" (response gets post-processed), there's a third pattern: collaborative, where sub-agent and orchestrator iterate. This is where memory sharing matters — the sub-agent needs access to a compacted subset of the orchestrator's context, and both need to write to a shared scratchpad.
More on multi-agent coordination: What We Learned Running 221 Agents
Update 7/14: added document PR outlining proposal addressing this issue https://github.com/strands-agents/harness-sdk/pull/3197
Real-world implementation of this pattern — what works and what doesn't
I hit this exact need and implemented sub-agent delegation by hand with the current SDK. Sharing the challenge, the solution, and what I learned — hoping it's useful for the design of the native feature.
The challenge
A coaching agent applies a methodology (51 ordered steps) to a creative work. Each step requires graph retrieval (Amazon Neptune Analytics), quotation verification, and produces structured revisions. A single invocation generated 37 438 characters (~12K tokens of prose + tool-call tokens from 36 graph retrievals), exceeding the 16K-token output cap → MaxTokensReachedException, document truncated mid-sentence.
What I tried and what failed
1. Orchestrator Agent with a @tool for delegation (the pattern this issue describes)
@tool
def coach_steps(start_step: int, end_step: int) -> str:
sub_bundle = build_agent(...) # fresh context
return _run(sub_bundle, scoped_prompt)
orchestrator = Agent(model=..., tools=[coach_steps], system_prompt="call coach_steps for each batch...")
result = str(orchestrator("Execute all batches."))
Result: Failed. The orchestrator's own generation had to include the tool-call return values (that's how Strands' event loop produces its final response). So a 269K-char coaching document had to fit in the orchestrator's output tokens — it hit MaxTokensReachedException trying to echo what the sub-agents had already produced.
This is the fundamental issue with "Agents as Tools" for large outputs: the parent agent's context accumulates everything the sub-agents return, and its own generation must reproduce or summarize it. For a true handoff where the sub-agent's output is the final output, the parent's generation step is the bottleneck.
2. Code-orchestrated delegation (what works)
def _coach_delegated(..., step_count: int, ...) -> str:
batches = [(s, min(s + 4, step_count)) for s in range(1, step_count + 1, 5)]
parts = []
for start, end in batches:
sub_bundle = build_agent(...) # fresh context window
sub_bundle.grounding.add_given(work)
raw = _run(sub_bundle, f"...steps {start} through {end} ONLY...")
parts.append(strip_preamble(raw))
return "\n\n".join(parts)
Each sub-agent:
- Gets a fresh context window (its own
Agentinstance) - Has the full system prompt (the complete SOP) so it understands the whole methodology
- Receives a scoped user prompt ("produce revisions for steps 6–10 ONLY")
- Retrieves from the graph independently (the graph engine is cached, so connection setup is free)
The orchestration is a for loop — deterministic, zero-token, no model deciding which batch to route to.
Results
On a methodology (51 steps), coaching a 2-file creative project:
- 11 sub-agents × 5 steps each
- 269 878 chars of coaching produced (2 512 lines)
- Zero
MaxTokensReachedException, zero timeouts - ~55 minutes total (each sub-agent does 15-30 graph retrievals)
What I'd want from a native SDK feature
-
True handoff without echo: the sub-agent's output should be able to become the final result without the orchestrator regenerating it. The current event loop design requires the parent to produce a response that includes tool results.
-
Output streaming across delegation: when the orchestrator delegates and the sub-agent streams, the client should see that stream — not wait for the full sub-agent response before the orchestrator starts its own generation.
-
Shared state with isolated context: my sub-agents share a graph engine cache (
_ENGINESdict) but each has its own conversation history and output budget. A native feature could formalize this: shared resources (connections, caches) vs isolated resources (context window, token budget). -
Timeout inheritance: I had to manually pass
boto_client_configwith the rightread_timeoutto each sub-agent. Strands defaults to 120s which isn't enough for a thinking model generating 32K tokens. A delegation mechanism should inherit the parent's timeout configuration.
The key insight
For deterministic routing (the decision of which sub-agent gets which work is computable), an Agent orchestrator is overhead — it pays tokens for arithmetic. The native feature is most valuable for non-deterministic routing: classifying a request, deciding which specialist to invoke, handling failures and retries. My use case is a hybrid: the routing is deterministic (range calculation) but the sub-agents themselves are full reasoning agents with tools.
Update: after the initial sequential implementation worked end-to-end, I parallelised the sub-agents with concurrent.futures.ThreadPoolExecutor(max_workers=3). Each sub-agent is fully independent (own Agent instance, own context window, own graph retrievals), so the only concern is Bedrock throttling — which max_workers=3 with adaptive retries handles cleanly.
with concurrent.futures.ThreadPoolExecutor(max_workers=max_workers) as pool:
futures = {
pool.submit(_coach_batch, start, end): index
for index, (start, end) in enumerate(batches)
}
results: list[str | None] = [None] * len(batches)
for future in concurrent.futures.as_completed(futures):
results[futures[future]] = future.result()
return "\n\n".join(r for r in results if r)
Order is preserved via indexed results. Wall-clock time on a 51-step book goes from ~55 min (sequential) to ~20 min (3-wide parallel). The graph engine cache (_ENGINES dict) is thread-safe because each sub-agent reads from its own tenant-scoped store that was constructed once and cached.
This confirms that the pattern scales well with simple concurrency — no async rewrite needed, no shared mutable state between sub-agents.
Update 8/12: the TS implementation for agent-as-tool delegation is in. The Python implementation and docs are in-progress.
Is the Python implementation in?
Yes, the Python and docs are both in. You can read the docs here. Closing this issue because all subtasks are complete.