agentleFS
shyftlabsshyftlabs/continuum/.claude/skills/continuum-handoffs/SKILL.md

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*).

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
  1. Very specific:

    Import path: continuum.agent.exceptions (not re-exported at the package root).

    line 116
  2. Very specific:

    Don't forget to register the target via runner.register_agent(...) or agent_registry={...} — HandoffTargetNotFoundError.

    line 196
  3. Very specific:

    Don't reference the handoff tool by transfer_to_<target> — actual prefix is handoff_to_<target>.

    line 198
  4. Very specific:

    Don't try to import HandoffCycleDetectedError from continuum.agent — only from continuum.agent.exceptions.

    line 200
  5. Very specific:

    Don't crank max_handoff_depth to skip cycle errors — fix the routing logic instead.

    line 202
  6. Very specific:

    Don't pass async hooks for on_handoff — hooks are sync.

    line 205

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

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 RouterAgent for 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 HandoffCycleDetectedError

Define 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 reply

Handoff fields

FieldTypeDefaultPurpose
target_agentstrrequiredName of the target agent
descriptionstrrequiredWhen this handoff should fire — read by the LLM
conditionstr | Callable | NoneNoneExtra guard (rarely used)
transfer_historyboolTruePass conversation history to the target
summarize_historyboolTrueRun an LLM summarization before transferring
summarization_modeHistorySummarizationModeHYBRIDSee table below
recent_messagesint5Used by RECENT_N and HYBRID
return_to_parentboolTrueAfter the target finishes, control returns to the source

History summarization modes

ModeBehaviour
FULLPass the entire conversation verbatim — no summarization
SUMMARYReplace history with a single LLM-generated summary
RECENT_NPass 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:

patternpayload per handoffresult
re-routing loopidentical each timeHandoffLoopError
fan-out over N itemsdiffers each timenever 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_parent

Streaming 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 casePick
LLM picks ONE specialist for the whole turnRouterAgent (create_router_agent)
Source agent might decide during the conversation to transferHandoff
Source agent should regain control after the specialist finishesHandoff with return_to_parent=True
Stateless mapping of intent → agentRouterAgent

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(...) or agent_registry={...} — HandoffTargetNotFoundError.
  • Don't reference the handoff tool by transfer_to_<target> — actual prefix is handoff_to_<target>.
  • Don't try to import HandoffCycleDetectedError from continuum.agent — only from continuum.agent.exceptions.
  • Don't crank max_handoff_depth to 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.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.