Skip to content

feat(acp): read turns claude starts on its own on the shared runtime - #37563

Closed
chenmingwei23 wants to merge 4 commits into
mainfrom
feat/claude-shared-agent-turns
Closed

chenmingwei23 wants to merge 4 commits into
mainfrom
feat/claude-shared-agent-turns

Conversation

@chenmingwei23

@chenmingwei23 chenmingwei23 commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: a claude chat that shares the ACP runtime still shows the replies Claude Code starts on its own, so claude chats can share with the default settings.

Claude Code can start a turn between a chat's messages: a run_in_background command finishes and it answers the task notification, or a background agent asks for a permission. The per-chat client sees that turn with its idle reader. A chat on the shared runtime has no such reader, so #37540 keeps a claude chat on its own process while agent.agent_started_turns is on, which is the default.

Stack: this branch carries #37540 (and the PRs under it) below one commit of its own. Review only the top commit; it merges with #37540.

Why it matters

With the default settings, turning on "Chats on the Claude harness" shares nothing today. Without a reader on the shared session, a reply Claude Code starts by itself would be dropped unseen, and a permission it asks for would be rejected.

Not a goal

  • No change for chats on their own process: the per-chat client's idle reader is unchanged.
  • No change for kiro-cli, KAS or codex sessions: only a host with per-session state (claude) gets the new queue.
  • No change to any default: the claude switch stays off.

What changed (motivation -> approach -> change)

The shared runtime already routes every frame of a session into that session's queue -> the queue can tell its handle when a frame starts a turn nobody is reading -> the chat reads that turn through the user turn's own loop.

  • AgentTurnQueue (acp/session_handle_agent_turns.py): the session queue create_session and load_session build when HarnessAdapter.per_session_state is set. Each frame it takes is shown to the handle. A frame that starts a turn (client_transport._starts_agent_turn) while no turn or awaited request reads marks the turn pending and schedules the chat's callback.
  • stream_unsolicited runs _run_turn(..., agent_started=True): nothing is built or sent, and _dispatch_events ends the turn on the usage_update that closes Claude Code's own cycle (_ends_agent_started_turn). Tool rows, permission cards and the terminal are the user turn's own.
  • Queued cycles. When any turn on such a session ends, the frames still queued are shown to the queue's hook again (_rearm_agent_turn), so a second cycle Claude Code began while a turn read is handed off as its own turn instead of waiting for the next prompt's drain.
  • Pre-turn drain. A prompt that starts while such a turn is pending keeps that turn's frames, from its first frame on, and reads them as its own, as a prompt on the per-chat client does. A prompt waits while an agent-started turn is being read.
  • Providers. AcpSessionProvider (members in acp/session_provider_agent_turns.py) answers watch_agent_turns, agent_turn_pending and stream_unsolicited (under its shared-turn claim), and puts the watch on a handle that replaces its own. acp_turns routes the three calls to it for a shared claude chat.
  • Placement. The agent_started_turns refusal from feat(acp): let claude dashboard chats share one ACP process, switch off by default #37540 is removed, with its metric reason and the Claude row's condition text.
  • Scope. Sharing follows feat(acp): share one KAS process per session tree (Ultra Mode and Bot) under runtime sharing preview #37466's session-tree rule: the turns read here belong to sessions of one tree on one process, never to two unrelated chats.

Backwards compatibility

Compatible: only claude sessions on the shared runtime get the new queue, and those only exist with the off-by-default switch on.

Removes nothing: the refusal and its reason were added by #37540, which merges with this PR.

Tests

  • test/test_claude_shared_agent_turns.py (new): a turn the agent starts between prompts calls the chat back (scheduled, not from the reader) and is read whole with nothing written; a prompt that starts first reads the pending frames as its own; a second cycle queued behind the first is read as its own turn (fails with the re-arm disabled); a frame during a turn starts nothing; a host without per-session state keeps a plain queue. With _take_agent_turn_frames disabled the first two fail.
  • test/test_chat_runtime_sharing_cleanup.py: a claude chat shares whatever agent_started_turns says.
  • test/test_session_handle_bindings.py: the handle's inventory names the new members and owner.
  • Local: these files plus the agent-started-turn, pre-turn-drain, provider, binding and runtime tests, serially; isort, flake8, black (pinned).

Proof: not provable -- other: new capability for shared claude chats, not a fix

Manual verification

