continuum-handoffs
Skill84 starsChanged 6 months agoApache-2.0View on GitHub
Build agent-to-agent transitions with Continuum's `Handoff` system — triage routing, history summarization modes (FULL/SUMMARY/RECENT_N/HYBRID), cycle detection, depth tracking, return-to-parent. Invoke when the user asks "route customer requests to specialists", "agent that can transfer to another", "summarize history before handing off", or anything multi-agent that's a *transition* (not a *workflow*).
In this repository49 other files it gives its agents.
- AGENTS.mdAGENTS.md
- .claude/commands/monitoring/agents.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- .cursor/rules/continuum.mdcCursor rule
- AgentDB Advanced FeaturesSkill
- AgentDB Learning PluginsSkill
- AgentDB Memory PatternsSkill
- AgentDB Performance OptimizationSkill
- AgentDB Vector SearchSkill
- browserSkill
- continuum-agentSkill
- continuum-claude-codeSkill
- continuum-codexSkill
- continuum-cursorSkill
- continuum-evaluationSkill
- continuum-llm-providersSkill
- continuum-memorySkill
- continuum-observabilitySkill
- continuum-quickstartSkill
- continuum-recipesSkill
- continuum-streamingSkill
- continuum-temporalSkill
- continuum-testingSkill
- continuum-tools-mcpSkill
- continuum-workflowsSkill
- github-code-reviewSkill
- github-multi-repoSkill
- github-project-managementSkill
- github-release-managementSkill
- github-workflow-automationSkill
- Hooks AutomationSkill
- Pair ProgrammingSkill
- ReasoningBank with AgentDBSkill
- ReasoningBank IntelligenceSkill
- Skill BuilderSkill
- sparc-methodologySkill
- stream-chainSkill
- swarm-advancedSkill
- Swarm OrchestrationSkill
- V3 CLI ModernizationSkill
- V3 Core ImplementationSkill
- V3 DDD ArchitectureSkill
- V3 Deep IntegrationSkill
- V3 MCP OptimizationSkill
- V3 Memory UnificationSkill
- V3 Performance OptimizationSkill
- V3 Security OverhaulSkill
- V3 Swarm CoordinationSkill
- Verification & Quality AssuranceSkill
The file
We split this skill into the rules it gives an agent
6 rules. About 0 are common, 0 are distinctive, and 6 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
6
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 116
Import path: continuum.agent.exceptions (not re-exported at the package root).
- Very specific: line 196
Don't forget to register the target via runner.register_agent(...) or agent_registry={...} — HandoffTargetNotFoundError.
- Very specific: line 198
Don't reference the handoff tool by transfer_to_<target> — actual prefix is handoff_to_<target>.
- Very specific: line 200
Don't try to import HandoffCycleDetectedError from continuum.agent — only from continuum.agent.exceptions.
- Very specific: line 202
Don't crank max_handoff_depth to skip cycle errors — fix the routing logic instead.
- Very specific: line 205
Don't pass async hooks for on_handoff — hooks are sync.
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Continuum Handoffs Skill
Authoritative source: docs/agent.md, §7.
Handoffs are agent-to-agent transitions ("triage → billing"), distinct from workflow agents which compose multiple agents into one (Sequential, Parallel, etc.). Use a
RouterAgentfor stateless routing; use handoffs when the source agent should be able to decide at any turn that the target should take over.
Imports
from continuum.agent import BaseAgent, AgentRunner, Handoff
from continuum.agent.types import HistorySummarizationMode, HandoffData, HandoffResult
from continuum.agent.exceptions import (
HandoffNotAllowedError, HandoffDepthExceededError,
HandoffTargetNotFoundError,
)
# HandoffCycleDetectedError is NOT re-exported from `continuum.agent`:
from continuum.agent.exceptions import HandoffCycleDetectedErrorDefine a triage agent
billing = BaseAgent(name="billing", instructions="Help with invoices and refunds.")
technical = BaseAgent(name="technical", instructions="Help with bugs and outages.")
triage = BaseAgent(
name="triage",
instructions="Route the customer to the right specialist.",
handoffs=[
Handoff(target_agent="billing",
description="Billing, payments, refunds, invoices"),
Handoff(target_agent="technical",
description="Bugs, errors, outages, integration issues"),
],
)
runner = AgentRunner(agent_registry={
"triage": triage, "billing": billing, "technical": technical,
})
resp = await runner.run(triage, "I want a refund for invoice 1234",
user_id="u1", session_id="s1")
print(resp.handoff_chain) # ["triage", "billing"]
print(resp.content) # the billing agent's replyHandoff fields
| Field | Type | Default | Purpose |
target_agent | str | required | Name of the target agent |
description | str | required | When this handoff should fire — read by the LLM |
condition | str | Callable | None | None | Extra guard (rarely used) |
transfer_history | bool | True | Pass conversation history to the target |
summarize_history | bool | True | Run an LLM summarization before transferring |
summarization_mode | HistorySummarizationMode | HYBRID | See table below |
recent_messages | int | 5 | Used by RECENT_N and HYBRID |
return_to_parent | bool | True | After the target finishes, control returns to the source |
History summarization modes
| Mode | Behaviour |
FULL | Pass the entire conversation verbatim — no summarization |
SUMMARY | Replace history with a single LLM-generated summary |
RECENT_N | Pass only the last recent_messages messages |
HYBRID (default) | LLM summary + last recent_messages raw messages |
from continuum.agent.types import HistorySummarizationMode
Handoff(
target_agent="billing",
description="...",
summarization_mode=HistorySummarizationMode.RECENT_N,
recent_messages=8,
)Tool prefix (internal detail)
The framework injects a hidden tool per handoff named
handoff_to_<target> (NOT transfer_to_…). The LLM calls this
tool to trigger the transition; you never write the tool yourself.
agent.is_handoff_tool_call(tool_name) -> tuple[bool, str | None]
detects whether a tool call is actually a handoff invocation.
Multi-level handoffs (depth + cycles + loops)
HandoffConfig.max_handoff_depth defaults to 10. Beyond that:
HandoffDepthExceededError(current_depth, max_depth, ...).
Cycles (e.g. A → B → A) are detected before the call — they raise
HandoffCycleDetectedError(from_agent, to_agent, agent_stack, ...).
Import path: continuum.agent.exceptions (not re-exported at the
package root).
Loops are the third case, and the one depth and cycle checks miss: under
return_to_parent=True the target is popped off the stack when it returns, so an
agent that keeps re-routing never grows the stack and never forms a cycle — it
just burns turns. HandoffLoopError(from_agent, to_agent, count, ...) catches it
at AgentConfig.max_consecutive_handoffs (default 3).
It fires only on the same target and the same request — reason plus
context, the two parameters a handoff tool declares:
| pattern | payload per handoff | result |
| re-routing loop | identical each time | HandoffLoopError |
| fan-out over N items | differs each time | never blocked |
So a voice agent handing one specialist ten different leads, or a triage agent
sending one specialist ten different tickets, is fine at any N — that is fan-out,
not a loop, and it is explicitly allowed. max_turns remains the backstop for a
loop that varies its wording enough to slip through.
Raise max_consecutive_handoffs only for a dispatcher that means to re-send one
identical request — same caution as max_handoff_depth: don't crank it to silence
a real loop, fix the routing or set return_to_parent=False so the target's
answer is returned directly.
Inspecting the result
resp = await runner.run(triage, "...")
resp.agents_used # ["triage", "billing"]
resp.handoff_chain # ["triage", "billing"]
resp.handoff # HandoffData of the most recent handoff (or None)
resp.handoff_result # HandoffResult with success / error / returned_to_parentStreaming exposes EventType.HANDOFF_START / HANDOFF_END /
HANDOFF_RETURN events with event.data = {"from_agent": ..., "to_agent": ..., "reason": ...}.
Driving handoffs manually with HandoffManager
from continuum.agent import HandoffManager
mgr = HandoffManager(llm_client=runner.llm_client, tracing_manager=None, max_depth=10)
mgr.validate_handoff(from_agent=triage, to_agent_name="billing")
data = await mgr.prepare_handoff(
from_agent=triage, to_agent=billing,
reason="Refund request",
messages=current_messages,
handoff_config=triage.get_handoff("billing"),
)Most apps don't need this — let the runner drive it.
RouterAgent vs Handoff
| Use case | Pick |
| LLM picks ONE specialist for the whole turn | RouterAgent (create_router_agent) |
| Source agent might decide during the conversation to transfer | Handoff |
| Source agent should regain control after the specialist finishes | Handoff with return_to_parent=True |
| Stateless mapping of intent → agent | RouterAgent |
A RouterAgent never looks back; a handoff chain can. Use whichever
matches the conversation shape.
Don't
- Don't forget to register the target via
runner.register_agent(...)oragent_registry={...}—HandoffTargetNotFoundError. - Don't reference the handoff tool by
transfer_to_<target>— actual prefix ishandoff_to_<target>. - Don't try to import
HandoffCycleDetectedErrorfromcontinuum.agent— only fromcontinuum.agent.exceptions. - Don't crank
max_handoff_depthto skip cycle errors — fix the routing logic instead. Cycles indicate either bad descriptions or a missing fallback agent. - Don't pass async hooks for
on_handoff— hooks are sync.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

