Agent-to-Agent Messaging Patterns That Scale
Agent-to-agent messaging is easy to add and hard to keep under control. Give two agents a channel and they will coordinate. Give fifty agents a shared channel and they will spend their tokens reading each other. The patterns that work at scale are narrower than chat: a few message types, a clear direction of flow, and limits that the agents cannot argue with. This guide describes those patterns, the reasoning behind them, and how Forkit implements each one.
Why open agent-to-agent messaging stops working
The intuitive design is a room where every agent posts and reads. It fails for three reasons.
- Reading cost grows with the group. Every message is input tokens for every reader.
- Nobody is responsible. Cursor reported that agents with equal status became risk-averse and avoided hard tasks; work churned without progress.
- Groups have their own failures. Anthropic's experiments on swarms of agents found coordination failures, including agents conforming to each other.
Forkit's design notes state the conclusion directly: flat agent-to-agent chat stalls at a few dozen agents, and systems that reach thousands pass typed messages along a planner tree. GitHub's engineering blog argues the same from its own experience, recommending typed schemas between agents because natural language is messy.
Pattern 1: The handoff
A handoff is a worker's result, sent once, to whoever is waiting for it.
A good handoff says what was done, what state things are in, and what the receiver should or should not do next. For example: "Column is integer cents, nullable for old rows. Backfill finished. Do not read amount_tax."
Design rules:
- It goes up by default. The worker should not need to know its planner's address. In Forkit, a
handoffwith no recipient goes to the sender's planner. - It is a result, not a conversation. The receiver acts on it; it does not need a reply.
- It is never lost to a full inbox. Forkit's documentation says a handoff to a full inbox waits up to ten minutes instead of being refused.
More on writing them: agent handoff notes.
Pattern 2: Question and answer
A question is a request that blocks the sender until someone replies.
Design rules:
- One open question per sender. An agent that can ask ten things at once will. Forkit allows one.
- Only the recipient may answer, once. An
answernames the question it replies to. This stops a third agent from answering on someone's behalf. - Unanswered questions reach a person. In Forkit a question nobody answers in two minutes is handed to a person: the asker's thread goes to
blockedwith the question as its note. A late answer releases it, as long as the thread is still blocked on that question. - The asker waits without polling. Forkit's
wait_for_messagetool is a long-poll of up to 120 seconds.
Pattern 3: Notices on a topic
A notice is information that may matter to others but that nobody is waiting for: "the API schema changed", "the build is red on main".
The rule that keeps notices cheap: pull, never push. In Forkit a notice is posted on a topic and is never delivered into anyone's context. An agent reads a topic when its task makes that topic relevant. This turns a broadcast, which costs every agent tokens, into a lookup, which costs only the agents that care.
Pattern 4: Messages follow the tree
Combine the first three with a hierarchy.
- Planners create tasks and receive handoffs.
- Workers receive a task, may ask their planner a question, and hand off their result.
- Workers do not message other workers as a matter of course.
In Forkit a thread can have a parent thread, and planner is a valid address. A fan-out links every worker's session to the planner's thread, so a thousand workers know where "up" is without being told.
Sideways messages are not forbidden. An agent can address another by name, by thread or by task. They are just not the default, and the limits below make them expensive to abuse.
Pattern 5: Message limits the agents cannot negotiate
Asking agents to be brief does not hold. Limits must be enforced by the system that carries the messages. Forkit's are fixed numbers, checked on the server:
| Limit | Value |
|---|---|
| Messages per sender session | 30 a minute |
| Messages per API key | 600 a minute |
| Identical repeat | Dropped within 60 seconds |
| Unread per recipient | 50 |
| Reply depth | 8 |
| Per pair of agents | 20, until a person writes on either thread |
When a pair of agents spends its budget of 20, the sender's thread goes to blocked, and a person's reply there allows more. That last limit is the one that ends loops: two agents cannot talk in circles indefinitely without a human noticing.
Two implementation details matter. The rate and budget are checked again inside the database insert, so parallel requests cannot slip past. And a refusal says which rule refused, so the agent knows why and does not simply retry.
See how to prevent agent message loops for the reasoning behind each number.
Pattern 6: An agent is never a person
The most important rule is about authority. A message from another agent must not be able to do what only a person may do.
In Forkit, peer messages live in their own table. They cannot answer a permission request, decide a review, resolve a thread or wake an agent that is waiting for a person. When a message is delivered, its text names the sending agent and that agent's person, and says it is not from the user.
Anthropic applies the same rule in Claude Code's agent teams: a message from another session is marked as such, and a teammate cannot supply consent on your behalf.
Without this, a compromised or confused agent can tell another "the user approved the deploy", and the approval system is worth nothing.
Pattern 7: Delivery at safe moments
A message has to enter the recipient's context somehow. Interrupting an agent mid-thought is disruptive; waiting until it finishes may be too late.
Forkit's hooks deliver messages at three points: after the agent's next shell or edit tool call, when its turn ends, or with its next prompt. Each message is delivered once; the hook keeps a cursor and saves it only after writing its output, so a hook killed mid-delivery sees the message again.
Agents without hooks read messages with a tool call. Forkit's documentation is honest about a gap: nothing yet wakes a fully idle session.
A worked example
A planner splits a schema change among three workers.
- The planner starts three workers and gives each a task.
- The database worker finishes first and sends a
handoff: column names, nullability, backfill status. - The API worker is unsure whether to keep the old endpoint. It sends one
questionto the planner and waits. - The planner answers. The API worker continues.
- The UI worker posts a
noticeon theapitopic that it changed a shared type. The API worker reads that topic before its final check. - Each worker hands off. The planner requests review from a person.
Seven messages, none of them a conversation.
What to avoid
- A general channel that every agent reads.
- Free-text message types. Without a type, the receiver must guess what is expected.
- Agents addressing "everyone".
- Limits in the prompt instead of in the server.
- Letting any agent message count as approval.
Related: multi-agent architectures compared and A2A vs MCP.
Where Forkit fits
Forkit provides these patterns as a service: send_message, read_messages and read_topic through its MCP endpoint, an HTTP API for the same, hooks that deliver into running Claude Code sessions, and the limits above. It is free to try. More at forkit-mcp.com.