Repository navigation
Description
Problem
Agents send each other too many A2A messages, and a busy receiver pays for each one. While the receiver's turn is running, every message is queued as its own run (D4: only Astra takes peer messages mid-turn), so N messages become N turns in a row. The receiver usually answers each one, and when the sender is Astra each answer reaches it mid-turn and prompts more messages.
- Measured on this host's ledger and run history: the deepest queue was 11 A2A deliveries waiting on one Fable agent (2026-09-26). 6 came from an Astra agent and 7 from one Opus agent (an ask, three follow-ups and three plain messages). A pile of 40 was seen elsewhere. Astra sends the most, but Claude senders do it too.
- Our own instructions invite it.
T3OrchestrationInstructions.tstells Crew members to share "intermediate findings … as soon as useful. Do not wait."
Letting peer messages into a running Claude turn is not an option. A live test on 2026-10-03 (Claude Code 2.1.287, Opus 5.5, the SDK's priority: "now" call that upstream's steerTurn makes) cancelled a second Bash call in the same message with "The user doesn't want to take this action right now. STOP…", and the agent stopped and told the person they had declined it (2 of 2 runs). D4 still holds on upstream main after pingdotgg#2829.
Decided (Jackson, 2026-10-03)
Fix it on the sender's side. Rejected:
- Merging queued messages into one turn. It breaks the one-to-one mapping between ledger messages and upstream messages that cancellation and delivery proof rely on, it mixes unrelated requests together, and there's no good UI for it.
- Refusing sends above a limit.
- A "queue cleared" notice. The warning tells the sender to group its updates, not to wait for a reply, so there's nothing to wait on.
Wanted
- Warning in the send result. When
send_messagereaches an agent that is mid-turn and won't take the message into that turn (anything except a running Astra turn), the result says so with measured facts: that the receiver is mid-turn, how many messages are waiting for it and how many of those are from the caller, that it handles each one as a separate turn after its current turn ends, and to put any further updates in one message.- Show it from the first queued message on. No threshold.
- When the receiver is idle, or will take the message mid-turn, the result is unchanged.
- Compute it when the tool is called, from the receiver's thread state (as
astraPeerSteeringRunreads it) plus its A2A deliveries that haven't been delivered yet. It is never stored, so a replayedclient_request_idreports the current state. No new events or projections.
- One sentence in
sendToolDescription(envelopes.v1.json, bumpversion) saying the same thing up front. - Rewrite the Crew line in
T3OrchestrationInstructions.ts. Share what would change the other agent's work, grouped into one message, instead of "as soon as useful". This is J5's own text, so no new FORK.md case is needed.
Draft wording (envelopes.v1.json is human-owned; Jackson approves the final text in the PR)
- Warning:
{{receiverId}} is in the middle of a turn. {{waiting}} messages are waiting for it ({{fromYou}} from you), and it will handle each as a separate turn after its current turn ends. Put any further updates for it in one message. - Tool description, added sentence:
An agent that is busy usually handles each message as its own turn after its current one ends, so put related updates in one message rather than sending them one by one. - Crew line:
…can coordinate directly with send_message: share findings, concerns, questions, evidence, and final results when they would change the other agent's work, grouped into one message rather than sent as each one happens. Do not wait for an artifact or a separate coordination approval. …
Scope
- Senders: agents only. Machine senders get nothing new.
- Receivers on a peer server: no warning for now. A send to a known remote receiver makes no network call today;
SendService.remoteMembershipuses the recorded route "so one dead peer never taxes a send to a known one", and delivery happens later in the worker. Reporting remote state would need a live request on every cross-server send, plus a peer contract change that older servers treat as "unknown". Tracked in A2A backlog warning for receivers on another server #425. - Held and usage-limited receivers: these stay with Held A2A deliveries and limited receivers: tell the sender what is happening #272. Shape the result field so Held A2A deliveries and limited receivers: tell the sender what is happening #272 can report those states the same way later.
- Definition:
docs/j5/product/a2a/index.mdgains a Delivery criterion along the lines of "a send to an agent whose turn is running returns the measured backlog". It ships in the same PR. Jackson approves the definition change and the wording there, with Product's check asdocs/j5/process/docs.mdrequires.
Checking it worked
After it ships, run the queue-depth measurement again (the deepest pile of A2A deliveries waiting on one thread, from orchestration_v2_projection_runs) and compare it with the baseline of 11.
Related: #272 (tell the sender about held or limited receivers), #285 (A2A metadata as context records; does not affect tool results).
Activity
feat(a2a): warn senders when the receiver is mid-turn with messages w…