Repository navigation
fix(acp): apply a requested claude auto mode with session/set_mode - #30226
shubhamkurkure wants to merge 1 commit into
Conversation
0537a74 to
52fe4e3
Compare
|
This should merge after #30308 (the fix for #29909), which is now open. This PR lets a session that asked for The two PRs touch the same docstring field list in |
|
#30308 now keeps today's behaviour by default, at a maintainer's request: its broader starting-mode pin runs only when After this PR, a session that ran in The two PRs still conflict as text in |
52fe4e3 to
ffeb995
Compare
ffeb995 to
e0b74b9
Compare
e0b74b9 to
708d8ef
Compare
e4d7bf2 to
a9bade0
Compare
UX Review (Opus 5.5, fork) — ⏭️ skippedRevision |
Design Review (Opus 5.5, fork) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: the change applies an operator opt-in that the docs already promised, through the one channel the SDK does not filter. If Notes
[DESIGN-REVIEWED] a9bade0 Description read[DESCRIPTION-READ] d2a37fbbac999cacbf1e821ca3400e6caee55b12de8e6d62fbc6cd5613dbe908 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, fork) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Nothing blocks. This fix makes the existing opt-in What this change shipsInventory (7 items) — 7 justifiedIntent: an operator who sets
[FIRST-PRINCIPLES-REVIEWED] a9bade0 Description read[DESCRIPTION-READ] abb3f7b9c9ae567fab9e24af82566ad872d779bdcb3e18bdd1b9e04f8b3877c2 That sha256 names the PR description this verdict read. Recompute it with |
Opus 5.5 Review (fork) — ✅ no blocking findingsReviewed |
GPT 6.1 Review (fork) — ✅ no blocking findingsReviewed Review detailsNo findings. |
|
Heads-up from the review of #33847, which merged at 8cc73e9. That PR makes Smallest fix: return early from |
a9bade0 to
db89f3f
Compare
|
Thanks for the heads-up. This is fixed in db89f3f, which is rebased onto main and so includes #33847.
The new test |
|
@bolichen97 @iamwhatever could you take a look at this PR when you have time? It fixes #30169: with The branch merges cleanly with current main. |
Code change approver recommendation: A person should decideWhy: the decider thinks the change is probably fine but estimates a 20% chance that this change introduces a defect, above the 12% limit for approving on its own. The PR makes the documented KIROCREW_CC_PERMISSION_MODE=auto opt-in take effect: after the pin and startup model, the session is moved to 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 |
db89f3f to
fb9838d
Compare
fb9838d to
5379cd3
Compare
5379cd3 to
d256382
Compare
d256382 to
9116905
Compare
9116905 to
6178cb7
Compare
A claude session that asks for auto (KIROCREW_CC_PERMISSION_MODE=auto)
started in default. Crew writes the request as permissions.defaultMode
in the session's settings.local.json, and the Claude Agent SDK drops an
auto default mode from that tier, so the opt-in did nothing.
After session/new and a successful session/load, once the mode pin and
the startup model selection have run, _apply_claude_requested_mode
sends session/set_mode auto when the session requested auto, is in
default and lists auto as available. It goes on after the model so
that auto is asked for on the model the session runs: a switch to a
model without Auto mode support moves an auto session to acceptEdits.
Side Chat and zero-tool sessions are never moved. Any other mode is
kept with one warning; for acceptEdits or bypassPermissions, which
approve on their own, the warning says so and names
KIROCREW_CC_PIN_INHERITED_MODE=1 (which moves a session carrying Crew's
tools out of bypassPermissions first), and a mode_change:claude_auto
SEL record has outcome kept_inherited_mode. A set_mode refused with an error answer, or an adapter that
does not offer auto, logs one warning and the session keeps default.
Only a JSON-RPC error frame (an AcpError carrying its code) is a
refusal: a child that exits, a broken pipe or a shutdown while
set_mode auto is sent or awaited propagates and ends the start, as it
does during the startup model, so the caller retries or restarts it.
A set_mode auto left unanswered is moved back to default with
session/set_mode, since the adapter may still apply it after the wait
gave up, and the session is stopped if that move fails; the request is
marked withdrawn, so an auto the adapter applies after the undo is
moved back before the first prompt as well. A cancel once
set_mode auto is on the wire and before the start drain has read its
mode reports is the same unknown answer, and it skips ensure_ready's
handler, so the start ends the process (as for a cancelled member
confirm) and the next prompt starts a new one. The guard is entered
only on a requested-auto claude start. A fresh
conversation on the live adapter (ClaudeAcpClient.new_conversation) does the
same after its own pin, so a requested auto survives that reset too.
On a model without Auto mode support the adapter answers set_mode auto
with {} but reports acceptEdits, where an edit runs without asking
Crew's gate. Crew's own request put the session there, so it is moved
back to default with session/set_mode before the first prompt, and the
session is stopped if that move fails, through the pin's own move
(_set_claude_pinned_mode_or_stop, shared with the pin, and also used
for the unanswered set_mode above).
A session that left a foreign settings.local.json out (the exclusion
path, which since kirodotdev#33847 keeps Crew's tools for a requested auto and
pins it to default with a chat notice) is never moved either:
_apply_claude_requested_mode returns early when
_claude_session_excludes_local() is true, so that notice stays true
and the session has no classifier approvals that the SEL audit skips.
A session whose foreign file could not be left out (a project
settings.json that sets hooks or sandbox or cannot be examined, or an
adapter below the floor) loads that file, so Crew does not govern its
permissions (_permission_surface_governed is false) and withholds its
MCP tools. It is not moved to auto either: one warning, the same chat
notice, no record, and it keeps default.
A requested auto is applied at session start only. A live model switch
Crew sends (set_model: the picker, /model, a warm-pool claim)
is made while the session asks: a requested-auto session in auto,
acceptEdits or bypassPermissions is moved to default first, and stopped
with no switch sent if that move fails. It then stays in default for the
rest of that session, with one warning, so no mode report can follow the
switch and a turn the agent starts on its own, which does not pass
through ensure_ready, never runs in acceptEdits after it.
A requested-auto session's mode is followed for the whole session.
_track_claude_starting_mode records the mode the pin or the response
names, and from then on _read_message hands every frame off the wire to
_note_claude_mode_report, which keeps the confirmed mode current from
current_mode_update and mode config_option_update reports. Adapter-sourced
mode ids longer than harness_notices.MODE_ID_MAX are ignored in both report
shapes and in the start response, so none is retained or copied into SEL.
Reports read during startup are restored before the first prompt: one naming
acceptEdits or bypassPermissions, which Crew never asks for (an answer
to set_mode auto reported after the answer, or the startup model's
fallback), marks the session, which is moved back to default at the
end of its start, and stopped if that move fails. A start settles at
its last step (the Claude-owned start drain, or the end of a fresh
conversation; _claude_mode_settling), so the report that answers the
start's own set_mode auto is the start's. Once startup has settled, a
report of auto, acceptEdits or bypassPermissions stops the captured
process tree from the existing reader before an agent-started turn can
dispatch a tool. The reader awaits that stop through asyncio.shield:
the stop's own kill cancels the idle reader that awaits it, and the
stop goes on; no second stdout reader starts. Each start clears the
recorded mode first.
On the claude harness the start drain reads nothing off the wire
(kirodotdev#37154), except on the start of a session that requested auto
(session/new, session/load or a fresh conversation): its drain keeps
the idle window, so a mode report that follows an answer the start
read (to set_mode auto, to its move back after a timeout, or to the
startup model) is still read and undone before the first prompt.
The enterprise approval_modes ceiling gates the request. In auto
Claude's classifier approves a call without asking anyone, which is
what a session Trust grants, so Crew asks
approval_mode_policy.session_mode_permitted("trust") before sending
set_mode auto. While a ceiling that narrows the scope is being
installed it answers deny as a placeholder, which Crew does not commit:
it waits for the final answer off the loop (ensure_resolved, bounded),
at the start and before a prompt, and an install that outlasts the
wait keeps or moves the session to default with a warning and no
record. Denied, no set_mode auto is sent: one warning, an
SEL mode_change:claude_auto record with outcome
approval_mode_denied_by_policy, and the session keeps default. An
applied auto writes the same record with outcome enabled. Records
written from the client's event loop go through asyncio.to_thread, so
a first SEL use does no file I/O on that loop; the deny hook writes its
record on the thread that installs the ceiling. A ceiling
that denies trust while a requested-auto session is in auto,
acceptEdits or bypassPermissions stops that process: one Claude-owned
approval_mode_policy deny hook, over a weak registry of requested-auto
clients and their event loops, records approval_mode_denied_by_policy
on the installing thread and captures the current process. On the
client's loop it settles every unsettled observed call and builds its
interrupted_by_policy SEL row without awaiting, stops that exact
process, and only then writes the rows. Every interrupted row is
claude_unattributed with reason claude_unasked_call, while
permission_mode keeps the confirmed mode, because the following
session/request_permission may still be unread. Nothing awaits between the
capture check and the stop, so a delayed callback leaves a replacement
alone. A closed loop or an enqueue RuntimeError uses the same
settle-stop-write order synchronously on the installing thread and kills
the captured process tree, sweeping children that left its process group.
A stop that is cancelled or fails uses the tree fallback too. The hook sends no set_mode and reads no stdout. A deny
that lands while a start or prompt waits for the ceiling's final
answer is left to that stop: the restore re-reads the mark after each
wait and sends no set_mode and no second record. If the hook lands while a
prompt's ensure_ready restore is waiting for a mode answer, that prompt
fails once with the process-exit error. The next prompt starts a fresh
session, whose start reads the denying ceiling and keeps default. The
ceiling is also read again at the end of every start and in ensure_ready
before every prompt, so a resumed transcript in such a mode is moved to
default first, and stopped if that move fails; the denial is recorded
even when a mode report had marked the session for that move.
A session that needs the session options and is refused below the
settingSources floor, before its spawn or at its handshake, never
reaches the request: no set_mode, no ceiling read and no record.
The SEL row for a completed unasked call of a requested-auto session now
names what approved it. In a confirmed auto the row keeps decided_by
claude_classifier. In bypassPermissions, and for a file edit (ACP kind
edit, delete or move) in acceptEdits, decided_by is
claude_permission_mode; any other call in acceptEdits, which that mode
does not approve, gets claude_unattributed. So does every unasked call
of a session confirmed in an asking mode (default, plan, dontAsk, or
none): it keeps its row, as on main, but names no approver. Every row
carries permission_mode. If the ceiling stop lands before a terminal
update, every unsettled observed call gets outcome and tool_status
interrupted_by_policy, decided_by claude_unattributed and reason
claude_unasked_call while retaining permission_mode. Ids are settled
before the stop, so a racing terminal update cannot write a duplicate.
Ending the process cannot classify a frame still unread in the pipe: an already observed call may be
recorded as interrupted_by_policy, while a call not yet observed gets
no row.
The code is ClaudeAcpClient's: its requested-mode fields are set in
ClaudeAcpClient.__init__, its members live in a new claude owner,
acp/client_claude_mode.py (listed in _CLIENT_OWNERS after
client_claude_turn), and the pin's return value and
_set_claude_pinned_mode_or_stop, which moves through _claude_set_mode
and stops through _claude_stop_session, stay in client_claude_session.
The shared Kiro path is unchanged (harness-parity H13):
client_start.py, client_transport.py and client_model_selection.py
equal main. ClaudeAcpClient overrides seams AcpClient already has, in
acp/client_claude_mode_seams.py: _initialize_params forgets the last
session's mode before session/load or session/new; main's
_pin_starting_mode hook records the mode and keeps the response;
_drain_notifications, which the start reaches after the startup model,
applies the request, keeps the idle window, undoes a late report and
ends the session on a cancel; _read_message follows mode reports;
_push_model_config_option leaves an approving mode before a live
switch, only on a session that follows its requested mode (any other
claude session switches in the mode it is in, as on main); and
ensure_ready restores the asking mode before a prompt. Those restores
never run at the same time on one client: the cold-start drain runs
inside ensure_ready, a fresh-conversation reset runs only on an idle
pooled client, and warm ensure_ready owns stdout through the idle-reader
wrapper.
AcpClient gains only _unasked_call_attribution, whose body keeps the row
an auto session wrote before this change.
With KIROCREW_CC_PIN_INHERITED_MODE on, the pin moves a requested-auto
session that starts in bypassPermissions, or reports no mode, to
default. The response still names the starting mode, so
_pin_claude_starting_mode now returns the mode it set, which
_track_claude_starting_mode records, and _apply_claude_requested_mode
moves the session on to auto when availableModes offers it. Off the
exclusion path the pin keeps an auto the session requested, so neither
step undoes the other. A session
that requested nothing is unchanged: with the setting off it keeps the
mode it started in, and with it on the pin moves an approving mode to
default.
Fix 5 bounds adapter mode ids at MODE_ID_MAX, attributes every interrupted
row to claude_unattributed, and gives both synchronous policy-stop fallbacks
the live-loop settle-stop-write order. Focused regressions cover both report
shapes, the start response, interrupted attribution, closed loops, enqueue
failure and a terminal update after settlement.
Fix 6 identity-checks the closed-loop POSIX stop before and after child
discovery, then signals only the isolated group returned by
process_identity.isolated_group_of. If the captured start id is unknown
or no longer matches, it does not scan or signal the root and sweeps
only previously recorded children through their own guards. The Windows
path keeps its pinned tree kill when a start id exists; without one it
kills only the captured process object.
It also shares the requested-auto callable-surface predicate between
mode tracking and mode application. Side Chat and zero-tool sessions
are not watched or put in the live requested-auto registry, so a trust
deny or approving mode report cannot stop a text-only turn.
Fix 7 moves the live-loop policy stop's synchronous tree-kill fallback
off the event loop: when _claude_stop_session raises or is cancelled,
both arms await it on subprocess_executor() under asyncio.shield, as
_kill_process does, so a Windows tree drain or a macOS ps/pgrep spawn
cannot stall the gateway loop. The closed-loop path on the installing
thread still calls it inline. The synchronous trust-deny fallback test
now pins IS_WINDOWS, so its POSIX group-kill assertion holds on Windows
shards.
6178cb7 to
ef16ab8
Compare
Problem / Motivation
Goal: A Claude Code session that asks for
automode (KIROCREW_CC_PERMISSION_MODE=auto) really runs inauto, or Kiro Crew logs that it could not.With
agent.acp_backend = claudeand theautoopt-in, the session starts indefault, so Claude asks before every tool call as if the setting were not there. Crew writes the request as{"permissions": {"defaultMode": "auto"}}into<work_dir>/.claude/settings.local.json, thelocalsettings tier. The Claude Agent SDK removes anautoorbypassPermissionsdefault mode that comes from theprojectorlocaltier (filterEscalatingDefaultMode, called by the adapter'sSettingsManager) and does not fall back, sosession/newreportsdefault. Nothing warns, and the docs say every session is seeded withauto.Why it matters
The opt-in is the only way an operator chooses Claude's own classifier for a Crew session, and today it silently does nothing on claude-agent-acp 0.97.0 and 0.100.0. An operator who turned it on still gets a permission prompt for every call and has no signal why. The SEL audit of unasked calls (
_maybe_audit_unasked_tool_call) is built forautosessions, and on main it credits Claude's classifier with calls thatdefaultallowed.Not a goal
permissions.defaultModewrite. It is kept to keep this diff small; other open PRs change that code._pin_claude_starting_mode) pins, or where it runs..claude/settings.local.json, fix(acp): keep Crew's tools for a claude session that asks for auto beside a foreign settings file #33847): such a session keeps the mode the pin leaves it in.default(plan,acceptEdits,dontAsk,bypassPermissions) intoauto; such a session keeps its mode, now with a warning.auto.auto-approved calls before they run (tracked in claude auto mode: classifier-approved tool calls reach no Crew gate and write no SEL record #12743).What changed (motivation → approach → change)
Symptom: the requested
autonever applies. Root cause: Crew's only channel for it is a settings tier the SDK filters.session/set_modeworks: on 0.100.0set_modeautoanswered{}, then a Bash call ran with nosession/request_permission.Change:
_apply_claude_requested_modeonClaudeAcpClient, in the newsrc/kiro_crew/acp/client_claude_mode.py. It sendssession/set_modeautoonly when the session requestedauto, is not Side Chat, a zero-tool spec or one beside a foreignsettings.local.json(below), is indefault, and listsautoinavailableModes. Any other mode is kept, with one warning; foracceptEditsorbypassPermissionsit namesKIROCREW_CC_PIN_INHERITED_MODE=1and an SEL record has outcomekept_inherited_mode.autoasksapproval_mode_policy.session_mode_permitted("trust"); denial keepsdefaultand audits. Side Chat and zero-tool sessions are unregistered. A POSIX stop checks the start id, then scans children and signals only the verified isolated group. An unknown or changed id skips the scan and root signal; recorded-child guards still apply. Windows without a start id kills the captured process only.settings.local.json. A session that leaves it out (fix(acp): keep Crew's tools for a claude session that asks for auto beside a foreign settings file #33847, pinned todefaultwith a chat notice) is skipped. So is one that could not leave it out: that file loads, so Crew does not govern it (_permission_surface_governed); one warning, the same notice, no record.defaultwhen it moved the session;_track_claude_starting_moderecords that mode. The request follows the startup model. This holds onsession/new,session/loadand a fresh conversation (src/kiro_crew/acp/client_new_conversation.py). WithKIROCREW_CC_PIN_INHERITED_MODEon (fix(acp): add an opt-in to move unrequested claude sessions out of auto #30308), a session the pin moves todefaultthen getsautoif offered.autonot offered, logs one warning and keepsdefault; a dead child or broken pipe ends the start. No answer in time, or an answer reportingacceptEdits(a model without Auto mode support), is undone withsession/set_modedefault, as is anautolanding after that undo; a failed undo stops the session. A cancel before the drain reads the reports ends the process.autois applied at session start only:set_modelfirst moves a requested-autosession in an approving mode todefault(stopping it, unswitched, if that fails) and leaves it there._read_messagefollows mode reports for requested-autosessions. Adapter ids longer thanMODE_ID_MAXare ignored at the start and in both report shapes. Startup reports are restored before the first prompt; after startup, a report ofauto,acceptEdits, orbypassPermissionsstops the captured process tree before an agent-started turn can dispatch a tool. A requested-autostart retains the drain idle window perf(acp): end the post-start drain at once on the claude harness #37154 removed, so it still reads late reports.claude_classifierinauto,claude_permission_modeinbypassPermissionsand for file edits inacceptEdits, otherwiseclaude_unattributed. Interrupted rows are alwaysclaude_unattributedbecause a following permission request may still be unread. Every row carries the scrubbedpermission_mode.client_start.py,client_transport.pyandclient_model_selection.pyequal main:ClaudeAcpClientoverrides existing seams (_initialize_params,_drain_notifications,_read_message,_push_model_config_option,ensure_ready) insrc/kiro_crew/acp/client_claude_mode_seams.py.AcpClientgains only_unasked_call_attribution.claude-code-provider.md,governance.md,sel.md,acp-client.md,agent-host-contract.md(underdocs/system-specs/modules/),src/kiro_crew/docs/configuration.md.Backwards compatibility
Compatible: a session that does not request
autosends nothing new; a session that requests it now runs in the mode the documented opt-in already promised. An excluded session behaves as on main. So does a session whose foreignsettings.local.jsoncould not be left out: it gets noset_modeauto, plus the same chat notice.One new case to know about: claude-agent-acp resumes a
session/loadin the mode its transcript was left in. After this change, a session that ran inautounder the opt-in keeps that in its transcript. If the operator later removes the opt-in, that resumed session comes back inauto. That is the resumed-session half of #29909. Its fix, #30308, has merged and keeps today's behaviour by default at a maintainer's request: its pin moves an unrequestedautotodefaultonsession/loadonly whenKIROCREW_CC_PIN_INHERITED_MODEis set. So by default such a resumed session stays inauto, as a session whose user~/.claudenamesautodoes today, and an operator who setsKIROCREW_CC_PIN_INHERITED_MODE=1gets it moved todefaultbefore its first prompt.A managed fleet whose
approval_modesrule deniestrustkeepsdefault: with the opt-in set, Crew sends noset_modeauto, logs a warning and writes amode_change:claude_autoSEL record with outcomeapproval_mode_denied_by_policy. If such a rule is installed while a requested-autosession is inauto,acceptEditsorbypassPermissions, Crew settles every observed unasked call before it stops the captured process, then writes oneclaude_unattributedinterrupted_by_policyrow per unsettled id. A callback queued for an older process does not touch its replacement. Side Chat and zero-tool sessions are not watched or registered, so a trust denial or approving report does not stop their text-only turns. A closed client loop or failed enqueue uses the same settle-stop-write order synchronously on the installing thread. On POSIX it rechecks the captured start id before and after child discovery and signals only the identity-checked isolated group; an unknown or changed id skips that scan and signal, while recorded escaped children keep their own guarded sweep. Windows keeps the pinned tree kill when a start id exists and otherwise kills only the captured process object. A deny that lands while a start or prompt waits for the ceiling's final answer is left to that stop: the restore re-reads the mark after each wait and sends noset_modeand no second record. A prompt whose pre-prompt restore is in flight fails once with the process-exit error. Its next attempt starts a fresh session, which reads the denying ceiling and keepsdefault. On main a requested-autosession that started inacceptEditsorbypassPermissions(a~/.claudedefault, a resumed transcript) kept it under any policy. A requested-autosession whose start has settled and that then reportsauto,acceptEditsorbypassPermissionsCrew did not ask for (a model change Crew did not send, anautolanding after Crew withdrew it) is stopped the same way, from the reader that read the report, before an agent-started turn can dispatch a tool; the next prompt starts a fresh session. A start settles at its last step, the start drain or the end of a fresh conversation, so the report answering its ownset_modeautois the start's, and a fallback read during a start is still moved back before the first prompt. While a ceiling that narrows the scope is still being installed, the start or prompt waits for its final answer (up toapproval_mode_policy's 30 s bound) instead of recording a denial.Audit changes. On main a requested-
autosession never leavesdefault, yet every call of it that asks nothing (onedefaultitself allows, such as a read inside the project) gets anauto_approved/claude_classifierSEL row, which names the wrong decider. Every unasked call of a requested-autosession still gets its row, as on main, but the row now names what let it run:claude_classifieronly in a confirmedauto;claude_permission_modeinbypassPermissions, and for file edits inacceptEdits;claude_unattributedfor other calls inacceptEditsand for every call indefault,plan,dontAskor an unconfirmed mode, withpermission_modenaming the mode. If an installed ceiling stops the process before a terminal update arrives, every unsettled observed call gets that same row shape with outcome andtool_statusinterrupted_by_policy,decided_byclaude_unattributed, reasonclaude_unasked_call, and the confirmedpermission_mode; the nextsession/request_permissionmay still be unread, so the row names no approver. Ids are settled and their rows built before the stop and written after it, so a racing terminal update does not duplicate one. Ending the process cannot classify a frame still unread in the pipe: an already observed call may be recorded asinterrupted_by_policy, while a call not yet observed gets no row. Requested-mode SEL records written from the client's event loop go throughasyncio.to_thread, so a first SEL use does no file I/O on that loop; the deny hook writes its record on the thread that installs the ceiling. A consumer that readsdecided_bysees the new values. A requested-autosession that starts or resumes in another mode keeps it, as on main, but now logs one warning, and inacceptEditsorbypassPermissionswrites amode_change:claude_autorecord with the new outcomekept_inherited_mode.The change adds one
session/set_modecall on the opt-in path, a second (default) only after an unanswered request or a report ofacceptEditsorbypassPermissions. The installed-denial path sends none; it stops the process instead. On the claude harness #37154 ends the start drain at once; the start of a session that requestedautokeeps the drain's 0.5 s idle window instead, so a mode report that follows an answer the start read is read before the first prompt. Every other claude start keeps #37154's speed-up. The requestedautois now applied after the startup model rather than before it, and a live model switch of a requested-autosession now moves it todefaultfirst and leaves it in Default mode for the rest of that session (one warning), where on main the session never leftdefault.Known limits, left for a follow-up: if the policy stop's kill fails and the captured process outlives its bounded wait, the deny mark is still cleared, so that session is not blocked afterwards; a ceiling install that races a session's pre-prompt check can write the
approval_mode_denied_by_policyrecord twice; a denying ceiling that installs while a model switch is moving a requested-autosession back todefaultcan still stop that session, because its stop reads the mode from before the switch; one that installs whileset_modeautois in flight seesdefaultand leaves that session to the later restore check; on the installing thread the denial record is written before the stop is scheduled, so a slow first SEL write delays that stop; a session that resumes already inautokeeps it, as on main, even where Crew does not govern its permission surface; and a startup model switch that falls back toacceptEditsbefore it answers is recorded askept_inherited_mode, although Crew then restoresdefault.Tests
test/test_claude_requested_mode_start.py: the registered hook stops idle requested-autoclients confirmed inauto,acceptEditsorbypassPermissionswithout sendingset_mode, and the next start stays indefaultwith the ceiling warning; a deny while a startup reader is active stops without starting a concurrent stdout read; a mid-turn deny settles every unsettled unasked call before the stop, writes itsinterrupted_by_policyrow asclaude_unattributedafter it and does not duplicate an already-settled call (test_a_trust_deny_stops_then_records_each_unsettled_unasked_call); an SEL writer that blocks until released finds the process already stopped, and the rows keep the title and attribution the session had before the stop dropped them (test_a_trust_deny_stops_the_process_before_any_sel_write_is_awaited); a stop captured for an older process leaves its replacement alone, whether the old process has exited, is not yet reaped, or is replaced after the stop task is created (test_a_stop_scheduled_for_a_replaced_process_does_not_touch_the_replacement); a non-requesting client and a requested client confirmed indefaultare untouched; a synchronous fallback after a closed loop or failed enqueue settles one observed call before killing the captured tree, writes exactly oneclaude_unattributedinterrupted_by_policyrow, and ignores its later terminal update; and the weak registry does not retain clients.test_async_requested_mode_audit_runs_off_the_event_loop(the SEL write at a start runs off the loop thread);test_a_deny_that_lands_during_the_verdict_wait_owns_the_stop(a deny installed while the restore waits for the final verdict: one record, noset_mode, the process stopped);test_closed_loop_fallback_kills_the_captured_tree_and_escaped_children(the synchronous fallback kills the tree and sweeps stored and fresh children);test_idle_reader_stops_before_dispatching_a_turn_after_an_approving_report(a settled session's idle reader readsacceptEdits, then an agent-started turn frame: the process is stopped and no turn is dispatched);test_the_idle_reader_awaiting_its_stop_is_cancelled_and_the_stop_still_ends_the_process(the idle reader that awaits that stop is cancelled by the stop's own kill or by a prompt claiming stdout; neither waits on the other, and the stop finishes on the client's own kill, not the fallback);test_a_fresh_conversation_that_applies_auto_is_not_stopped_by_its_own_report(on the recorded 0.100.0 frame order, a fresh conversation reads itsset_modeautoreport before the{}answer and ends inauto, or indefaultafter theacceptEditsfallback, and is not stopped).test/test_claude_requested_mode_stop_safety.py: a matching POSIX start id scans children and signals only the identity-checked isolated group; a recycled or unknown id neither scans nor signals and sweeps only recorded children; Windows with no start id kills only the captured process object. Requested-autozero-tool and Side Chat sessions stay out of the live registry and are not stopped by a trust denial or approving report. Both fix-specific revert mutations fail this file.test_a_failed_policy_stop_runs_its_tree_kill_fallback_off_the_event_loop: when the live-loop policy stop's client stop raises or is cancelled, the synchronous tree-kill fallback runs once, on asubprocess_executorthread rather than the loop thread, with the captured start id and child snapshot; a revert that runs it inline on the loop fails the matching case.test/test_claude_requested_mode.py(new; the seam test file is over 1,500 lines, so it lives in its own module):autoand reporteddefaultsends exactly onesession/set_modeautoand logs at info;auto,plan,acceptEdits,dontAsk,bypassPermissions, nocurrentModeId, a malformed or missingmodesblock sends nothing;automissing fromavailableModeslogs one warning and sends nothing;set_modeanswered with a JSON-RPC error frame (anAcpErrorcarrying acode) logs one warning, does not raise and does not stop the harness;test_a_dead_child_during_set_mode_auto_is_not_a_refusal: a process that exited, is not running, a shutdown or a broken pipe, raised on the send or on the wait, propagates as the same error with no such warning; an unanswered one is followed byset_modedefault, and the harness is stopped andAcpErrorraised when that is refused or unanswered too;acceptEditsfallback is logged as a warning naming it, and the session is moved back todefault;_initialize_sessionpin through_pin_starting_mode, whoseClaudeAcpClientbody records the pin's mode right after the pin, and the request is applied once, after the startup model;defaultis moved on toautowhatever the response reported, a pinned session with nomodesblock warns and keepsdefault, and a pin return that is not a mode is ignored;session/new; thesession/loadcase replays that same recorded answer under the loaded id, because no livesession/loadwas captured;KIROCREW_CC_PIN_INHERITED_MODEunset and1, with and without a request, starting indefault,autoorbypassPermissions: a requestedautoends inauto, except abypassPermissionsstart with the setting unset, which keeps it as on main; with no request the setting unset keeps the starting mode and1movesautoandbypassPermissionstodefault;test_an_excluded_requested_auto_session_keeps_the_pinned_mode, through_initialize_sessiononsession/newandsession/load, starting indefaultorauto: beside a foreignsettings.local.jsonthe session sends nosession/set_modeauto, ends indefault, keeps the fix(acp): keep Crew's tools for a claude session that asks for auto beside a foreign settings file #33847 notice, and a completed unasked call writes noauto_approvedSEL row; with a Crew-owned file the same request ends inauto, has no notice and writes that row. With the early return removed, the 4 excluded cases fail ('auto' not in ['auto']from adefaultstart,'auto' not in ['default', 'auto']from anautostart) and the rest of the file passes;test_an_unasked_call_is_recorded_naming_the_mode_that_approved_it, 16 cases onsession/newandsession/loadeach, through_initialize_sessionand then a completed unasked call.claude_classifier/auto: an answeredset_modeauto(with and without the recordedconfig_option_updateauto), a start inauto, abypassPermissionsstart the pin moves beforeautois applied.claude_permission_modenaming the mode: a start inbypassPermissionswithKIROCREW_CC_PIN_INHERITED_MODEunset, an edit in anacceptEditsstart with it unset or1.claude_unattributednamingacceptEdits: a read in such a start.claude_unattributednamingdefault: a refused or timed-outset_mode,autonot offered, theacceptEditsfallback reported as acurrent_mode_updateor aconfig_option_update(moved back todefault), and a pinned session whoseset_modeautois refused; namingplan: aplanstart;test_a_set_mode_auto_that_times_out_is_moved_back_to_default, onsession/newandsession/load, starting indefaultor pinned there frombypassPermissions:set_modeautogoes unanswered anddefaultis sent; whendefaultis answered the session continues, confirmed indefault, and an unasked call gets aclaude_unattributedrow, and when it is refused or times out the process is killed and_initialize_sessionraisesAcpError;test_a_set_mode_auto_that_lands_elsewhere_is_moved_back_to_default, onsession/newandsession/load, with the fallback reported either way:session/set_modeautoand thendefaultare sent; whendefaultis answered the session continues and an unasked call gets aclaude_unattributedrow, and when it is refused or times out the process is killed and_initialize_sessionraisesAcpError;test_a_later_start_that_skips_the_mode_read_back_is_not_audited_as_auto: a second start on the same client whose restore fails after naming its session never reaches the read-back, and does not inherit the first session's confirmedauto: its unasked call gets aclaude_unattributedrow with no mode;_WireAdapter: Crew's own_wait_for_responseand_read_messageread its frames off a fake stdout, and it keeps the session's mode as claude-agent-acp'sSessionModeManagerdoes), onsession/newandsession/load:test_the_requested_auto_goes_on_after_the_startup_model(theset_modeautofollows the model switch; a model with Auto mode support ends inauto, one without ends indefault; the drain keeps its idle window);test_a_fallback_reported_after_the_set_mode_answer_is_undone_before_the_first_prompt(theacceptEditsreport after the{}answer is read by the drain, which keeps its idle window, and undone, or the session is stopped when the undo is refused);test_the_real_start_drain_of_a_requested_auto_start_reads_a_late_report(Crew's real_drain_notificationson the same adapter: a fallback reported after the answer, or before it, is read and undone before the start returns). The adapter's drain stub, like the real drain, reads nothing off the wire when asked for no idle window;test_a_live_model_switch_into_accept_edits_stops_the_settled_session(a switch to a model without Auto mode support that Crew did not send, its report read during the switch or later inside a turn: the settled session's process is stopped, and noset_moderestore is sent);set_modelon the same adapter, onsession/newandsession/load:test_a_live_model_switch_leaves_the_session_in_default(to a model with or without Auto mode support, its mode reports read before or after the answer: the switch reaches the adapter indefault, noset_modeautofollows, and after the idle reader has read everything the session is indefault, with aclaude_unattributedrow for an unasked edit and one warning over two switches);test_a_refused_move_to_default_before_a_live_switch_stops_the_session(killed, no switch sent);test_only_a_session_that_requested_auto_leaves_its_mode_before_a_live_switch(a session started inacceptEdits,bypassPermissionsorautothat requested nothing switches with noset_modeand no warning; one that requestedautomoves todefaultfirst);test_a_refused_model_leaves_the_session_in_default(AcpModelUnavailableraised, session indefault, aclaude_unattributedrow); and onlyauto,acceptEditsandbypassPermissionsare left before a switch;acceptEditsandbypassPermissions; a restated mode, another session's report or a frame with no mode changes nothing; a later report of an asking mode clears the mark;_read_messagefollows reports only for a session that requestedauto; the move back is sent only when due;test_an_oversized_mode_report_is_ignored_without_scheduling_a_stopcovers both report shapes, andtest_an_oversized_starting_mode_is_not_retainedcovers the start response;session/newandsession/load:test_a_child_that_dies_during_the_start_ends_it_in_either_step(the child exits or its pipe breaks during the startup model or duringset_modeauto:_initialize_sessionraises the transport error alike in both steps);test_a_cancel_before_the_requested_auto_is_settled_ends_the_session(on a model with and without Auto mode support, a cancel right afterset_modeautois written, during its wait, or in the start drain before its late mode report is read:ensure_readyraises the cancel, the process is killed and the session dropped, and the nextensure_readyspawns a new child instead of the warm return);test_only_a_requested_auto_start_enters_the_cancel_guard(withclient_claude_mode_seams._ended_on_requested_mode_cancelpatched to record entries, a requested-autostart enters it once, around the request and the drain, and a claude start that asked for nothing never does).test/fixtures/claude_mode_pin/requested-auto-applied.jsonl(new): the adapter's answers toinitialize,session/newandsession/set_modeauto, recorded byKIROCREW_ACP_RECORD_FRAMESwhile Crew's ownAcpClientdrove claude-agent-acp 0.100.0, pruned of host data (session id replaced, prompt turn dropped, config options cut tomode). It follows theclaude_mode_pin/convention; theacp_frames/replay corpus and its host-data gate do not cover this directory.test/test_acp_client_new_conversation.py: a fresh conversation, withKIROCREW_CC_PERMISSION_MODE=autoset and unset, whose new session answers with the recorded 0.100.0 modes (reportingdefault, orbypassPermissionswith the pin returningdefault). With the opt-in,session/set_modeautofollows the startup model; without it none is sent. A fresh conversation after a session confirmed inautowrites the classifier row only when its ownset_modeautois answered; when it is refused, the row names no approver (claude_unattributed). A fresh session whoseset_modeautolands inacceptEdits, goes unanswered, or is reported inacceptEditsafter its answer (read by the drain, which keeps its idle window for every requested-autostart), is moved back todefault, and a refused move ends the process. A fresh session whose child exits or whose pipe breaks duringset_modeautoraises that error, is not drained and ends the process, as a failure in its model step does. A cancel right after itsset_modeautois written, during its wait or in its drain ends the process too, on a model with and without Auto mode support.test/test_claude_requested_mode_start.py(new; it reuses the_WireAdapteroftest/test_claude_requested_mode.py, which is near the 1,600-line target):test_a_ceiling_that_denies_trust_keeps_the_session_in_default(onsession/new,session/loadand a respawn into a session the adapter resumes inauto: noset_modeauto, one policy warning, oneapproval_mode_denied_by_policyrecord,defaultconfirmed and still watched, and an unasked call gets theclaude_unattributed/defaultrow);test_a_ceiling_that_permits_trust_applies_auto_and_records_it(oneset_modeauto, oneenabledrecord, no move before the next prompt);test_a_deny_installed_while_the_session_is_in_auto_moves_it_before_the_next_prompt(the nextensure_readysends oneset_modedefault, the one after sends nothing, and a refused move stops the session);test_a_deny_moves_a_requested_auto_session_out_of_any_mode_that_approves(a resumedacceptEditsorbypassPermissionsstart is moved todefault);test_a_start_in_auto_whose_model_switch_reports_late_is_undone_before_the_first_promptandtest_a_landing_reported_after_the_timeouts_move_back_is_undone_before_the_first_prompt(with the real drain: anacceptEditsreport after the startup model's answer, or after the timeout's move back, is read and undone before the start returns);test_only_a_requested_auto_start_keeps_the_drain_idle_window(a claude start that asked for nothing still drains withidle_exit=0.0);test_a_mode_id_that_is_not_a_string_is_skipped(a list, object or numberidinavailableModesneither raises nor hides a stringauto);test_a_requested_auto_session_refused_before_spawn_never_reaches_the_requestandtest_a_requested_auto_session_the_handshake_refuses_never_reaches_the_request(a requested-autoworker with narrowed built-ins on an adapter below the session-options floor, refused before its spawn or at its handshake, sends noset_mode, reads no ceiling and writes no record; the same worker at the floor getsauto). Also:test_a_session_crew_does_not_govern_is_not_switched_to_auto(a foreignsettings.local.jsonbeside asettings.jsonthat setshooksorsandbox, or that is a directory, onsession/new,session/loadand a fresh conversation: noset_modeauto, one warning per start, the exclusion path's notice, no record,defaultkept, and an unasked call gets theclaude_unattributed/defaultrow; with no foreign file Crew governs and appliesauto);test_a_ceiling_install_in_progress_is_waited_out_before_the_requestandtest_a_session_in_auto_waits_out_a_ceiling_install_before_its_next_prompt(a real ceiling mid install: one that finishes during the wait givesautoor keeps it, one that outlasts it keeps or moves todefaultwith no denial record);test_a_landing_reported_after_the_timeouts_move_back_is_undone_before_the_first_promptnow on a model with and without Auto mode support (a withdrawnautolanding late is moved back, noenabledrecord) andtest_only_a_withdrawn_auto_is_due_when_it_is_reported; the deny-hook tests cover an idle approving session stopped with noset_modeand a fresh start kept indefault; a startup reader stopped without a concurrent read; unsettled unasked calls recorded asinterrupted_by_policybefore the stop while an already-settled call gets no duplicate; a queued callback leaving a replacement process alone; non-requesting and confirmed-defaultsessions untouched; a closed-loop kill of the captured process; and weak registry ownership;test_a_marked_session_the_ceiling_denies_records_the_denial(a session marked by anacceptEditsreport while the ceiling deniestrustis moved once and the denial recorded). The unit-level_applyhelper oftest/test_claude_requested_mode.pyand this PR's tests intest/test_acp_client_new_conversation.pymark the client as having written its own seed, since a session Crew does not govern now gets noauto. The_WireAdaptergainedwithhold_auto, which answers aset_modeautoonly after the nextset_mode.test_requested_mode_sequencing_stays_off_the_shared_client_paths(H13): the shared_initialize_session,ensure_ready,_read_messageandset_modelname none of the requested-mode steps,AcpClientcarries none of them, andClaudeAcpClientbinds each seam override fromclient_claude_mode_seams.test_a_non_claude_unasked_call_keeps_mains_sel_row: a non-claude client's unasked-call row keeps main's metadata, with nopermission_mode.test_a_requested_auto_session_already_in_auto_needs_no_write_or_warning,test_a_requested_auto_warns_for_every_inherited_mode_it_keeps(plananddontAsk: one warning, no record;acceptEditsandbypassPermissions: one warning that Crew keeps the mode and namesKIROCREW_CC_PIN_INHERITED_MODE=1, and onekept_inherited_moderecord) andtest_a_requested_auto_warns_when_the_current_mode_is_not_reported.test_a_mode_report_behind_raw_sdk_task_frames_is_followed: acurrent_mode_updateorconfig_option_updateread after two_claude/sdkMessagetask frames in one_read_messageis returned and followed (the move back is marked), the task frames reach the session's task state and no caller, and the turn's mode-change notice still reads the report.test/test_acp_client_new_conversation.pyalso hastest_a_fresh_session_asks_the_approval_modes_ceiling_before_auto(permitted:set_modeautoandautoconfirmed; denied: none sent,defaultconfirmed).test/test_acp_client_tool_hooks.pyalso hastest_the_reported_mode_is_scrubbed_before_it_reaches_the_row(a credential or an exfiltration URL reported as the mode reaches SEL scrubbed).test/test_acp_client_tool_hooks.py: the unasked-call audit tests build a client confirmed inautoand check its row namesclaude_classifierandauto; a requested-autoclient confirmed inbypassPermissions(any kind) or inacceptEdits(kindsedit,delete,move) writes a row namingclaude_permission_modeand the mode; any other kind inacceptEdits, and any call of one confirmed in no mode,default,planordontAsk, writes a row namingclaude_unattributedand that mode.test/test_acp_claude_mode_pin_seam.py(from fix(acp): add an opt-in to move unrequested claude sessions out of auto #30308): the case of a requestedautothat starts or resumes inbypassPermissionswith the setting on now expectssession/set_modedefaultand thenauto. This existing assertion changes because the second call is the fix.test/test_client_bindings.py: inventory rows for the members this PR adds (onClaudeAcpClientthe members bound fromclient_claude_mode, the seam overrides fromclient_claude_mode_seamsand_follows_requested_mode; onAcpClient_unasked_call_attribution), and the pin's new signature digest (it now returns a mode). Main'stest_only_the_facade_and_the_class_import_the_session_startbecomestest_only_the_facade_class_and_late_claude_seam_import_session_start: the seam module, listed afterclient_startin_CLIENT_OWNERS, is a third importer ofclient_start.test/test_acp_post_session_new_drain.py,test/test_acp_session_mcp_client_seam.py,test/test_acp_refactor_facade.py,test/test_client_bindings.py,test/test_acp_client_model_substitution.py), the files fix(acp): keep Crew's tools for a claude session that asks for auto beside a foreign settings file #33847 added or changed (test/test_claude_member_auto_mode_mount.py,test/test_acp_client_tool_hooks.py,test/test_acp_session_mcp.py,test/test_acp_bindings.py,test/test_claude_member_tool_limits.py),test/test_cc_permission_mode_seed.py,test/test_acp_provider_new_conversation.py, the files feat: carry a claude crewmate worker's native-tool excludes #34475 and feat(chat): list a claude chat's own commands and skills in the / menu #34555 changed (test/test_claude_worker_tool_limits.py,test/test_crew_oauth_bridge_harnesses.py,test/test_crewmate_harness_inherit.py,test/test_mate_worker_harnesses.py,test/test_api_slash_commands.py),test/test_acp_client_session_setup.py,test/test_harness_parity.py,test/test_claude_requested_mode_start.pyand the approval-mode tests (test/test_approval_modes_governance.py,test/test_approval_modes_trust_policy.py,test/test_members_roster_relay_teammate.py,test/test_remote_dispatch_work_item.py,test/integration/test_boot_smoke.py), and the files fix(acp): refuse an option-bound claude session before it spawns #37163 and perf: start kiro-cli's agent engine from a node compile cache #30671 added (test/test_claude_below_floor_before_spawn.py,test/test_acp_node_compile_cache.py,test/test_acp_node_compile_cache_engine.py), and the tests of the exclusion and declined paths (test/test_acp_client_settings_restore.py,test/test_acp_seed_provenance.py,test/test_acp_seed_provenance_sharer_teardown.py,test/test_acp_seed_provenance_sibling_sharing.py,test/test_member_dispatch_mount.py,test/test_member_panel_mount.py,test/test_seed_claim_released_on_teardown.py,test/test_settings_seed_declined_notice.py), and the other test files refactor(acp): move the claude-agent-acp session code off AcpClient into ClaudeAcpClient #37484 added or changed (test/test_claude_prepare_session.py,test/test_acp_seed_provenance_durable_grant.py,test/test_acp_client_agent_started_turns.py,test/test_acp_client_model_entitlement.py,test/test_acp_client_shutdown_eof_grace.py,test/test_acp_client_shutdown_reset.py,test/test_acp_goose_backend.py,test/test_acp_mcp_ref_guard.py,test/test_agent_sdk_backend_identity.py,test/test_backend_cards_advertised.py,test/test_core_path_redact_before_bound.py,test/test_deny_bounded_write.py,test/test_pi_saved_spec.py,test/test_post_compaction_continuation.py,test/test_provider_dispatch.py,test/test_security_posture.py), and the other test files feat: show the claude-agent-acp surfaces the dashboard drops #37512 and refactor(acp): move the goose session code off AcpClient into GooseAcpClient #37535 added or changed (test/test_acp_bindings.py,test/test_acp_mcp_startable.py,test/test_agent_sdk_capabilities.py,test/test_chat_handlers_composition_contract.py,test/test_chat_runner_composition_contract.py,test/test_chat_slot_reasoning_effort.py,test/test_claude_auto_memory_envelope.py,test/test_claude_compaction_summary.py,test/test_claude_fast_mode_toggle.py,test/test_claude_harness_notices.py,test/test_claude_native_child_stop.py,test/test_claude_native_subagent_cards.py,test/test_claude_plan_checklist.py,test/test_claude_raw_sdk_tasks.py,test/test_claude_raw_sdk_tasks_lifecycle.py,test/test_claude_read_image_rows.py,test/test_claude_subagent_card_tool_titles.py,test/test_claude_thinking_display.py,test/test_claude_zero_tools.py,test/test_codex_compaction.py,test/test_goose_tested_version_notice.py,test/test_json_object_body_guard.py,test/test_session_backend_model_list.py,test/test_side_readonly_goose.py,test/test_slot_running_readers.py,test/test_todo_pill_resync.py,test/test_transient_notice_parity.py, andtest/test_acp_frame_replay.py, which replays the frames feat: show the claude-agent-acp surfaces the dashboard drops #37512 recorded), and the files feat(acp): ClaudeHarness, claude-agent-acp on the shared runtime with per-session setup (not routed) #37521, refactor(acp): move the opencode session code off AcpClient into OpencodeAcpClient #37602 and refactor(acp): move the deepseek session code off AcpClient into DeepseekAcpClient #37641 added or changed (test/test_claude_shared_runtime.py,test/test_acp_harness_contract.py,test/test_runtime_bindings.py,test/test_acp_opencode_backend.py,test/test_acp_deepseek_backend_enforcement.py,test/test_acp_mimocode_turn.py,test/test_member_mount_deepseek.py), and those feat(acp): GooseHarness, goose on the shared runtime with per-session checks (not routed) #37562 and feat(acp): route claude Agent-tool children per session on the shared runtime #37601 added or changed (test/test_goose_shared_runtime.py,test/test_claude_shared_children.py,test/test_session_handle_bindings.py), and the other approval-mode tests (test/test_approval_modes_enforcement.py,test/test_cron_approval_mode.py,test/test_dashboard_approval_modes.py,test/test_dashboard_chat_approval_mode.py,test/test_slack_code_channel_approval_mode.py), and fix(crew): keep a bot's deny rules when the upgrade moves it #35011'stest/test_mate_held_rules.py, and the test files fix(acp): end a claude turn whose prompt was never sent #37922, feat: add Google Antigravity ACP harness #37974, fix(mimocode): refuse a chat that would answer from Xiaomi's hosted model unsigned #37629 and fix(metrics): split the sharing tenants bucket past 4 and count unshared turns' start #37980 added or changed (test/test_acp_antigravity_backend.py,test/test_acp_mimocode_hosted_fallback.py,test/metrics/test_chat_runtime_share.py,test/test_strands_model_switch.pyand the 21 others they touched): 8,605 passed and 20 skipped withKIROCREW_CC_PIN_INHERITED_MODEunset, and the same with it set to1.test/test_acp_*.pyandtest/test_claude_*.py: 10,893 passed, 17 skipped.test/test_claude_requested_mode_start.pyandtest/test_claude_requested_mode_stop_safety.pyplus, intest/test_claude_requested_mode.py,test_a_requested_auto_session_reported_default_is_moved_to_auto,test_the_adapters_accept_edits_fallback_is_named_and_undone,test_both_session_establishment_paths_reach_the_claude_owned_drain_after_the_model,test_only_a_requested_auto_start_enters_the_cancel_guardandtest_only_a_session_that_requested_auto_leaves_its_mode_before_a_live_switch, intest/test_acp_client_new_conversation.py,test_a_requested_auto_is_applied_to_the_fresh_session_after_its_model,test_a_fresh_session_asks_the_approval_modes_ceiling_before_autoandtest_a_fresh_session_whose_fallback_is_reported_late_is_moved_back_or_ended(119 ids) passed 20 runs at-n0and 10 runs at-n 4 --dist loadgroup --max-worker-restart=2besidetest/test_acp_post_session_new_drain.pyandtest/test_approval_modes_trust_policy.py(171 ids each), and one shuffled run oftest/test_claude_requested_mode_start.py,test/test_claude_requested_mode.py,test/test_acp_client_new_conversation.pyandtest/test_acp_client_session_setup.pypassed (361 ids, seed 74053). The deny-hook, settled-report and shield tests (30 ids) also passed 50 runs on their own at-n0. On the previous head (5379cd3874):test/test_claude_requested_mode.py,test/test_acp_client_tool_hooks.py::TestAcpClientUnaskedClaudeAutoAudit,test/test_acp_client_new_conversation.pyandtest/test_acp_client_session_setup.pypassed 20 runs at-n0; those four files withtest/test_acp_session_mcp_client_seam.pyas a co-tenant passed 10 runs at-n 4 --dist loadgroup --max-worker-restart=2(501 ids each); one shuffled run of the four files passed (381 ids, seed 30235).test/test_flake_pattern_ratchet.pypassed.Proof: PROVEN test/test_acp_claude_mode_pin_seam.py::TestUnrequestedModePin::test_an_opt_in_session_that_starts_or_resumes_in_bypass_is_pinned[new], test/test_acp_claude_mode_pin_seam.py::TestUnrequestedModePin::test_an_opt_in_session_that_starts_or_resumes_in_bypass_is_pinned[load], test/test_acp_client_new_conversation.py::test_a_requested_auto_is_applied_to_the_fresh_session_after_its_model[opt-in-reported-default], test/test_acp_client_new_conversation.py::test_a_requested_auto_is_applied_to_the_fresh_session_after_its_model[opt-in-pinned-to-default], test/test_acp_client_new_conversation.py::test_a_child_that_dies_during_the_fresh_sessions_set_mode_auto_ends_the_process[exited] (head ef16ab8)
Gate proof: tree d449b2817311; ran 24; skipped none
Manual verification
Kiro Crew's real
AcpClientfrom this branch, driven by a script against live claude-agent-acp with Claude Code 2.1.318, a scratchCLAUDE_CONFIG_DIRholding only the model-access keys, scratchKIROCREW_HOMEandKIRO_HOME, and one prompt that asks for a harmlessecho ok > <scratch>/probe.txtthrough Bash:KIROCREW_CC_PERMISSION_MODE=auto:session/newreporteddefault; Crew sentsession/set_modeauto(answered{}, preceded by aconfig_option_updatewith modeauto) and logged "claude session started in 'default'; applied the requested permission mode 'auto'"; the Bash call ran with nosession/request_permissionand the file was written.session/newreporteddefault, noset_modewas sent, the Bash call sent asession/request_permission, and the script's ungated client refused it.4a546774f):session/newreporteddefault, noset_modewas sent, and the Bash call sent asession/request_permission. This is the bug.These runs were made before this branch was rebased onto #30308, #31091 and #33847 and do not exercise
KIROCREW_CC_PIN_INHERITED_MODE, a fresh conversation or the exclusion path; those cases are covered by the tests above.Related Issues
Closes #30169
Related: #29909 (a session that asks for no mode starts in the user's own
~/.claudemode), fixed behind an opt-in by #30308, which has merged; this PR is rebased onto it. #31091 (a fresh claude conversation on the live adapter) has merged too, and this PR applies the request on its path as well. #33847 (Crew's tools for a requested-autosession beside a foreign settings file) has merged; this PR is rebased onto it and leaves its excluded sessions in the pinned mode, as its review asked.This head is rebased onto #37154 (the claude start drain ends at once; see Backwards compatibility for the one start that keeps its idle window) and #26459 (a wrapped claude-agent-acp's version from its handshake; this PR reads no adapter version, and it skips an excluded session the same way whichever version source decided the exclusion), and #37484 (the claude session code moved from
AcpClienttoClaudeAcpClient; this PR's fields and members are on that class, reached through its hooks). It is also rebased onto #37512 (claude-agent-acp surfaces: raw SDK task frames that_read_messagekeeps from every reader, and mode-change notice rows; mode reports still reach this PR's follower first) and #37535, #37602 and #37641 (GooseAcpClient,OpencodeAcpClient,DeepseekAcpClient, which keep every hook this PR adds asAcpClienthas it), and #37521 (claude on the shared runtime, not routed yet: its per-session pin goes through the same_pin_starting_mode, but nothing there applies a requestedauto, so such a session keepsdefaultas on main). It is also rebased onto #37922 (a claude turn whose prompt was never sent is ended; the settled-mode stop runs inside the reader before the idle reader hands an agent-started turn off, and_release_unsent_turnis unchanged), #37974 (the Antigravity harness, whose class reaches none of this PR's Claude code), #37629 (MimocodeAcpClient's hosted-model refusal) and #37980 (unshared-turn metrics), whose behaviour this PR leaves as it is.With this change the opt-in takes effect for every claude session the variable reaches, including cron and sub-agent sessions. A call the classifier approves skips Crew's gate before it runs and gets only the after-the-fact SEL row. A managed fleet refuses that through the
approval_modesceiling, the one precedence point governance names for an auto-approve mode: a policy that deniestrustkeeps a new session indefaultand stops an already-live approving process and then records its unsettled unasked calls.Sibling sweep
Swept:
git grep -n "defaultMode" -- src/kiro_crew/acp src/kiro_crew/agent_sdkSibling:
src/kiro_crew/acp/client_claude_seed.py-- changed hereThe claude seed writer is the only place Crew puts a requested permission mode into a settings tier the SDK filters; every other match is a docstring or another harness's own channel (goose's
GOOSE_MODE, the deepseek gate module).Swept:
git grep -n -E "_apply_(claude_)?requested_mode\(|ACP_BACKENDS_NO_MCP_INIT_FRAMES" -- src/kiro_crew/acpSibling:
src/kiro_crew/acp/client_start.py-- not affected -- equal to main;ClaudeAcpClient's_initialize_params,_drain_notificationsandensure_readyoverrides (client_claude_mode_seams.py) carry the cold start's stepsSibling:
src/kiro_crew/acp/client_new_conversation.py-- changed hereThe
session/loadandsession/newcalls and the fresh-conversation call reach the exclusion check and the mode record, which sit inside the function. They are also the two drains #37154 shortened; both keep the idle window for a session that requestedauto(the_drain_notificationsoverride on the cold start,_claude_mode_watchedon the fresh conversation) and only for it.Swept:
git grep -n "_permission_surface_governed" -- src/kiro_crewSibling:
src/kiro_crew/acp/client_seed_ownership.py-- not affected --settings_withheld_causealready reads it for the chat's tools-off noticeSibling:
src/kiro_crew/acp/client_mcp_array.py-- not affected -- it already withholds themcpServersarray on itThe mirror, the member projection, the MCP array and
settings_withheld_causealready withhold Crew's tools when this is false;_apply_claude_requested_modenow also withholdsauto. Every other mode change this PR makes only moves a session todefault, so it needs no such guard.Swept:
git grep -n -E "session_mode_permitted|register_deny_hook" -- src/kiro_crewSibling:
src/kiro_crew/dashboard/server.py-- not affected -- itsregister_deny_hookcallback drops slot Trust state on the installing thread; the claude callback (client_claude_mode._on_claude_trust_denied) registers beside it, captures each affected process, and schedules its audit-then-stop on that client's loopEvery site that sets or honours a session Trust asks
session_mode_permitted. The requested claudeautonow asks it where it is set (_apply_claude_requested_mode) and where it is honoured (_restore_claude_asking_mode_if_due, at the end of each start and inensure_ready).Swept:
git grep -n -E "CC_PERMISSION_MODE_AUTO|claude_classifier|_permission_mode" -- src/kiro_crewSibling:
src/kiro_crew/acp/client_tool_events.py-- changed hereSibling:
src/kiro_crew/acp/client_class.py-- changed hereThe unasked-call audit (
_maybe_audit_unasked_tool_call, which asks the_unasked_call_attributionhook what approved the call: main's classifier row inclient_class.py, the confirmed mode inclient_claude_mode.py) is the only reader that attributes a call to Claude's classifier; the seed, the pin and the exclusion read the requested mode only to ask for, keep or refuse a mode.Swept:
git grep -n -E "except \(?Acp(Error|TimeoutError)" -- src/kiro_crew/acp/client_claude_mode.py src/kiro_crew/acp/client_claude_session.py src/kiro_crew/acp/client_model_selection.pySibling:
src/kiro_crew/acp/client_claude_mode.py-- changed hereSibling:
src/kiro_crew/acp/client_claude_session.py-- changed hereSibling:
src/kiro_crew/acp/client_model_selection.py-- not affected -- equal to main;ClaudeAcpClient._push_model_config_optionmakes the move before a strict (live) switch, only on a session that follows its requested mode, which raises before any switch is sent_apply_claude_requested_modenow reads only an error frame as a refusedauto._set_claude_pinned_mode_or_stopstops the session (_claude_stop_session, which kills the process) and raises on any failure, so the move back before a prompt and the move before a model switch already stop the session on a dead child.Pattern harvest
Not generalizable: the defect is one adapter's settings-tier filter silently dropping one value; the general lesson (read a harness's resolved mode back instead of trusting a written setting) is already how the pin and the
VERIFIED_SEEDED_SETTINGSrouting work.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; see the Licensing section of CONTRIBUTING.md.