Pod run with real claude-agent-acp and Claude Code, default settings (agent.agent_started_turns on, preview and Claude switch on), two dashboard chats in one project:

  • Chat A asked Claude to run sleep 20 && echo <token> with run_in_background and answered STARTED; its turn ended at 12.9 s.
  • Chat B, on the same process, answered at 16.0 s.
  • At 36 s chat A showed a new assistant row carrying the command's output, with meta.origin.kind == "agent": the reply Claude Code started on its own after the command finished, with no message sent.
  • Gateway log: chat A spawned, chat B joined the same runtime.

That run predates #37466's session-tree key; on today's main two unrelated chats take a process each. Re-run inside one tree on #37615 (which carries this PR): a kirocrew-conductor chat opened two worker sessions that joined its process, worker 1 ran sleep 8 && echo <token> in the background, answered STARTED, and then posted the command's output in a turn it started itself (screenshot below).

Screenshots / video

Pending: the pod recording is added here once uploaded.

Related Issues

Part of #5033

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...) -- not yet: the branch carries feat(acp): let claude dashboard chats share one ACP process, switch off by default #37540 and the PRs under it until they merge
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

Contribution License Agreement

Contributed under the project's Apache-2.0 license.

Worker 1: background command started, then its output in a turn Claude started itself

@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Nov 15, 2026
@github-actions

github-actions Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ✅ PASS (a BLOCK with no Trigger and no Outcome does not block)

UX-level review of a8500bd480fae44861d506d205b73e316489df73 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

UX-Verdict: PASS

cannot evaluate: missing the new "Chats using Claude Code" switch in Settings. The only screenshot shows a chat transcript, not the settings row this diff adds.

Evidence gaps

  • "Chats using Claude Code" switch (ChatRuntimeSharingHarnessRows.tsx, new claude entry with defaultOn: false). Its description is "On: new chats on this harness share one background program and use less memory. Off: each chat runs its own program." No supplied screenshot shows it (only shot-01.png, a chat view), so neither its label nor where it sits next to the KAS and Codex rows could be judged. To close: a screenshot of the Feature previews chat-sharing rows with the Claude switch visible, in both its off and on states.

Notes

  • The blind reader read the agent-started reply in shot-01.png as an ordinary reply ("someone asked the assistant to run a command and it replied with the result"). That is the intended effect. The description still says the recording is "Pending"; attaching it would show the reply arriving with no message sent.

[UX-REVIEWED] a8500bd

Description read

[DESCRIPTION-READ] a2727c6a806c11695e9aec42a5f417675fda80e09bcb70dc444a533797e506c2

That sha256 names everything this verdict read: the PR description, plus the 4 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 .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of a8500bd480fae44861d506d205b73e316489df73 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

No design-level concerns. The agent-started turn runs through the user turn's existing _run_turn loop and dispatch path, and only a host with per_session_state gets the new queue, so other harnesses keep a plain queue.

Notes

  • If a reader leaves stream_unsolicited early, the turn is not marked abandoned (not agent_started in the CancelledError branch). The rest of Claude's cycle then lands in the next prompt's stale drain rather than being closed. Say whether dropping that tail is intended, or pin it with a test.
  • The screenshot shows only the chat reply. Add the promised pod recording, or a capture of the Claude row's changed condition text in ChatRuntimeSharingHarnessRows.tsx, so the settings surface has evidence of its own.

[DESIGN-REVIEWED] a8500bd

Description read

[DESCRIPTION-READ] 0b72bd2f62f00a78d694a580be87995b7a585c333916a6418241b2969266a60f

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 .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of a8500bd480fae44861d506d205b73e316489df73 — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

First-Principles-Verdict: PASS

Nothing blocks. Each item answers the dropped-turn harm the description names, and every new member has a counted consumer. The claude sharing switch stays off by default.

Notes

  • Item 7 — duplicate of acp/client_transport.py _AGENT_STARTED_REQUEST_ID: AGENT_STARTED_REQUEST_ID = _AGENT_STARTED_REQUEST_ID gives the same constant a second name. Its only consumer is session_handle_turn.py. Subtraction: delete the alias and import _AGENT_STARTED_REQUEST_ID from client_transport in session_handle_turn.py, as session_handle_agent_turns.py already does.

What this change ships

Inventory (8 items) — 7 justified

Intent: a claude chat sharing one ACP process still shows the replies and permission asks Claude Code starts on its own between messages. ADDITION.

  1. A shared claude chat shows a reply Claude Code started by itself, with no message sent — justified
  2. A permission asked by a background agent between turns reaches the chat instead of being rejected — justified
  3. A second cycle Claude Code began during a turn is shown as its own turn — justified
  4. A prompt sent while such a turn waits reads that turn's frames instead of dropping them — justified
  5. A prompt waits while an agent-started turn is being read — justified
  6. A replaced session handle (a fresh conversation, an MCP re-send) keeps the chat's watch — justified
  7. The constant gets a second name, AGENT_STARTED_REQUEST_ID — duplicate of client_transport._AGENT_STARTED_REQUEST_ID
  8. Claude chats share even with agent.agent_started_turns on (the refusal from feat(acp): let claude dashboard chats share one ACP process, switch off by default #37540 is removed) — justified

[FIRST-PRINCIPLES-REVIEWED] a8500bd

Description read

[DESCRIPTION-READ] ec8a10200617d72a2f9f95b65891e42498c0b888430a590ce1e34ee5af14f696

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — 🔴 changes requested (blocking)

GPT 6.1 found at least one blocking issue that must be resolved before merging a8500bd480fae44861d506d205b73e316489df73. Adjudication upheld 1 of 1 blocking finding(s); those must be resolved before merging.

This comment is updated in place on each push.

BLOCKING -- src/kiro_crew/acp/session_handle_dispatch.py:1071 -- Late prompt responses cannot close an agent-started turn

if req_id == AGENT_STARTED_REQUEST_ID and _ends_agent_started_turn(msg):
Trigger: A shared Claude chat hits its dashboard deadline without a cancellation acknowledgement. Late reply text opens stream_unsolicited; abandonment cleanup exhausts its grace before the prompt response arrives. The runtime routes that response into the session queue, but _dispatch_events discards it in the earlier stray-response branch.
Outcome: The recovered reply remains running after Claude finishes, and subsequent messages wait behind it until watchdog recovery or another timeout.
Anchor: defect
Fix: Handle closing responses during agent-started dispatch before discarding stray responses, while preserving responses owed to active request waiters.
Sites: none

[BLOCK-MERGE] a8500bd
[GPT-REVIEWED] a8500bd

Adjudication (Opus 5.5) — is blocking on each finding proportionate?

F1 — UPHOLD. Harm rung: MEDIUM. The bug follows from the code as written:

  • session_handle_agent_turns.py:85-93 (_note_queued_frame) does not check _abandoned_prompt_id. So once the prompt is abandoned (session_handle_turn.py:1101), a late frame from that prompt can still open an agent-started turn.
  • That turn's _close_abandoned_turn (session_handle_turn.py:1170-1182) clears the id once the grace period runs out.
  • When the prompt's response finally arrives, nothing is waiting for it, so the stray branch at session_handle_dispatch.py:865-886 drops it before the close check at :1071 can see it. That check sits inside the update branch anyway.

The result: a turn that never ends and blocks the next prompt (session_handle_turn.py:409-412) until the stale/watchdog recovery fires. It can be recovered from, but it is slow and the chat sits on a common surface. The fix is cheap: one branch in the stray-response path that closes an agent-started turn, which is the behaviour the docstring at client_transport.py:185-190 already promises.

[ADJUDICATION] a8500bd480fae44861d506d205b73e316489df73 total=1 uphold=1 downgrade=0
UPHOLD F1 src/kiro_crew/acp/session_handle_dispatch.py:1071 reason=harm-warrants-remedy
[GPT-ADJUDICATED] a8500bd480fae44861d506d205b73e316489df73

False positive or not applicable? A repository writer can comment:
/ai-review override gpt a8500bd480fae44861d506d205b73e316489df73 false-positive: <reason, 20 to 500 characters>

@github-actions

github-actions Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — 🔴 changes requested (blocking)

Reviewed a8500bd480fae44861d506d205b73e316489df73 — this comment is updated in place on each push.

Blocks on one defect: on the shared runtime, a claude chat's session health counts every Agent-tool child the session has ever had as a resident native child, including finished ones.

BLOCKING — src/kiro_crew/acp/session_handle_native_children.py:554
count = len(self._native_child_sids) + self._native_child_overflow + len(live_card_ids(self))
Trigger: a claude chat on the shared runtime runs Agent-tool children in earlier turns, and they finish. _run_turn now skips self._native_child_sids.clear() when _claude_children_declared() is true, and nothing else removes ids from that set. dashboard/session_health.py:435 then calls handle.report_native_children(_UNCHARGED_MIRROR).
Outcome: uncharged["native_children"] and snap.native_children show every child the session has ever had (up to NATIVE_CHILD_ROSTER_CAP) as resident, for the rest of the session. The per-chat client reports only this turn's children (len(self._native_child_turn), client_native_children.py:582), so the same chat shows different health numbers depending on which runtime it is on.
Anchor: defect
Fix: for a claude-declared handle, count len(self._native_child_turn) (the per-chat client's rule) instead of len(self._native_child_sids).

[BLOCK-MERGE] a8500bd
[OPUS-REVIEWED] a8500bd

Verdict parsed from the review's SHA-scoped output markers for commit a8500bd480fae44861d506d205b73e316489df73.

False positive or not applicable? A repository writer can comment:
/ai-review override fable a8500bd480fae44861d506d205b73e316489df73 false-positive: <reason, 20 to 500 characters>

@chenmingwei23
chenmingwei23 force-pushed the feat/claude-shared-agent-turns branch from 38a572e to 04dbee4 Compare November 15, 2026 09:05
@chenmingwei23
chenmingwei23 marked this pull request as ready for review November 15, 2026 09:05
@KiroCrewCaptain

KiroCrewCaptain commented Nov 15, 2026 •

Copy link
Copy Markdown
Collaborator

Code change approver recommendation: A person should decide

Why: the decider raised 1 possible problem and estimates a 72% chance that this change introduces a defect; a person should check it.

Confirmed in code: on the shared runtime, late output from a cut prompt is handed off as an agent-started turn (_note_queued_frame ignores _abandoned_prompt_id). That turn can only end on an autonomous-origin usage_update, never on the prompt's response, so it hangs until the stale watchdog fires and blocks the next prompt. The per-chat client handles this case and has a test for it; the shared path does neither. Requesting changes: either skip the hand-off while a prompt is abandoned, or end an id -1 turn on an unclaimed response, and add a shared-runtime test.

Things to check (possible problems the decider raised; at this confidence many turn out to be fine):

  • On a shared claude chat, late output from a prompt whose consumer left becomes an agent-started turn that never ends on a response. It reads until the stale watchdog (about 600 s), ends as STALE_RECOVER (session reset), and the user's next prompt blocks behind it via the _agent_turn_reading gate. Th (src/⁠kiro_crew/acp/session_handle_agent_turns.py, medium)

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 9576ffc3f2 · 3382 changed lines. If this recommendation is wrong, reply here: replies are how the approver is evaluated.

@chenmingwei23
chenmingwei23 force-pushed the feat/claude-shared-agent-turns branch from 04dbee4 to 8cb317e Compare November 15, 2026 09:48
@github-actions github-actions Bot added the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Nov 15, 2026
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Nov 15, 2026
@chenmingwei23
chenmingwei23 force-pushed the feat/claude-shared-agent-turns branch from 8cb317e to 5185fdd Compare November 15, 2026 12:01
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Nov 15, 2026
@chenmingwei23
chenmingwei23 force-pushed the feat/claude-shared-agent-turns branch from 5185fdd to f5b590f Compare November 15, 2026 12:07
@chenmingwei23
chenmingwei23 force-pushed the feat/claude-shared-agent-turns branch from f5b590f to 7312a13 Compare November 15, 2026 13:04
@github-actions github-actions Bot removed the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Nov 15, 2026
@chenmingwei23
chenmingwei23 force-pushed the feat/claude-shared-agent-turns branch from 7312a13 to 3ecc8aa Compare November 15, 2026 13:16
@github-actions github-actions Bot removed the readiness: checking Automated validation is still running label Nov 15, 2026
@github-actions github-actions Bot added the readiness: action required A blocking check or review needs attention label Nov 15, 2026
@chenmingwei23
chenmingwei23 force-pushed the feat/claude-shared-agent-turns branch from 3ecc8aa to d1f2e40 Compare November 15, 2026 13:56
@github-actions github-actions Bot added readiness: checking Automated validation is still running merge conflict Branch has merge conflicts with its base — author must resolve before merge and removed readiness: action required A blocking check or review needs attention labels Nov 15, 2026
@chenmingwei23
chenmingwei23 force-pushed the feat/claude-shared-agent-turns branch from d1f2e40 to 44ec20f Compare November 15, 2026 14:04
@github-actions github-actions Bot removed the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Nov 15, 2026
@chenmingwei23
chenmingwei23 force-pushed the feat/claude-shared-agent-turns branch 2 times, most recently from 1cd0d2e to 9576ffc Compare November 15, 2026 15:02
@github-actions github-actions Bot added the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Nov 15, 2026
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.
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Nov 15, 2026
@chenmingwei23
chenmingwei23 force-pushed the feat/claude-shared-agent-turns branch from 9576ffc to 1c40e8c Compare November 15, 2026 16:44
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Nov 15, 2026
… runtime

claude-agent-acp announces an Agent-tool child on its parent's session
(subagent_update, keyed on the update's sessionId) and sends the child's
work under the child's own id. The shared runtime learned only
codex-acp's subagent_spawned, so a shared claude chat's child frames
had no route: its updates were dropped and its permission requests
answered fail-closed, and the chat drew no card for it.

- The runtime's reader learns a subagent_update's child as the
  announcing session's, so the child's frames reach that session.
- AcpSessionHandle reads claude's child form with the client's own
  functions and row shape (session_handle_claude_children): the card
  roster, the delegated prompt, a background child listed again, a
  child's notice as card text, and a parent-session call stamped with
  a child's Agent call. The child's other frames keep the handle's
  child arm, and its text goes through its own redactor.
- A child granted capabilities.cancel can be stopped alone:
  cancel_native_child sends session/cancel naming it on the shared
  connection, and the requests each child asks are kept for that Stop
  (native_child_requests), both reachable through the provider.

Tests run two chats on one runtime through the real reader loop.
…ff by default

A dashboard chat on the claude harness joins the shared ACP runtime when the
ACP runtime sharing preview and its own "Chats on the Claude harness" switch
are both on. Every other claude session (channels, members, background work,
sage) keeps its own AcpClient process exactly as before.

- claude joins ACP_BACKENDS_CHAT_RUNTIME_SHARING and the per-harness switch
  table (default off). ACP_BACKENDS_SHARED_RUNTIME_ONLY_FOR_CHATS marks it as
  served by the runtime only for a chat that got a shared placement.
- The provider asks for the placement before choosing its arm, and the runtime
  start uses that placement; a refused placement keeps the per-chat client.
- Each session's identity (session key, stub token) rides its own
  _meta.claudeCode.options.env instead of the founder's process env.
- The chat's permission mode, side read-only and memory choices travel to
  ClaudeHarness.prepare_session with each session start.
- The account era of a claude process is a digest of Claude Code's own
  credentials file, so a sign-in to another account founds a new process.
- A resumed session sends its own envelope on session/load, as session/new
  does, and a resume cancelled after it registered closes its session.
- An organization-policy model substitution on session/new is adopted and
  the start re-sent once, as the per-chat client does.
- The spec's toolsSettings shell and write allowlists, which claude never
  reads, are read at session setup, carried by the envelope's ask rules and
  stamped on the shared session's permission requests, as the per-chat
  client does.
- A substitution retry whose re-seed finds Crew's settings file replaced is
  refused instead of re-sending the array authorized under it, and a load
  abandoned mid-request is closed once the request settles.
- A start cancelled or refused inside the starting-mode pin closes its
  session, and a refusal on the shared connection reads as a failed pin; the
  envelope's Connection asks read this session's own array.
A claude chat on the shared runtime now shows a reply Claude Code starts by
itself between the chat's messages (a background command finishing, a
background agent asking for a permission), as the per-chat client does, so
claude chats share one process with the default settings.

- The session queue of a host with per-session state (claude) is an
  AgentTurnQueue: each frame it takes is shown to the handle, and a frame that
  starts a turn while no turn or request reads calls the chat back.
- stream_unsolicited reads that turn through the user turn's own loop
  (_run_turn with agent_started=True): nothing is sent, and the turn ends on
  the usage_update that closes Claude Code's own cycle.
- A prompt that starts first keeps the pending turn's frames in its pre-turn
  drain and reads them as its own; a prompt waits while an agent-started turn
  is being read.
- AcpSessionProvider and AcpProvider answer watch_agent_turns,
  agent_turn_pending and stream_unsolicited for a shared chat, and the watch
  follows a handle swap.
- The agent_started_turns refusal in resolve_chat_share is removed.
@chenmingwei23
chenmingwei23 force-pushed the feat/claude-shared-agent-turns branch from 1c40e8c to a8500bd Compare November 15, 2026 16:58
@github-actions github-actions Bot removed the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Nov 15, 2026
@chenmingwei23

Copy link
Copy Markdown
Contributor Author

已并入 #37540 (merged into #37540 at 39c59f0; the tree is byte-identical to this branch's restacked head). Branch kept.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants