Skip to content

fix(acp): add an opt-in to move unrequested claude sessions out of auto - #30308

Merged
bolichen97 merged 1 commit into
kirodotdev:mainfrom
shubhamkurkure:fix/claude-pin-unrequested-mode
Nov 6, 2026
Merged

bolichen97 merged 1 commit into
kirodotdev:mainfrom
shubhamkurkure:fix/claude-pin-unrequested-mode

Conversation

@shubhamkurkure

@shubhamkurkure shubhamkurkure commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: with a new setting, KIROCREW_CC_PIN_INHERITED_MODE, turned on, a Claude session that carries Kiro Crew's tools never reaches its first prompt in auto or bypassPermissions unless Crew requested that mode, whatever the user's own Claude Code settings or a resumed transcript say (claude-agent-acp 0.84.0 or newer). The setting is off by default, and with it off every session behaves as on main.

A claude session that requests no permission mode gets a seeded <work_dir>/.claude/settings.local.json with no permissions.defaultMode. claude-agent-acp then takes the starting mode from the user's own settings, so "defaultMode": "auto" in ~/.claude/settings.json starts the Crew session in auto. In auto, Claude's classifier approves tool calls, and an approved call sends no session/request_permission (docs/system-specs/modules/claude-code-provider.md, "What Crew gates on this harness"). Crew's deny rules, sensitive-path checks, approval card and SEL decision record never see it. A bypassPermissions there does the same for every call.

A resumed session starts in the mode its transcript was left in, so a session that ran in auto comes back in auto.

The spec says a session opens past the asking mode "only on purpose", and nothing in Crew asked for it here. The host contract's Auto mode row on main reads "a session that carries Crew's tools and starts in bypassPermissions or auto without Crew asking for it is pinned to default before its first prompt, and stopped if the pin fails" (docs/system-specs/modules/agent-host-contract.md), but _pin_claude_starting_mode does that only on the project-owned-file path and on Side Chat.

Why it matters

Anyone whose own Claude Code default is auto or bypassPermissions and who selects the claude backend has every Crew claude session that carries Crew's tools and is neither on the exclusion path nor a Side Chat (chat, subagent, cron, crew member) decided by Claude instead of Crew: in auto for every call the classifier approves, in bypassPermissions for every call. No Crew setting changes that. The unasked-call audit does not record these calls either: it runs only when Crew itself requested auto.

Not a goal

  • Mapping Crew's trust or YOLO approval modes to a Claude permission mode. Those still answer the requests Claude sends.
  • Moving a user's plan or acceptEdits. The pin moves only the modes that approve calls without asking Crew (auto, bypassPermissions), as on the exclusion path today. acceptEdits approves the file edits it covers without asking, and a user auto on a model without Auto support starts in acceptEdits, where edits under the work dir run without asking Crew. Moving it would override a posture the user chose, and is a separate change.
  • A session without Crew's MCP array, such as a "tools": [] helper or a session whose array was withheld. test_a_session_without_crews_array_gains_no_pin records "No Crew tools, no pin: the adapter's own mode is left alone", and this change keeps that decision; its built-in calls still run unasked under a user auto. Whether such a session should be pinned too is a question for a maintainer, because it reverses that recorded decision.
  • A mode change after the first prompt, for example leaving plan through ExitPlanMode.
  • Adapters below 0.84.0, or ones that report no version. They keep today's behaviour.
  • Making Crew's own auto opt-in start in auto. On claude-agent-acp 0.97.0 and 0.100.0 the SDK drops an auto that comes from the local tier, so KIROCREW_CC_PERMISSION_MODE=auto starts a new session in default, before and after this change. That is claude backend: KIROCREW_CC_PERMISSION_MODE=auto starts the session in default mode, and turns off the user's own auto #30169.
  • Deferring to a user's own auto or bypassPermissions in a Crew session. claude_code: do not silently write .claude/settings.local.json; let users add models to availableModels #24870 asks Crew to write less into settings.local.json; this change writes nothing new there, and it moves only the two modes that skip Crew's gate.
  • permissions.allow rules inherited from ~/.claude, the rest of the spec's "Known gap: the user's global ~/.claude is inherited".

What changed (motivation → approach → change)

Symptom: a claude session that carries Crew's tools and requested no mode starts in the user's own auto or bypassPermissions, on session/new and on session/load. Root cause: the seed omits defaultMode when nothing was requested, so the user's settings and the transcript choose the mode, and _pin_claude_starting_mode reads the mode only on the exclusion path and Side Chat. Both are still true on main at a3a737b65.

Approach: a maintainer asked that today's behaviour stay the default, so the broader pin is an operator opt-in in the style of KIROCREW_CC_PERMISSION_MODE: the environment variable KIROCREW_CC_PIN_INHERITED_MODE, declared as CC_PIN_INHERITED_MODE_ENV and resolved by resolve_cc_pin_inherited_mode() in agent_sdk/backends_models.py (re-exported from agent_sdk/backends.py). 1, true, yes or on turns it on; anything else leaves it off, and a value that is not 0, false, no or off logs a WARNING. Like that lever it has no config key and no Settings row. The pin reads it when a session starts.

Setting off (the default): the pin returns at its first check for every session that is not on the exclusion path, a Side Chat or a zero-tool spec, as on main, and those three keep main's behaviour.

Setting on: the pin also runs on every other claude session that carries Crew's MCP array, after session/new and a successful session/load. It reads that from the array the start sent (_mcp_mount_servers), so it projects nothing on the event loop. auto, bypassPermissions or no reported mode gets session/set_mode default before the first prompt, unless it is the mode Crew requested (never kept on Side Chat or the exclusion path); a failed call stops the session. A session this brings in on an adapter below CLAUDE_ACP_SETTING_SOURCES_MIN_VERSION, or with no reported version, is left as it started. The same call and stop have run on the exclusion path since #14981 and on Side Chat since #19059, and the adapter reports the mode on 0.84.0, 0.94.0, 0.97.0 and 0.100.0 (test/fixtures/claude_mode_pin/, test/fixtures/acp_frames/claude/session.jsonl, Manual verification).

No pin on main is reversed: test_a_crew_authored_session_is_not_pinned stays, now on both paths, and the spec's "The pin runs only on this path and on a Side Chat session" and "Known gap: the user's global ~/.claude is inherited" stay true by default, each followed by what the setting changes.

Docs: comments and docstrings that described the broader pin as the rule now name the setting (the pin, the seed writer, client_class.py, resolve_cc_permission_mode, the mirror ruling in providers/mirrors/claude_code.py); backends_routing.py, types.py and the unrecognised-mode warning are reworded to hold in both states. configuration.md gains a row for the setting, and its KIROCREW_CC_PERMISSION_MODE audit caveat is corrected: a classifier-approved call skips Crew's tool-call hook and permission-decision record and gets a tool_invocation record only after it finishes (_maybe_audit_unasked_tool_call). claude-code-provider.md, agent-host-contract.md (its Auto mode row now names which sessions are pinned by default and which the setting adds) and acp-client.md (which said the seed writes defaultMode: default) describe both states. The same note in agent_sdk/tool_gate.py is left for a maintainer, because it is a sensitive path.

Backwards compatibility

Compatible: with KIROCREW_CC_PIN_INHERITED_MODE unset, the default, no session changes behaviour, and no key, field or value main accepts is rejected; no seed byte changes.

Log text: the WARNING the pin logs and the error a failed pin raises now say the mode approves calls without asking Crew's gate or was not reported, instead of "while carrying Crew's tools", and the KIROCREW_CC_PERMISSION_MODE unrecognised-value warning says the session runs as if no mode was requested. Both pin messages can appear by default only on the exclusion path and Side Chat, where they appear on main.

With the setting on, on claude-agent-acp 0.84.0 or newer: a claude session that carries Crew's tools and whose start response names auto, bypassPermissions or no mode, other than the mode Crew requested, gets session/set_mode default before its first prompt, and is stopped if that call fails. A failed start is retried once with a new process, as any start failure is; the resume id is consumed on the first attempt, so a resumed session whose pin fails comes back as a new conversation, as on the exclusion path today. An adapter that one day reports no modes and also refuses session/set_mode would stop these sessions. A session that starts in default, plan or acceptEdits, or carries no Crew MCP array, gains no call. Such an operator's Crew claude sessions then ask Crew about each call no rule decides: a dashboard chat in normal approval shows a card, and a cron without approval_mode: auto meets the same request. Crew's own trust approval, or approval_mode: auto on the cron, approves those calls without asking; Crew's deny rules still apply. An opt-in session that starts or resumes in auto keeps it; one that starts or resumes in bypassPermissions, or reports no mode, is moved to default.

Removes nothing: no key, record, path or public function is removed; the change adds one environment variable, off by default, and one resolver.

Tests

Driven by the recorded claude-agent-acp 0.84.0 answers in test/fixtures/claude_mode_pin/. The pin on a session that carries Crew's tools and is neither excluded nor a Side Chat is tested in a new module, test/test_acp_claude_mode_pin_seam.py, so the seam module stays under the 1,600-line target. The recorded transports it shares with the seam module (_pin_harness, _recorded_results, _adapter_transport) move into test/acp_session_mcp_helpers.py as plain functions; only the cls argument of _adapter_transport is dropped. The helpers module also gains no_ambient_pin_setting, an autouse fixture both pin modules import, which clears KIROCREW_CC_PIN_INHERITED_MODE so the test host's environment cannot decide a result, and spells the variable's name as configuration.md documents it.

test/test_acp_claude_mode_pin_seam.py::TestUnrequestedModePin runs with the setting on (a class fixture sets it to 1):

  • test_a_crew_authored_session_is_pinned_off_an_approving_mode (auto and bypassPermissions, on session/new and session/load): the seed names no defaultMode, one session/set_mode default is sent, and the session keeps Crew's MCP array.
  • test_a_crew_authored_session_in_a_mode_that_asks_gains_no_call (default, plan, acceptEdits, dontAsk, both paths): no session/set_mode.
  • test_a_crew_authored_session_that_reports_no_mode_is_pinned: a response with no modes is pinned.
  • test_a_failed_pin_stops_a_crew_authored_session: a failing session/set_mode stops the harness.
  • test_a_load_that_did_not_take_is_pinned_once_on_the_new_session: a session/load with no modes falls through to session/new, which is pinned once.
  • test_a_failed_pin_on_a_resumed_session_is_not_taken_for_a_failed_load: a failed pin after a load stops the harness and sends no session/new.
  • test_the_deny_re_read_stays_on_the_exclusion_path: a checked-in project deny rule does not stop a session whose file Crew wrote.
  • test_an_opt_in_session_that_starts_or_resumes_in_bypass_is_pinned (both paths): the opt-in keeps auto only, so a requested auto that reports bypassPermissions is pinned.
  • test_a_crew_opt_in_mode_is_not_overridden (moved, now on both paths): a requested auto that starts in auto is not pinned.
  • test_the_pin_does_not_project_the_array_again (both paths): through the real start, the projection cache is cold when the pin runs, and the pin makes no projection of its own.
  • test_a_sent_array_is_pinned_though_a_new_projection_withholds_it (both paths): a session that sent Crew's array is pinned even when any later projection returns no servers.

test/test_acp_claude_mode_pin_seam.py::TestUnrequestedModeKeptByDefault runs with the setting off:

  • test_a_user_auto_start_with_crews_array_is_not_pinned (both paths), the case the review asked for: a user ~/.claude defaultMode: auto, Crew's MCP array sent on the wire, no requested mode. No session/set_mode is sent and the session is not stopped.
  • test_the_setting_reaches_the_pin_from_its_env_var (1, true and On padded with spaces pin; 0, off and 2 do not): the value in the environment at the start decides whether a user auto start is pinned.

test/test_acp_claude_mode_pin_seam.py::TestResolveCcPinInheritedMode: the variable has its documented name; unset is off with no warning; 1, true, TRUE, yes, on and 1 padded with a space and a newline are on; empty, 0, false, no and off are off with no warning; 2, enabled, auto and default are off and logged with the variable's name.

In test/test_acp_session_mcp_client_seam.py::TestClientSeam:

  • test_a_crew_authored_session_is_not_pinned (main's test, now on session/new and session/load): with the setting unset, a session whose file Crew wrote keeps a user bypassPermissions and gains no session/set_mode.
  • test_a_side_chat_opt_in_is_still_pinned: a Side Chat session is pinned even with auto requested.
  • test_an_adapter_below_the_floor_is_not_pinned (both paths, setting on): 0.83.0 and an unreported version keep today's behaviour and are not stopped.
  • test_a_session_without_crews_array_gains_no_pin (both paths, setting on and off): a session with no Crew MCP array keeps the adapter's mode.

A mutation check of the pin and the resolver killed all 19 mutants against these three modules and test_claude_zero_tools.py: ignoring the setting either way, any non-empty value turning it on, no trimming or lower-casing, no warning, a warning on a falsy value, and the 13 pin mutants of the previous round.

Determinism: the changed tests (60 ids) passed 20 runs at -n0, 10 runs at -n 4 --dist loadgroup --max-worker-restart=2 beside test_acp_session_mcp_client_seam.py and test_acp_session_mcp.py, and one shuffled order (seed 21983, 60 ids).

Gate proof: tree 54ddafb98af8; ran 24; skipped none

Proof: PROVEN test/test_acp_claude_mode_pin_seam.py::TestUnrequestedModePin::test_a_crew_authored_session_is_pinned_off_an_approving_mode[new-auto], test/test_acp_claude_mode_pin_seam.py::TestUnrequestedModePin::test_a_crew_authored_session_is_pinned_off_an_approving_mode[new-bypassPermissions], test/test_acp_claude_mode_pin_seam.py::TestUnrequestedModePin::test_a_crew_authored_session_is_pinned_off_an_approving_mode[load-auto], test/test_acp_claude_mode_pin_seam.py::TestUnrequestedModePin::test_a_crew_authored_session_is_pinned_off_an_approving_mode[load-bypassPermissions], test/test_acp_claude_mode_pin_seam.py::TestUnrequestedModePin::test_a_crew_authored_session_that_reports_no_mode_is_pinned (head 8f4cc5e)

Manual verification

Tested against claude-agent-acp 0.84.0, 0.90.0, 0.97.0 and 0.100.0 (Claude Code CLI 2.1.318 on 0.100.0). Each case used a fresh CLAUDE_CONFIG_DIR whose settings.json held only the case's permissions.defaultMode, model, env.AWS_REGION and the credential export. Where a prompt ran, it asked for one Bash call that writes a file in the session's temp directory.

This revision, Crew's own AcpClient on 0.100.0 through ensure_ready(), over main at 4194602e6, user auto, no requested mode, an agent spec with one stdio MCP server, session/new, no prompt:

  • KIROCREW_CC_PIN_INHERITED_MODE unset: seed {}, session/new carried kirocrew-core, kirocrew-cron and the stdio server, the adapter reported auto, no session/set_mode was sent, and the start completed. This is main's behaviour.
  • KIROCREW_CC_PIN_INHERITED_MODE=1: the same start, and the projection cache was cold when the pin ran; Crew logged the WARNING pin line, sent session/set_mode default, and the start completed.

The runs below were made on earlier revisions of this change, where the broader pin ran by default. That is the code path the setting now turns on, so "the broader pin" below means this change with the setting on.

Raw adapter over stdio on 0.84.0, 0.90.0 and 0.97.0, _meta.claudeCode.options {}, the same results on all three versions:

  • User auto, session/new, {} in settings.local.json (the seed shape with no request): modes.currentModeId was auto, and the Bash call ran with no session/request_permission.
  • session/load of that transcript, same {} seed: reported auto. After session/set_mode default (answered {}, then a config_option_update naming default), the next Bash call raised session/request_permission.
  • User bypassPermissions, session/new, {} seed on 0.84.0 and 0.90.0 (no seed file on 0.97.0): started in bypassPermissions and the call ran unasked; session/set_mode default answered {}, and the next call raised session/request_permission.

Crew's own AcpClient on 0.97.0, real _spawn() and _initialize_session(), no prompt, the broader pin:

  • User auto, no requested mode: wrote {}, logged the WARNING pin line, sent session/set_mode default (answered {}), stayed up, and the adapter then reported default.
  • User plan, no requested mode: no session/set_mode, stayed in plan.
  • auto requested, user default or user auto: seeded defaultMode: auto, the session started in default, and no session/set_mode was sent.

Crew's own AcpClient on 0.100.0, through ensure_ready() and send_message(), user auto, and an agent spec with one stdio MCP server, so session/new carried Crew's MCP array (kirocrew-core, kirocrew-cron and that server):

  • Main at e33330f8f (and before at 4a546774f), no requested mode: seed {}, session/new reported auto, no session/set_mode was sent, and the Bash write ran with no session/request_permission. The file was written.
  • The broader pin, no requested mode: seed {}, session/new reported auto, Crew logged the WARNING pin line and sent session/set_mode default (answered {}, then a config_option_update naming default). The Bash write then raised session/request_permission, and Crew's gate refused it (no approver in that run), so the file was not written. Run three times with the same result.
  • The broader pin, no requested mode, session/load of the transcript main had just left in auto: the load reported auto, Crew sent session/set_mode default, and the Bash write raised session/request_permission. A second load of the same transcript, with no prompt and with the user tier changed to defaultMode: default, still reported auto, so a loaded session takes its mode from the transcript, not from the user's settings.
  • The broader pin, KIROCREW_CC_PERMISSION_MODE=auto, session/new: seed defaultMode: auto, the session started in default (the SDK drops a local-tier auto, see Not a goal), no session/set_mode was sent, and the Bash write raised session/request_permission.
  • The broader pin, KIROCREW_CC_PERMISSION_MODE=auto, session/load of a transcript main had left in auto: the load reported auto, the mode Crew requested, so no session/set_mode was sent, and the Bash write ran with no session/request_permission.

Related Issues

Part of #29909

This no longer closes #29909 by default. A maintainer asked that a session with no requested mode keep starting and staying in the mode the user's own settings or its transcript name, so the default stays as on main, and the fix reaches only operators who turn on KIROCREW_CC_PIN_INHERITED_MODE. Whether #29909 should stay open for the default, or be closed as answered by the setting, is a maintainer's call.

Related: #12743 (open: no host check before a classifier-approved call in a session that opts in to auto), #12692 (with no opt-in the seed writes no defaultMode), #14981 (the read-back on the exclusion path), #19059 (the read-back on Side Chat), #24870 (open: write less into settings.local.json; this change writes nothing new there).

Overlap: #30093 (merged) changed _pin_claude_starting_mode too; this change is rebased on it and keeps its zero-tool floor stop and its no-pin return. #26459 (open) also edits that function. #30226 (open, applies a requested auto with session/set_mode) conflicts with this change in agent-host-contract.md, client_claude_seed.py, client_claude_session.py and configuration.md; each conflict is textual, so whichever lands second needs a rebase. #30226 asked to merge after this change because this change re-pinned a resumed session; with the setting off by default it no longer does that by default (see #30226).

Question for a maintainer: should a session that carries no Crew MCP array, or one on an adapter that reports no version, be pinned too when the setting is on? Both are left as they start (Not a goal), which keeps the recorded decision in test_a_session_without_crews_array_gains_no_pin.

Sibling sweep

Swept: git grep -nE "_verify_goose_routing(|_pin_claude_starting_mode(|_verify_opencode_routing|seeded_setting_issue(|ACP_BACKEND_FORBIDDEN_MODES" -- src/kiro_crew/acp
Sibling: src/kiro_crew/acp/client_claude_session.py -- changed here
Sibling: src/kiro_crew/acp/client_permissions.py -- not affected -- _verify_goose_routing reads goose's mode back after every session/new and session/load, and _tripwire_session_config stops a session that reports a mode in ACP_BACKEND_FORBIDDEN_MODES (copilot's autopilot)
Sibling: src/kiro_crew/acp/harness/opencode.py -- not affected -- _verify_opencode_routing reads the harness's resolved permission config back on every session

Pattern harvest

Rule candidate: review-prompt
Pattern: a harness permission mode Crew does not set comes from the user's own config or a resumed transcript; reading the reported mode back on every session, instead of trusting an omitted settings key, is the check, and turning it on where users did not ask for it needs an opt-in.

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: ...)
  • 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

@github-actions github-actions Bot added the fork Pull request from a fork (external contributor) label Nov 5, 2026
@shubhamkurkure

Copy link
Copy Markdown
Contributor Author

Merge order: please merge this before #30226 (the fix for #30169). #30226 lets a session that asked for auto reach it, and this PR is what moves a resumed session back out of auto when it did not ask for it.

The two PRs touch the same docstring field list in client_claude_session.py, so whichever merges second needs a one-line rebase, which I will do.

@github-actions github-actions Bot added the readiness: action required A blocking check or review needs attention label Nov 5, 2026

@bolichen97 bolichen97 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requesting changes on fbb78ba for one blocking point. CI has not run yet on this head (the fork workflows are waiting for approval), so I read the whole diff and checked what it changes against main.

The change moves claude sessions out of the mode they start in today, for people who did not ask for it.

On main, _pin_claude_starting_mode only runs on the exclusion path, on a Side Chat session and for a zero-tool spec. Any other claude session starts in whatever mode the user's own settings name, for example a defaultMode: auto in ~/.claude, and keeps it. With this PR the pin also runs on every session whose start sent Crew's MCP array. If that session reports auto, bypassPermissions or no mode, and Crew did not request that mode, it is sent session/set_mode default. Three behaviors change for existing users:

  • A session that runs in auto today stops running in auto. Its tool calls now go through Crew's permission prompt where they did not before.
  • A session/load is pinned too, so a resumed session loses the mode its transcript was left in.
  • If the pin fails, or the adapter reports no mode and the call fails, the session is stopped with an AcpError. That is a new way for a session that starts today to be refused.

