# Hand-Offs and Swarm-Style Networks — LangGraph Agents & Multi-Agent Systems

Source: https://www.geekswithgeeks.com/en/langgraph-agents/x-handoff

> Let agents pass control directly to one another.

## Peer to peer instead of via a manager

In a **network / hand-off** design there is no central manager: each agent decides whether to answer or **hand off** to another agent (for example, a general support agent hands a billing question to the billing agent, and the billing agent can hand back). Hand-offs carry **context** (the relevant messages and a summary) and are implemented in LangGraph with `Command(goto=other_agent, update=...)` or with a hand-off tool the model can call. Benefits: flexible and natural for conversational products. Risks: **ping-pong loops** between agents, lost context and harder global control. Mitigate with a hop counter in state, an allow-list of who may hand to whom, and logging of every hand-off.

## A guarded hand-off (illustrative)

The node refuses to hand off after too many hops and only to allowed targets. Not run here.

```python
from typing import Literal
from langgraph.types import Command

ALLOWED = {"support": {"billing"}, "billing": {"support"}}
MAX_HOPS = 4

def support(state) -> Command[Literal["billing", "__end__"]]:
    wants_billing = "invoice" in state["messages"][-1].lower()
    if wants_billing and "billing" in ALLOWED["support"] and state["hops"] < MAX_HOPS:
        return Command(goto="billing", update={"hops": state["hops"] + 1})
    return Command(goto="__end__", update={"reply": "support handled it"})
```

**Quiz:** What is a typical risk of hand-off networks?

- [x] Agents ping-ponging control back and forth
- [ ] Too few model calls
- [ ] No need for state
- [ ] Automatic correctness

*Answer:* Agents ping-ponging control back and forth. Without hop limits, agents can pass a task around forever.
