Repository navigation
fix(native-chat): Claude, Pi and ACP chats are Working only while the agent holds the send - #30134
Conversation
… agent holds the send Each adapter reports the sends it still holds (Claude's dispatch waiters, Pi's sends until settlement, ACP's unsettled prompt and steers). A late settlement's write runs inside the per-send handover window, so a send reads held until its row lands, and a failed write reads as doubt at once. Removes the idle-release API and its callers.
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the
Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Priority: ➖ Normal Merge Risk: ⚪ Minimal · up to
|
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
ba891c54-00e8-4b19-90d9-37000b6e38a0
📒 Files selected for processing: 21
src/main/acp/acp-structured-acquire.tssrc/main/acp/acp-structured-session.tssrc/main/claude/claude-structured-session-adapter.tssrc/main/claude/claude-structured-session-close.tssrc/main/claude/claude-structured-session-exit-lifecycle.tssrc/main/claude/claude-structured-session-state.tssrc/main/codex/codex-structured-session-acquire.tssrc/main/codex/codex-structured-session-close.tssrc/main/codex/codex-structured-session-state.tssrc/main/native-chat/agent-session-wire/structured-agent-session-attach-orchestration.tssrc/main/native-chat/agent-session-wire/structured-agent-session-child-exit.tssrc/main/native-chat/agent-session-wire/structured-agent-session-claude-stop-exit-ends-record.test.tssrc/main/native-chat/agent-session-wire/structured-agent-session-event-recovery.tssrc/main/native-chat/agent-session-wire/structured-agent-session-event-sink.tssrc/main/native-chat/agent-session-wire/structured-agent-session-exit-observation.tssrc/main/native-chat/agent-session-wire/structured-agent-session-host-types.tssrc/main/native-chat/agent-session-wire/structured-agent-session-unexpected-exit.test.tssrc/main/native-chat/agent-session-wire/structured-agent-session-unfinished-work.tssrc/main/pi/rpc-session.tssrc/main/runtime/claude-structured-idle-releases-unknown.test.tssrc/main/runtime/structured-agent-session-codex-held-sends.test.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.
|
A chat could keep showing Working after its agent released a message because saving the delivery result failed. This change derives Working from the agent's live turn and held messages, so failed bookkeeping no longer keeps Stop visible or blocks queued work. Delivery-confirmation rules are unchanged. The full review completed in two rounds at Verified:
Coverage gaps: installed Pi is below the supported version; native Codex authentication through the isolated runtime is blocked; genuine kept reattach could not be exercised without the original successful ensure request. Old-doubt/final-write/reattach failure races are covered by deterministic host regressions and source review, not real-agent fault injection. Historical desktop/phone clients, SSH, Windows and Linux were not run. Deferred without a proven regression: Pi's silent unacknowledged-input case and a resume-marker choice involving an older uncertain send. Inherited observations on both main and branch: configured default tab absent, generated titles despite automatic titles being off, and a startup listener-count warning. No behavior difference was found in exercised cases beyond variable timing/title text. An early Stop observation before the tool started was excluded and repeated successfully after a running tool was confirmed. For Brennan's review Two places worth human attention:
|
…hile the agent holds the send (#30134)" (#30572) This reverts commit fc925c3 until the real fix for STA-11160 lands. With it, `orca orchestration worker-start --agent claude` shuts a new Claude chat worker down right after Claude acknowledges its task: between the echo and the accepted row the send reads as no longer held, settlement reports it unknown, and worker-start tears the session down. Conflicts with #29150 were formatting only; resolved to the pre-#30134 code.
…ity, held-send revert Sleep (#28445) closes a workspace's chats through the same abort a close gives a registered start, re-aborts a start registered while it waited for the lane, and judges its receipt once the start it aborted has settled, so only a newer start reads as later work. Each adapter's owned-acquisition check covers the child it owns between acquire and open. Main's Sleep cases from the deleted surface lifetime suite move to the workspace Sleep suite, plus one for a starting agent. Codex (#30406): the split open sends the chat's command env overrides when it opens the thread; the adapter test keeps that assertion on the open's request. Revert of #30134 (#30572): the event sink, exit observation, Pi held-send wrapper and adapter heldSends overrides go with it; Pi dispatch submits through its turns again and its idle report is wired back.
… shutting down Claude chat workers (#30577) * fix(native-chat): a Claude chat worker keeps running after Claude acknowledges its task Claude's adapter dropped an echoed send from the sends it holds before reporting the send's answer to the host, and emitting the echo's turn can publish at once. That publish read the still-pending send as held by nobody, so it read as "couldn't confirm": orchestration worker-start then closed the new Claude worker, and every other answer wait and client saw a one-frame doubt. A frame's settled sends now stay held until their answers are reported, when the host's handover window takes them over; a Stop's rejected sends are released and reported one at a time, as Pi and ACP already do. Tracked in STA-11160. * test(native-chat): assert the settled send's dispatch state through the send result * Reapply "fix(native-chat): Claude, Pi and ACP chats are Working only while the agent holds the send (#30134)" (#30572) This reverts commit 3ef5a46. * fix(native-chat): a Claude send stays held until its settlement reaches the host, on the reapplied held-sends read * fix(native-chat): a Claude send stays Working, not in doubt, while a Stop is still ending its CLI * test(pi): drop the removed idle-release dependency from the adapter fixture






ELI5
A Claude, Pi or ACP chat (Grok, OpenCode and other ACP agents) could keep saying "Working" after the agent had finished. This happened when Orca never got to save the agent's answer about a message. Now these chats show Working only while the agent is running a turn or still holding a message, the same rule Codex chats have followed since #29922.
What Changed
Before:
After:
Mechanism:
Each adapter reports
heldSends, reusing the host plumbing fix(native-chat): a Codex chat is Working only while Codex holds the send #29922 added for Codex.The host keeps counting a message as held while its late answer is being written: the answer's write runs inside the existing handover window. That window now counts per message, because a late answer can land while the same message is still being handed over (ACP accepts at turn open). Without the count, the message would briefly read as doubt.
Clients are republished to only when that write fails; a successful write already republishes.
Removed: the "release unanswered messages when the agent goes idle" mechanism and every caller of it (Claude's idle hook, Pi's
onIdle, the host delegate and its file). Owned state replaces it.Claude: a
completedlifecycle frame with nostartedbefore it now releases that message as doubt, never as received. The CLI finished with it without saying it ran.Reopening the same live agent keeps its original in-memory child record and event stream, so recovery still reaches that agent if a final save fails during the reopen.
Unexpected-exit reporting also uses the agent's execution ownership captured before teardown. A completed, idle conversation no longer gets a false "response was in progress" error because an earlier send remained uncertain. Actual interrupted responses still report the interruption.
What counts as "received" is unchanged for every agent. This PR changes ownership and uses that same evidence for interruption reporting.
Why
The old rule ("any unanswered message is the agent's work") ties Working to bookkeeping: one failed save keeps a chat busy. The structural fix is to ask the agent what it holds. The agent already tracks it, and a missing save can't fake it.
The common pattern marks a thread busy when a send starts and clears it on the agent's final turn event. That mechanism fails when that event never arrives; a send that times out can leave a thread active indefinitely. Deriving Working from the agent's existing execution state removes the extra idle-recovery write that could fail. Each adapter still has to release its own input when that input is settled. It also keeps older clients right, because they read Working from the published sends.
Differences from the common pattern:
Linked Issue
Part of the native-chat send lifecycle work, after #29922. Not a GitHub issue.
Visual Proof
Fresh main (
ce2d6083) versus final branch (5a0654ee) on a separate Mac, with the same repository, setup, settings and inputs. Whole-window screenshots below show the real host queue waiting before drain, a genuine active Claude process failure, and Grok after Stop. All exercised flows matched main. Queue creation used the host RPC because the shipped queue controls are disabled by capability on both versions; this does not claim coverage of shipped queue creation.Testing
The full PR workflow, including its aggregate gate, passed on
5a0654eedcff59585099cbff3ecb0345d953f244. Two targeted host files also passed all 38 tests remotely. The safe, name-filtered real-Claude subset passed 2 tests with 12 skipped; the full real-Claude suites were not run because their excluded cases disable hooks or require a signed-out home.Real Claude and ACP Grok QA covered normal send, rapid follow-up, Stop while a tool was running, and ending without Working. Claude additionally covered host queue waiting/drain, quiet process exit after a completed turn, and a real active-process failure showing the agent-specific error. Grok's native rapid follow-up replaces the active turn on both versions; it is separate from host queue coverage. A premature branch Stop observation was excluded and repeated successfully after the tool was confirmed running.
Blocked coverage: Pi is below the supported installed version; native Codex cannot authenticate through the isolated runtime route; a genuine kept reattach requires the original successful ensure request, which the UI flow did not retain. No credentials were copied, and nothing was installed or signed in. Deterministic host regressions cover old uncertain sends, final-write failure, and reattach overlapping failed event recovery; these races were not injected into the real-agent smoke run. SSH, historical desktop/phone binaries, Windows and Linux were reviewed in source but not exercised here.
AI Disclosure
Internal contribution; not applicable.
Review
Full review path: ownership, lifecycle, ordering and cross-version publication. Two adversarial rounds, architecture challenge, independent design checks and final source readiness review completed. Both proven high-priority findings were fixed: old uncertain sends falsely implying an interrupted response on idle exit, and kept reattach replacing recovery's child identity. No open proven P0/P1 findings remain. Test additions exceed production additions because the existing host fixture now pins the real final-write/reattach failure sequence.
Agent skill upstream boundary
Notes
No new saved field, wire operation, receipt rule, automatic resend, or version floor. Older clients continue to derive Working from existing published fields. The implementation is platform-neutral; remote contact loss remains unverifiable rather than proof of process exit.
Inherited QA observations on both versions: the configured default tab was absent, generated conversation titles changed despite automatic titles being off, and startup logged a listener-count warning. The setup marker ran successfully. These observations are reported for follow-up, not attributed to this change. All owned QA processes were stopped, ports released, and real config hashes/credential metadata were unchanged.
Checklist