This is added strictness that nobody asked for, so it should not be the default.

Please keep today's behavior when nothing requested a mode: sessions with no requested mode start and stay as they do now. If you want the broader pin, put it behind a setting that is off by default, and have the spec and the tests describe both states. A test that mounts a session with Crew's MCP array, a user auto start and no request, and asserts it is not pinned with the setting off, would pin the default.

The docs edits describe the stricter behavior as if it were already the rule, so they need to follow whichever default you keep. I have no other blocking points yet. I will take a full pass once CI has run.

@shubhamkurkure

Copy link
Copy Markdown
Contributor Author

Thanks for the careful read. I will keep today's behavior as the default: when nothing requested a mode, a session starts and stays in the mode it starts in, on session/new and session/load, and no new stop is added.

The broader pin will move behind a setting that is off by default. The spec, the docs and the tests will describe both states, including the test you describe: a session that sent Crew's MCP array, a user auto start, no request, and the setting off, is not pinned.

I will push that once it passes the same local gates.

@github-actions

github-actions Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5, fork) — ⏭️ skipped

Revision 8f4cc5ef8e01595b809b8db58b7a2e2b5e36604c touches no user-facing surface (no changes under website/ or committed screenshots), so the UX review was skipped. Does not block merge.

@github-actions

github-actions Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5, fork) — ✅ PASS

Design-level review of 8f4cc5ef8e01595b809b8db58b7a2e2b5e36604c via the fork AI-review pipeline — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

No design-level blocker: the setting is off by default and adds no new mechanism, only reusing the existing session/set_mode pin and stop. With it unset, every path follows main.

Notes

  • The opt-in only closes the gate bypass for operators who already know about it. Anyone with a user-level defaultMode: auto who never sets KIROCREW_CC_PIN_INHERITED_MODE still runs Crew-tooled sessions ungated. That is a deliberate maintainer call, not a defect, but it is worth tracking a follow-up to make the pin the default.

[DESIGN-REVIEWED] 8f4cc5e

Description read

[DESCRIPTION-READ] 4857025d9bccdc684bc4c15f97201b4d10a872857b71095e15a3baa62a5f4284

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 5, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5, fork) — ✅ PASS

Premise-level review of 8f4cc5ef8e01595b809b8db58b7a2e2b5e36604c via the fork AI-review pipeline — 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: the new pin is off by default, the pins on main are kept, and the opt-in test moved rather than being deleted. One overlap with an existing helper and a fix: label on what is an addition are notes only.

Notes

  • Item 1 — inherited: the title says "fix", but the Goal is "a new setting … off by default, and with it off every session behaves as on main". That makes this an opt-in addition. The one reason given for keeping it off ("a maintainer asked that today's behaviour stay the default") has no linked issue or comment.
  • Item 2 — duplicate of src/kiro_crew/constants.py:239 (env_flag_enabled), which already does the truthy env read. Only the warn-on-unrecognised branch is new. Subtraction: make resolve_cc_pin_inherited_mode return env_flag_enabled(CC_PIN_INHERITED_MODE_ENV) and drop the custom parse.

What this change ships

Inventory (6 items) — 4 justified

Intent: let an operator stop Claude sessions that carry Crew's tools from starting in auto/bypassPermissions that Crew never asked for. This is an ADDITION (framed as a FIX).

  1. New env var KIROCREW_CC_PIN_INHERITED_MODE; when on, new and resumed tool-carrying sessions are moved to default before the first prompt — inherited (framed as a fix)
  2. Unrecognised values of the setting log a WARNING — duplicate of constants.env_flag_enabled, apart from the warning
  3. With the setting on, a session that asked for auto keeps it, unless it resumes in bypassPermissions — justified
  4. With the setting on, an adapter below 0.84.0 or one that reports no version is left alone instead of stopped — justified
  5. Pin warning and failure error text reworded — justified
  6. Specs, configuration.md row, and the corrected KIROCREW_CC_PERMISSION_MODE audit caveat — justified

[FIRST-PRINCIPLES-REVIEWED] 8f4cc5e

Description read

[DESCRIPTION-READ] 2908cc4b4fdb224dd820046ad8d2cd45f3f77f337063e40bc40878b13014c925

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 5, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review (fork) — ✅ no blocking findings

Reviewed 8f4cc5ef8e01595b809b8db58b7a2e2b5e36604c via the fork AI-review pipeline; updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 8f4cc5e

@github-actions

github-actions Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review (fork) — ✅ no blocking findings

Reviewed 8f4cc5ef8e01595b809b8db58b7a2e2b5e36604c via the fork AI-review pipeline; updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 8f4cc5e

@shubhamkurkure

Copy link
Copy Markdown
Contributor Author

@bolichen97 I pushed the change you asked for (head 5d1983569).

The default is now today's behaviour: with nothing requested, a session starts and stays in the mode it starts in, on session/new and session/load, and there is no new stop. The broader pin runs only when KIROCREW_CC_PIN_INHERITED_MODE is set to 1, true, yes or on. It is an env var only, like the existing KIROCREW_CC_PERMISSION_MODE lever, which has no config key or Settings row either. An unrecognised value is off and logs a warning.

Your test is TestUnrequestedModeKeptByDefault::test_a_user_auto_start_with_crews_array_is_not_pinned[new|load]: Crew's MCP array sent, a user auto start, no request, setting off, so no session/set_mode and no stop. Main's test_a_crew_authored_session_is_not_pinned is restored on both paths, and all the earlier pin tests now run with the setting on.

The spec, the host contract, acp-client.md and configuration.md describe both states, and the Known gap text stays true by default. The issue line is now Part of #29909. I changed the Goal line and the title to match, because you asked for the opt-in; that is the only reason they moved.

@shubhamkurkure shubhamkurkure changed the title fix(acp): move claude sessions that request no mode out of auto fix(acp): add an opt-in to move unrequested claude sessions out of auto Nov 5, 2026
@shubhamkurkure
shubhamkurkure force-pushed the fix/claude-pin-unrequested-mode branch from fbb78ba to 5d19835 Compare November 5, 2026 15:23
@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 5, 2026

@bolichen97 bolichen97 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, the opt-in setting is what I asked for. KIROCREW_CC_PIN_INHERITED_MODE is off by default, the old behavior stays for everyone who does not turn it on, and the tests cover both states. One small blocking point is left at 5d19835: two required checks are red on it for the same reason, and I confirmed it in the diff.

test/test_acp_claude_mode_pin_seam.py, the _setting_on fixture

_setting_on(self, monkeypatch, no_ambient_pin_setting) is an autouse fixture that requests the shared monkeypatch. The repository's determinism rule forbids a newly added autouse fixture that takes the shared monkeypatch, and the diff-only Semgrep scan reports it as an error (the SAST check is red), and the GPT 6.1 Review check blocks on the same line.

Fix: request _floor_monkeypatch instead of monkeypatch and use it for the setenv call, the way the other autouse fixtures in this PR already do (the conftest changes in this diff use it).

Everything else I read looks right to me. CI is still running on this head, so I have not judged the test results yet. I will approve once these two checks are green and the shards pass.

@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 5, 2026
@shubhamkurkure
shubhamkurkure force-pushed the fix/claude-pin-unrequested-mode branch from 5d19835 to 0db2050 Compare November 5, 2026 17:51
@shubhamkurkure

