Skip to content

fix(claude): name the offered model when an adopted one is refused after a restart (#40424) - #40429

Merged
buluoray merged 1 commit into
release/0.13.0from
crew/slack/pick-40424-0.13
Nov 21, 2026
Merged

buluoray merged 1 commit into
release/0.13.0from
crew/slack/pick-40424-0.13

Conversation

@buluoray

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: A Claude chat whose adopted model is refused after a restart starts on the model the policy now offers, instead of failing to start.

A per-chat Claude chat adopted model A in an earlier start. Later the policy refuses A and offers B, while the cached list of advertised models still names A. After the Claude process restarts, the retry named A again from the old list, saw the seed already named A, and gave up without trying B. 0.13 carries this bug through pick #40403 of #40326.

Why it matters

Any Claude chat on a gateway whose model policy tightens while the chat is alive stops starting after its next restart, with no way to fix it from the chat.

Not a goal

  • Changing how the advertised-model list is refreshed.
  • Changing how many times a start is re-sent (still at most twice).

What changed (motivation → approach → change)

This is a pick of #40424 onto release/0.13.0 for the next 0.13 build: one commit, git cherry-pick -x of main's c2b4f1ce783e. It applied with no conflict.

_substitution_retry_model (acp/client_claude_seed.py) now names the offered model when the pin is the model the seed already adopted, whatever the advertised list says. The per-chat client and the shared runtime both use this helper, so both take the same branch. The per-chat docstring and the substitution-retry paragraph of docs/system-specs/modules/claude-code-provider.md say so.

Backwards compatibility

Compatible: a start that worked before names the same model; only a start that used to fail at once now tries the offered model.

Removes nothing: the change adds one branch to a helper and keeps every existing path.

Tests

  • test_acp_client_model_substitution.py::TestSubstitutionFollow::test_a_model_adopted_earlier_and_refused_now_falls_back_to_the_offered_one: per-chat client, cases no cache, cache agrees, cache stale, offered model refused too, adopted model offered again, adopted model still allowed.
  • test_claude_shared_runtime.py::test_a_model_adopted_earlier_and_refused_now_falls_back_to_the_offered_one: the same cases on the shared runtime.
  • On this branch: test_acp_client_model_substitution.py, test_claude_shared_runtime.py and test_client_bindings.py pass (738 passed).

Proof: PROVEN test/test_acp_client_model_substitution.py::TestSubstitutionFollow::test_a_model_adopted_earlier_and_refused_now_falls_back_to_the_offered_one[cache_stale], test/test_acp_client_model_substitution.py::TestSubstitutionFollow::test_a_model_adopted_earlier_and_refused_now_falls_back_to_the_offered_one[offered_refused_too] (head 6a8ed4a)

Manual verification

N/A — unit coverage sufficient: the tests drive the real retry code with stub session/new replies that carry the policy advisory.

Real-machine verification

N/A -- reproducing it needs a live Claude gateway whose organization policy refuses a model mid-session, which no test machine has; the stub tests send the same advisory frames.

Related Issues

Part of #40422

Sibling sweep

Swept: git grep -n "_substitution_retry_model|_adopted_substitute_model" -- src/
Sibling: src/kiro_crew/acp/harness/claude.py -- not affected -- it already fell back to the offered model and now gets the same answer from the shared helper

Pattern harvest

Not generalizable: the defect is one helper trusting a cached list over a refusal that just happened; no other code adopts a model from a policy advisory.

@buluoray
buluoray requested review from a team and KiroCrewCaptain as code owners November 21, 2026 16:24
@buluoray
buluoray requested review from chenmingwei23 and removed request for a team November 21, 2026 16:24
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Nov 21, 2026
@github-actions

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

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

@github-actions

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 0438f2ffbe2b5b3a6124210fdec79bcde5029704 — 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

One branch in the shared retry helper fixes the cause: a stale advertised list was trusted over a fresh refusal. The per-chat client and the shared runtime both use this helper. Nothing rides along.

What this change ships

Inventory (4 items) — 4 justified

Intent: A Claude chat whose adopted model is now refused starts on the offered model after a restart instead of failing to start. FIX.

  1. After a restart, the retry names the offered model instead of re-sending the refused adopted one, even when the cached list still names the adopted model — justified
  2. Spec paragraph on the substitution retry restated to match — justified
  3. Docstrings on _substitution_retry_model and _retry_after_model_substitution restated — justified
  4. Parametrized tests pin the behaviour on the per-chat path and the shared runtime path — justified

[FIRST-PRINCIPLES-REVIEWED] 0438f2f

Description read

[DESCRIPTION-READ] 100feda998c1b1dbc76e56aee1649823b5259af74cf15b1476b505024f07477c

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

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

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

Design-Verdict: PASS

Nothing blocks: the fix sits in the one helper both the per-chat and shared-runtime paths call, so the two paths stay in step, and a start that used to fail now ends on the model the backend offers.

[DESIGN-REVIEWED] 0438f2f

Description read

[DESCRIPTION-READ] a578d3f02732a3e9b7daf42be20fae24afbb2e7a90fb5c0838afb4db8baec87e

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

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

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

Review details

No findings.

[OPUS-REVIEWED] 0438f2f

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

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

@github-actions

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of 0438f2ffbe2b5b3a6124210fdec79bcde5029704 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 0438f2f

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

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Nov 21, 2026
@buluoray
buluoray merged commit f30c85a into release/0.13.0 Nov 21, 2026
90 checks passed
@buluoray
buluoray deleted the crew/slack/pick-40424-0.13 branch November 21, 2026 17:32
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Nov 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant