Blog · Guide · 16 November 2026

How to Prevent Agent Message Loops

Agent message loops are what you get when two or more agents can message each other and nothing outside them keeps count. One asks, the other replies with a question, the first answers and asks again. Each message looks reasonable. Together they are an endless, expensive conversation that produces nothing. Prompts that say "be concise" do not fix this. Limits enforced by the system that carries the messages do. This guide explains how loops form and the six limits that stop them, with the values Forkit uses.

How agent message loops form

Loops come in a few recognisable shapes.

The polite loop. "Done, let me know if you need anything." "Thanks, I will. Anything else from your side?" Models are trained to be helpful and to respond. Two of them in a channel will keep responding.

The clarification loop. Agent A asks B a question B cannot answer. B asks A for details. A, which asked because it did not know, guesses. B asks again.

The retry loop. A message fails or gets no reply, so the sender sends it again, and again.

The delegation loop. A hands a task to B, which decides it belongs to A and hands it back.

The crowd. Many agents share a channel. Every message is read by all, several respond, and volume grows with the square of the group. This is multi-agent chatter, and it is why flat chat among dozens of agents stalls.

Anthropic's experiments on swarms of agents found coordination failures in groups, including agents conforming to one another. Cursor found that agents with equal status churned for long periods without progress. Loops are one visible form of both.

Why instructions are not enough

You can tell agents to avoid loops. It helps a little. It fails because:

  • Each agent sees only its side. From inside, every reply is justified.
  • Neither agent knows the total count.
  • A new session does not remember the last one's restraint.
  • Text can talk an agent out of its instructions.

A limit has to live where the agents cannot reason with it: in the server that accepts or refuses the message. Forkit's documentation states this as a rule: every limit is enforced by the server.

Limit 1: Rate limits per sender

Cap how many messages a sender can send in a window.

Forkit allows 30 messages a minute per sender session and 600 per API key. The second number exists so that opening new threads buys nothing: an agent cannot escape the per-session cap by starting another session under the same key.

This bounds the speed of any loop. It does not end one, because a loop can run slowly forever.

Limit 2: Drop duplicate messages

If an agent sends the same message twice in a short time, the second copy adds nothing.

Forkit drops an identical repeat within 60 seconds. That removes the retry loop at its source.

Limit 3: Cap unread messages per recipient

An agent with a flooded inbox cannot work, and reading the backlog costs tokens.

Forkit caps 50 unread messages per recipient. Beyond that, senders are refused. There is one considered exception: a handoff, which is a worker's result, waits up to ten minutes for room instead of being refused, because losing results is worse than delaying them.

Limit 4: Limit reply depth

A chain of replies is a conversation. Conversations between agents should be short.

Forkit allows replies 8 deep. An answer names the question it replies to, and the chain's depth is tracked. After eight, the chain ends.

Eight is generous for question and answer. If two agents need more than eight exchanges to settle something, they need a person or a better plan.

Limit 5: A pair budget that only a person can refill

This is the limit that ends loops instead of slowing them.

Forkit allows 20 messages per pair of agents since a person last wrote a message on either thread. When the pair's budget is spent:

  • The sender's thread goes to blocked.
  • It appears in the inbox as needing a person.
  • A person's reply on that thread allows more messages.

Answering a permission request or closing a thread does not refill it. Only a written reply does. The reasoning is that the budget measures how far two agents have gone without human attention. A person reading the exchange and replying is the attention. Clicking allow on an unrelated command is not.

The effect is a hard guarantee: no two agents can exchange more than twenty messages without a person looking.

Limit 6: One open question, and escalation

Two more rules shape question traffic.

  • One open question per sender. An agent cannot fire ten questions and wait for whichever returns.
  • Only the recipient may answer, once. No third agent can jump in, and no question collects several conflicting answers.

And for questions that go nowhere: a question nobody answers in two minutes is handed to a person. The asker's thread goes to blocked with the question as its note. If an answer arrives late while that note still stands, the thread is released.

So the clarification loop cannot form. A asks once. Either B answers, or a person is told.

Make refusals informative

When a message is refused, the sender must learn why, or it will retry.

Forkit's refusals say which rule refused. An agent told "rate limit: 30 a minute per session" can wait. An agent told "pair budget spent; a person must reply" can stop and report. An agent told only "error" will try again, which is the retry loop.

Make limits race-proof

A limit checked before the write can be beaten by parallel requests: ten messages sent in the same instant each see a count of 29.

Forkit's documentation notes that rate and budget are checked again inside the insert itself, so parallel requests cannot pass them. If you build your own, put the check and the write in one atomic statement.

Summary of the limits

Limit Forkit's value Stops
Rate per sender session 30 a minute Fast loops
Rate per API key 600 a minute Escaping through new sessions
Identical repeat Dropped within 60 seconds Retry loops
Unread per recipient 50 Flooded inboxes
Reply depth 8 Long conversations
Per pair of agents 20, until a person writes Any loop between two agents
Open questions per sender 1 Question storms
Unanswered question Handed to a person after 2 minutes Clarification loops

Design choices that reduce the need for limits

Limits are the backstop. Structure prevents most loops before a limit is reached.

  • Use a tree. Workers send results up to a planner and do not chat sideways.
  • Use typed messages. A handoff expects no reply. A notice is pulled from a topic and never pushed, so it cannot start a conversation.
  • Mark agent messages as agent messages. Forkit's delivery text names the sending agent and says the message is not from the user, which discourages the receiver from treating it as a command that needs acknowledgement.
  • Do not record chatter on threads under review. Forkit skips the peer note on a thread that is in review, so review is not disturbed.

See agent-to-agent messaging patterns for these in detail.

Testing your own setup

Three experiments tell you whether you are protected.

  1. Tell two agents to "keep each other updated". Count messages after ten minutes.
  2. Have one agent ask another something it cannot answer. See where the question ends up.
  3. Send the same message five times in ten seconds. See how many arrive.

If the first number is unbounded, the question in the second never reaches a person, or all five in the third arrive, you have loops waiting to happen.

Related: how to stop a runaway agent and multi-agent architectures compared.

Where Forkit fits

Forkit carries messages between coding agents and enforces every limit above on the server, so a loop ends in a person's inbox instead of on your bill. It is free to try. More at forkit-mcp.com.