Repository navigation
fix(server): agent messages join a busy Claude agent's turn instead of queueing - #690
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
BastiHu
left a comment
There was a problem hiding this comment.
Review from a three-seat crew (code quality, security, acceptance-criteria coverage), with findings cross-checked independently on Claude Opus 5.5 and GPT-6.1-Sol.
Verdict: approve with changes. The one change worth requiring before merge is F1 (a held turn can stay running with no timeout); see the comment on claudeAgentSteers.ts:127. The rest are minor or nits.
Validation at 0ce087a: apps/server tsc --noEmit clean; targeted tests 94/94; the PR's 8-file command 384/384; the three mutation claims reproduce. Security: no issues found. Agents cannot obtain createdBy: "user", and the unread notice reaches only the original sender.
PR-level gaps:
- The cited
test-reports/j5/claude-next-steer/*reports aren't in the repo, so the live-test evidence can't be checked. - The checklist says the human decision is "linked above", but there's no link.
|
Thanks @BastiHu, this was a really useful review. Fixes are in b22516c20b, and I replied on each thread. I resolved the ones I fixed and left F1 and the On the two PR-level points:
|
Jacksondr5
left a comment
There was a problem hiding this comment.
@bryantderosier Jackson and I reviewed this and ran our own live tests. He agrees with the direction: steer peer messages into Claude with "next". He'd like three changes before merge.
1. Keep the hold
We tested whether "next" alone would do, using a local build of this head with j5ClaudeSteerHoldsResult never holding. All runs used Haiku 5.5 receivers and GPT-6-Luna senders.
| Case | "next" alone |
This PR |
|---|---|---|
| Ask arriving after the last tool call, 3 runs | 2 turns every time. The sender got turn-ended-no-reply 4–5 s before the real reply, which came from a second turn labelled "Background activity updated". |
1 turn every time, with a same-turn reply and no notice |
| Plain message arriving after the last tool call | 2 turns. Claude acted on it in the second. | 1 turn |
| Ask arriving during a tool call | 1 turn, no notice | 1 turn, no notice |
Without the hold, every late ask sends its sender a false "no reply" notice, so the hold earns its place. It's also less of a new dependency than it looks: upstream's adapter already reads command_lifecycle for its own prompts (claudePromptLifecycle).
2. Cut the unread-after-Stop notice into #694, and keep the cleanup
The notice worked live. A plain message still waiting at Stop got exactly one steered-message-unread, and the receiver stayed stopped. We'd still rather not carry it:
- Asks are already covered: both live Stop-with-an-ask runs got the existing stopped/cancelled notice.
- The case is narrow: in the waiting-ask run, Claude Code took the message out of its queue as the Stop landed.
- The sender can't act on it: the notice tells it not to retry.
- It's the fragile part: the notice has to decide whether Claude read a message. The CLI's
cancelledmeans either "never ran" or "read, then the turn was aborted". A probe on CLI 2.1.310 showedstarted, thencancelledfor a steer Claude had read before an interrupt. It didn't reach a notice live, because the adapter closes the query first, but it's a latent false notice.
#694 holds the design and that guard if we build it later. Please keep the part of this path that releases a turn's tracked steers when a run ends without a clean result, minus the notice, so steersByTurn doesn't keep stopped or failed turns.
3. Renumber FORK.md case 82 to 83
#689 is merging first and takes case 82. After it lands, please:
- change the inventory line to "84 entries: 1–83 plus 15b";
- renumber the case itself;
- update the
ClaudeAdapterV2.tsfile-table row; - update the references in
ClaudeAdapterV2.ts(threeJ5: case 82comments),DeliveryTransport.ts,SilenceDetector.tsand its test (if kept),claudeAgentSteers.ts,docs/j5/product/upstream.md(the D4 text, its Decided line, the history line) anddocs/j5/product/upstream-convergence.md.
Smaller, optional
- In case 82 (83), note that the hold relies on the
@internalcommand_lifecyclecontract of the user's unpinnedclaudebinary, so it's a check at Claude Code upgrades as well as upstream advances. That was Basti's last open ask. - The CLI's schema says
discardedcomes only when the session ends andrefusedonly for cross-session peer messages, so leaving them unmapped is fine.
Live test reports
These are in J5's artifacts store:
test-reports/j5/claude-next-steer/b22516c20b.md(this head)test-reports/review/pr690-next-without-hold/96ed4fb09e.md(the"next"-alone comparison)
Stop after a plain message was read (this head): no notice, receiver stays stopped.
pr690-plain-message-read-then-stop.mp4
Posted by Claude Opus 5.5 (Claude Code in J5 Code) on Jackson's behalf.
|
@bryantderosier #689 is now merged (0d75051) and holds FORK.md case 82, so this PR's case becomes 83 and the count line "84 entries: 1–83 plus 15b". #689 also added a temporary-patch entry (the completion burst guard) in the part of FORK.md this PR touches, so please rebase onto j5/main rather than resolving FORK.md by hand. Posted by Claude Opus 5.5 (Claude Code in J5 Code) on Jackson's behalf. |
…ng them A steer into a running Claude turn was sent with the SDK's "now" priority, which cancels the turn's running tool calls and makes the agent report a refusal the person never gave. Send it with "next" instead: Claude Code waits for the running tool calls and reads the message at the next tool result, inside the same turn, the way its own CLI handles a message typed mid-turn. A steer offered after the turn's last tool call is still queued when the turn's result arrives, and the CLI runs it as the next native turn. The adapter follows each steer's command_lifecycle frames and keeps the turn open until that steer's own result. Claude no longer reports that steering interrupts tools, so upstream's rule steers a delegated completion into a running Claude turn, and J5 delivers peer messages into one as it does for Codex GPT 6. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The Claude driver is "claudeAgent", so the check for "claude" never matched and peer messages to a busy Claude agent still queued. The test now builds its fixture from CLAUDE_PROVIDER. The send tool's description says Claude agents take an ordinary message into the turn they are running. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… wait Upstream wants a person's steer to reach Claude at once (pingdotgg#15720), so it keeps priority "now". Steers from agents and the server, such as a peer's update or a child's completion, use "next" and wait for the running tool calls. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A turn result can arrive before Claude acknowledges a steer, so once the session has reported command_lifecycle frames, an offered steer counts as waiting too. A failed result always ends the turn so its error shows. A CLI that reports no lifecycle never holds a turn open: a steer it runs after the turn's result reaches the thread as a wake turn. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…am's adapter Move the priority choice, steer tracking and turn hold into J5-owned j5/a2a/claudeAgentSteers.ts. Upstream's Claude adapter keeps four marked hooks, and its capability, tests and automatic-delivery behavior go back to upstream's. J5's delivery steers peer updates into a running Claude turn by driver. Recorded as FORK.md case 82; register D4 and the A2A, Crews and user docs say Claude takes peer messages mid-turn. Co-Authored-By: Claude Opus 5.5 <[email protected]>
An agent's message steered into a running Claude turn waits for its tool calls. If a person's Stop ends the turn first, Claude never reads it, and before this nobody was told. The leaf tracks each steer's thread message; when an interrupted run ends, the silence detector asks which of its steers Claude never took and sends each sender a steered-message-unread notice through the same path as a removed queued message (A2A AC30). Co-Authored-By: Claude Opus 5.5 <[email protected]>
The notice told the sender to send the message again, and a GPT 6 sender did within seconds, undoing the person's Stop. It now carries the stopped notice's "Do not retry" instruction. It says the receiver probably never read the message, because Claude can take it just as the Stop lands (the steer-and-Stop race register D5 leaves unguarded), which FORK.md case 82 and D4 now record. Co-Authored-By: Claude Opus 5.5 <[email protected]>
- Release a turn's tracked steers on every run that ends without a clean result, so a Claude process that dies mid-turn doesn't leave them behind. Only a Stop still tells the sender. - Read a steer's lifecycle frames only from the query it was offered on, and ignore lifecycle states the leaf doesn't know. - Drop the leaf's abort-result check: the adapter holds an aborting result before it asks. - Pin the failed results that are never held, and a Stop that ends a turn held open for a late steer. - j5_send_message says a Claude agent takes a steer once its running tool calls finish; envelope version 28. - AC29, D4's record line, the backlog comments and FORK.md case 82 match the code, and case 82 records what the hold relies on. Co-Authored-By: Claude Opus 5.5 <[email protected]>
b22516c to
7263cd8
Compare
|
@Jacksondr5 Pushed the rebased update in 7263cd8, addressing your review and follow-up.
Validation: 400 focused tests passed across 8 files, server typecheck passed, formatting passed, and targeted lint reported only the existing unused I checked the inline discussions: all 12 were already resolved, with no open review threads left to close. GitHub now reports the branch mergeable. This update does not merge or close the PR. — GPT-6.1-Sol (High), Codex in J5 Code |
Jacksondr5
left a comment
There was a problem hiding this comment.
Approving at 7263cd8. All three changes from the review are in: the hold is kept; the unread-after-Stop notice is out (now #694) and the cleanup of stopped and failed turns is kept; the case is renumbered to 84 after the rebase. The note that the hold relies on the CLI's internal lifecycle frames is in too. No open threads, and required CI is green. No new live test: the tested behaviour is unchanged, and the removed code wasn't something an agent or person sees.
Posted by Claude Opus 5.5 (Claude Code in J5 Code) on Jackson's behalf.
Summary
Peer messages sent to a busy Claude agent currently become separate queued turns, so Crew coordination can build large backlogs. I send agent steers with Claude Code's priority
"next", letting running tool calls finish before the message joins the turn. A person's steer keeps upstream's"now"behavior.A message arriving after the last tool call can otherwise run as a second native turn and trigger a premature no-reply notice. I keep the J5 turn open until the consuming turn's result, using the CLI's lifecycle frames. Terminal runs release tracked steers without an unread-after-Stop notice; that notice is deferred to #694. Busy Claude receivers no longer get the waiting-behind-messages notice.
Evidence
On
7263cd83df, the focused suite passed 400 tests across 8 files:vp test run apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts apps/server/src/orchestration-v2/ClaudeAutomaticDelivery.integration.test.ts apps/server/src/orchestration-v2/SteeringCompletion.integration.test.ts apps/server/src/j5/a2a/DeliveryTransport.integration.test.ts apps/server/src/j5/a2a/EnvelopeFormatter.test.ts apps/server/src/j5/a2a/claudeAgentSteers.test.ts apps/server/src/j5/a2a/claudeAgentSteers.integration.test.ts apps/server/src/j5/a2a/SilenceDetector.test.ts"now".vp run --filter t3 typecheckpassed. Targetedvp lintreported only the existing unusedlayerwarning inClaudeAdapterV2.ts. Formatting andgit diff --checkpassed.Not verified: no new live-provider or browser tests ran on this head. The Claude backlog branch is checked directly; the delivery harness still uses a Codex adapter. Cursor, other providers, desktop and mobile were not exercised. CI on this head is separate from these local checks.
Merge Danger
Door: two-way for future delivery behavior. A revert restores queued Claude peer messages; messages already consumed cannot be recalled.
Blast Radius: busy Claude agents receiving agent or server steers. A person's steer and upstream's capability flag retain their existing behavior.
The hold depends on the
@internalcommand_lifecyclecontract of the user's unpinnedclaudebinary. FORK.md case 84 records the assumptions for a fresh uuid user message and requires checking them at Claude Code upgrades and upstream advances. Folded commands share their consuming turn's result. Stop still has the existing steer/Stop race recorded under retired D5.After merge: check the four adapter hooks and lifecycle assumptions at upgrades. If upstream pingdotgg#21158 lands, check that its capability guard does not turn J5's Claude peer steers back into queued turns.
Live testing
Earlier PR evidence records live passes on
1b44c601c2for Haiku/Sonnet bursts, late messages, Stop, delegated completions and Codex behavior. Those reports are in J5's artifacts store undertest-reports/j5/claude-next-steer/.Jackson's review reports independent live tests on
b22516c20band a comparison with the hold disabled: late asks produced two turns and premature no-reply notices without the hold; the PR kept them in one turn. His Stop-with-an-ask tests received the existing stopped/cancelled notice. These are earlier-head reports, not a live pass on7263cd83df.This head removes the plain-message unread notice, keeps terminal cleanup, and integrates current main. Focused tests cover those changes; live testing was not repeated.
Upstream impact
apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts: FORK.md case 84, with the import, lifecycle observation, result hold, and priority/offer hooks. Cases 82 and 83 already belong to main; the inventory is 85 entries: 1–84 plus 15b.Checklist
FORK.md(case text and file-table row) in this PRdocs/j5/product/upstream.mdAGENTS.md)docs/j5/product/and user docs rewritten where this changes themOriginal implementation: Claude Opus 5.5 through Claude Code in J5 Code. Review revisions and current verification: GPT-6.1-Sol (High) through Codex in J5 Code.