Repository navigation
fix(claude): name the offered model when an adopted one is refused after a restart (#40424) - #40429
Conversation
UX Review (Opus 5.5) — ⏭️ skippedRevision |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of 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 shipsInventory (4 items) — 4 justifiedIntent: A Claude chat whose adopted model is now refused starts on the offered model after a restart instead of failing to start. FIX.
[FIRST-PRINCIPLES-REVIEWED] 0438f2f Description read[DESCRIPTION-READ] 100feda998c1b1dbc76e56aee1649823b5259af74cf15b1476b505024f07477c That sha256 names the PR description this verdict read. Recompute it with |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of 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 |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
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
What changed (motivation → approach → change)
This is a pick of #40424 onto
release/0.13.0for the next 0.13 build: one commit,git cherry-pick -xof main'sc2b4f1ce783e. 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 ofdocs/system-specs/modules/claude-code-provider.mdsay 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.test_acp_client_model_substitution.py,test_claude_shared_runtime.pyandtest_client_bindings.pypass (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/newreplies 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.