Repository navigation
feat(acp): read claude background work per session on the shared runtime - #37593
Conversation
UX Review (Opus 5.5) — ⏭️ skippedRevision |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: the change adds a seam that answers Notes
[DESIGN-REVIEWED] d8221ed Description read[DESCRIPTION-READ] c7be590bbb1079616c04c960ea2224a56220418790cd398b6bf89d9d51d7c41b That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Nothing blocks. Every item carries the existing Notes
What this change shipsInventory (7 items) — 6 justifiedIntent: a claude chat on the shared runtime shows its own background-command-end and retry notices and Workflow agent cards, and none from other chats. ADDITION.
[FIRST-PRINCIPLES-REVIEWED] d8221ed Description read[DESCRIPTION-READ] 6645b7a188ab2316714f63889c4ce916472076f4048be36bdcc2cbd17b70861a That sha256 names the PR description this verdict read. Recompute it with |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
Code change approver recommendation: A person should decideWhy: the decider thinks the change is probably fine but estimates a 14% chance that this change introduces a defect, above the 12% limit for approving on its own. The PR does what it says. The shared runtime's reader passes a session's An automated recommendation, not a review: a maintainer still decides. It approves on its own only when the estimated chance of a defect is at most 12% and the change has at most 400 changed lines. Decider v3c (217fe607) · commit |
2d96bd9 to
c29c3c1
Compare
3bb1c5f to
41fc534
Compare
41fc534 to
02a16ea
Compare
02a16ea to
23b81b1
Compare
claude-agent-acp sends Claude Code's background-task and API-retry messages as _claude/sdkMessage notifications. The per-chat AcpClient reads them in its transport reader; on the shared runtime they went to the session's queue, where the handle read them as nothing, so a shared claude chat lost the background-command end and API-retry notices and the Workflow agent cards. - A new harness seam, take_session_frame, lets the runtime's reader hand a session's notification to that session's harness state. ClaudeHarness reads a _claude/sdkMessage into the session's own ClaudeSharedSession._raw_sdk (raw_sdk_tasks.take), on no queue. - AcpSessionHandle reads that state as _raw_sdk; its dispatch takes the dashboard's mark (begin_draw) and draws what waits before each frame (pending_events), as the client's dispatch does. The handle lists its announced children ahead of a Workflow's agents (_native_child_roster), refuses a resume of a Workflow agent's card and counts the agents that still run. - AcpSessionProvider exposes the handle's state, so the dashboard's mark, its kept-open cards and its lost-cards callback reach it. - Ending the session forgets its tasks (ClaudeHarness.end_session), which closes the cards the dashboard kept open. Tests run two chats on one runtime through the real reader loop: chat A's messages, sent while chat B's turn reads, are drawn by A's next dashboard turn and never by B's.
23b81b1 to
d8221ed
Compare
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
Approving. On head d8221ed the review checked these points. The runtime reader gives a session-tagged _claude/sdkMessage frame only to the harness state for that frame's own session, and raw_sdk_tasks.take checks sessionId a second time, so chat A's frames never reach chat B. Non-claude hosts answer False at the new seam and see no behaviour change. The moved rekey/reclaim code is identical to the original and still reads its patch seams at call time. The review ran the new test file and the related raw_sdk_tasks, runtime, handle and provider tests on the extracted head, and all passed. It also re-ran the body's stated mutations, and each one turned its named test red.
Done well: every isolation test drives two live chats through the real runtime reader loop and checks both sides.
Optional:
docs/system-specs/modules/claude-code-provider.mdstill callsclient_transport._read_message"the only stdout reader". The acp-client and providers specs do not listtake_session_framebesideholds_replayed_permission. A follow-up doc edit would fix both.- The 64-entry carry of an ended session's dashboard mark and seen cards in
ClaudeHarness.end_sessionis not described in the PR body, and no test covers its cap. A short note in "What changed" and a cap test would help. TheAcpSessionHandle._raw_sdksetter has no caller and could be dropped. - The Stack and Manual verification paragraphs still point at #37563, which closed without merging. Pointing them at the current top of the stack would keep them accurate.
Problem / Motivation
Goal: a claude chat on the shared ACP runtime shows the background-command end and API-retry notices and the Workflow agent cards that a chat on its own process shows, each only in its own chat.
#37512 asks claude-agent-acp for Claude Code's raw SDK messages about background tasks and API retries (
_claude/sdkMessage) and reads them inAcpClient's transport reader (acp.raw_sdk_tasks). The shared runtime's session envelope asks for the same messages, but its reader puts them on the session's queue, whereAcpSessionHandlereads them as nothing. Once claude chats share one process (#37540), such a chat would lose the row that says a background command ended, the warning that a request is being retried, and every Workflow agent card.Stack: this branch carries #37521 (ClaudeHarness) and #37586 (the claude surfaces on the shared handle) underneath one commit of its own. It merges after both and is rebased to one commit then; review only the top commit. #37540 and #37563 stack on top.
Why it matters
These rows are how a user learns that work they started in the background finished or that the model is being retried. With several chats on one adapter, each message must reach the chat whose session it names and no other.
Not a goal
subagent_update) on the shared runtime: their routing, cards and the per-child Stop are the next PR in the stack.Falseon every other host, andraw_sdk_taskschecksACP_BACKENDS_RAW_SDK_TASKSitself.What changed (motivation -> approach -> change)
The handle should read these messages as the per-chat client does: in the reader, into the session's own state, on no queue -> reuse
raw_sdk_tasksand give it a per-session state the runtime's reader can reach -> a harness seam and a handle property.HarnessAdapter.take_session_frame(state, msg)(defaultFalse). The runtime's reader asks it for each notification that names a session, with that session's harness state; a frame it takes is put on no queue, so a turn, a waiting request and an idle reader all read past it.ClaudeHarnesstakes a_claude/sdkMessageinto the session'sClaudeSharedSession._raw_sdk(raw_sdk_tasks.take), which already checks the session id. The reader resolves the seam once, as it does the harness's capability declaration, and acts only on an explicitTrue.AcpSessionHandle._raw_sdkreads that state (the handle's own empty one when the host keeps none)._dispatch_eventstakes the dashboard's mark (begin_draw) and draws what waits before each frame (pending_events), asclient_turn._dispatch_eventsdoes._native_child_rosterlists the handle's announced children ahead of a Workflow's agents.native_child_resume_refusalrefuses a Workflow agent's card andreport_native_childrencounts the agents still running, as on the client.AcpSessionProvider._raw_sdkexposes the handle's state, so the dashboard's mark (expect_dashboard_turn), its kept-open cards (live_card_ids) and its lost-cards callback (on_cards_lost) reach the session through the slot's client.AcpSessionProvider.rekeyandreclaimmove whole intoacp/session_provider_claim.py, bound on the class as before, sosession_provider.pystays under the 2,000-line cap with the new property. They readschedule_claimandschedule_session_token_publishoffacp.session_providerat call time, so a patch there still reaches them.ClaudeHarness.end_sessionforgets the session's tasks (raw_sdk_tasks.forget_tasks), which runs the lost-cards callback, as the client does when its session or process goes.Backwards compatibility
Compatible: the seam answers
Falseon every host but claude, and no claude chat takes the shared runtime until #37540's switch is on.Removes nothing: every change adds a reader or a field; no key, row or function is removed or renamed.
Tests
test/test_claude_shared_background.py: two claude chats on one runtime, frames written to the runtime's stdout and read by its real reader loop. Chat A's messages arrive while chat B's dashboard turn reads; then A's dashboard turn runs.With the reader's seam call switched off, or the dispatch's
begin_drawreplaced byFalse, the first four fail; withoutforget_tasksinend_session, the last fails.Proof: not provable -- other: feature PR, the mutations above are the check
Also run, serially:
test_session_handle_bindings,test_runtime_bindings,test_harness_parity,test_acp_runtime,test_claude_shared_runtime,test_claude_shared_surfaces,test_claude_raw_sdk_tasks*,test_security_posture, and every test file that touches the reader loop, the handle's dispatch or native children, or the harness seams (all pass).Manual verification
N/A for this PR alone: no chat reaches this path until #37540's switch is on. The pod check of #37563 (the top of the stack) runs a background command and a retry on a shared chat.
Related Issues
Follows #37512. Part of the claude chat sharing stack: #37521, #37586, this PR, then the Agent-tool children PR, #37540, #37563.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
Contributions are accepted under the project's Apache-2.0 license.