Copy link
Copy Markdown
Contributor Author

@bolichen97 Fixed in 0db2050c9: _setting_on now requests _floor_monkeypatch and uses it for the setenv, like the other autouse fixtures in this PR. It was the only new autouse fixture that took the shared monkeypatch. The branch is rebased on current main. The pin tests and the related set pass locally (742 passed), and the pre-push gate and prove.py are green on this tree.

@github-actions github-actions Bot added the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Nov 5, 2026
@shubhamkurkure
shubhamkurkure force-pushed the fix/claude-pin-unrequested-mode branch from 0db2050 to a5b9b87 Compare November 5, 2026 18:34
@github-actions github-actions Bot removed the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Nov 5, 2026
@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 5, 2026
@github-actions github-actions Bot added the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Nov 5, 2026
A claude session that requests no permission mode gets a seed with no
permissions.defaultMode, so claude-agent-acp starts it in the mode the
user's own settings name. With defaultMode auto or bypassPermissions in
~/.claude, tool calls run without session/request_permission and never
reach Crew's gate. A resumed session starts in the mode its transcript
was left in, so it comes back the same way.

The default stays as it is: _pin_claude_starting_mode reads the
starting mode back only on the project-owned-file path and on Side
Chat, and every other session keeps the mode it started in.

KIROCREW_CC_PIN_INHERITED_MODE, off by default and resolved by
resolve_cc_pin_inherited_mode, extends the pin to every other claude
session whose start sent Crew's MCP array, after session/new and after
session/load. An auto, bypassPermissions or unreported mode is moved to
default before the first prompt, and a failed pin stops the session.
plan and acceptEdits are kept, and so is a reported mode that is the
one Crew requested. A session that sent no Crew MCP array keeps the
adapter's mode. A truthy value turns the setting on; any other value
leaves it off, and one that is not a falsy spelling logs a warning.

With the setting on, the pin reads the array the start sent, not a new
projection: the re-seed after the start clears the projection cache,
and projecting again would read the spec and settings files on the
event loop. A session the setting brings in on an adapter below
CLAUDE_ACP_SETTING_SOURCES_MIN_VERSION, or one that reports no version,
keeps the mode it started in. The seed bytes are unchanged.
@shubhamkurkure
shubhamkurkure force-pushed the fix/claude-pin-unrequested-mode branch from a5b9b87 to 8f4cc5e Compare November 5, 2026 23:06
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running and removed merge conflict Branch has merge conflicts with its base — author must resolve before merge readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention labels Nov 5, 2026

@bolichen97 bolichen97 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving 8f4cc5e. Both points from my earlier reviews are fixed.

What I checked on this head:

  • The pin of an inherited starting mode is now behind KIROCREW_CC_PIN_INHERITED_MODE, which is off by default. A session that asked for no mode keeps the mode it starts in today. The default behavior is not tightened.
  • The pin on the exclusion path and on a Side Chat session is unchanged, and the pin only moves auto or bypassPermissions to default.
  • The seam tests run with the setting both on and off, and the shared monkeypatch problem in the autouse fixture is gone (it uses its own _floor_monkeypatch now).
  • The docs (acp client, agent host contract, claude code provider, configuration) describe the off-by-default setting and the default behavior.
  • A scan of the added lines for re.compile, re.search, re.match, re.sub, re.findall and RegExp finds none.
  • This head is a rebase onto current main. Fork CI ran on it: E2E, Integration, Coverage Combine and Coverage Gate passed, all 8 backend shards and the frontend shards passed, and 0 checks are red. Only PR Readiness is still pending, and it waits on Issue Gate.

Auto-merge is set to wait for PR Readiness.

@bolichen97
bolichen97 enabled auto-merge (squash) November 6, 2026 03:29
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention labels Nov 6, 2026
@bolichen97
bolichen97 merged commit 1e990f8 into kirodotdev:main Nov 6, 2026
102 of 103 checks passed
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Nov 6, 2026
@LuisBrel LuisBrel mentioned this pull request Nov 6, 2026
5 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fork Pull request from a fork (external contributor)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

claude backend: a session that requests no permission mode starts in the user's own ~/.claude defaultMode, so auto skips Crew's gate

2 participants