Repository navigation
fix: keep the run's model and effort on a continuation - #19006
Conversation
UX Review (Opus 5.5, fork) — ⏭️ skippedRevision |
Design Review (Opus 5.5, fork) — ✅ PASSDesign-level review of Design-Verdict: PASS Before merge, check that reviewers read the description's "What changed" note: the two frozen "Not a goal" bullets describe the previous head and contradict this code. [DESIGN-REVIEWED] d5f1d1f Description read[DESCRIPTION-READ] 666c7496c71516c1ddf41955c5593f298f24d6839d5a780d947ac4dcef7fd510 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) — 🟡 CONCERNSPremise-level review of First-Principles-Verdict: CONCERNS Continuations now inherit the spawn's model and effort, which reverses the spec's "NOT inherited by Not justified as shipped
What this change shipsInventory (5 items) — 4 justifiedIntent: a follow-up turn on a pinned sub-agent run stays on that run's model and effort. FIX.
[FIRST-PRINCIPLES-REVIEWED] d5f1d1f Description read[DESCRIPTION-READ] 9bb26288caafff0f5131e3bdec0519abae50ad9d970d2b38cb16985898ebcfdf That sha256 names the PR description this verdict read. Recompute it with |
GPT 6.1 Review (fork) — ✅ no blocking findingsReviewed Review detailsNo findings. |
Opus 5.5 Review (fork) — ✅ no blocking findingsReviewed Review detailsAdvisory finding only: a follow-up to a continuation that named a different model goes back to the first run's model. FINDING — src/kiro_crew/subagent_manager/continuation.py:681 — [OPUS-REVIEWED] d5f1d1f |
22fec18 to
610bc26
Compare
610bc26 to
3208427
Compare
3208427 to
ac69ef8
Compare
|
Rebased onto main (65df088). The one conflict was the The four new tests in |
iamwhatever
left a comment
There was a problem hiding this comment.
This makes spawn_continue, spawn_steer follow-ups and post-restart continuations reuse the run's model and reasoning effort. The root cause, _continue_prelude_impl carrying neither, is real, and the in-memory path is right. The restart path reads a different source, though. In memory, the continuation keeps original.model, which is only the caller's pin. After a restart, continuation.py (the new recorded.get("requested_model") branch) reads requested_model, which run.py:2245 writes as eff_model or "auto". That value already includes the agent.role_models['subagent'] pin and any model.route derived tier, and the continuation passes it on as an explicit per-call model. Risk: after one restart, a run spawned under a role pin or a routed tier freezes that model as a caller pin, so a later change to the role pin never reaches that run again, while the same run without a restart follows the new pin. This is the Design CONCERNS on ac69ef8, and it has no reply. Fix: record the caller's own pin (info.model) in the provenance write in run.py:2600 next to reasoning_effort, and read that field after a restart instead of requested_model. Second, the effort is still carried when the caller names a different model, and the First Principles CONCERNS on that is also unanswered. The accepted rfc-worker-model-inheritance rule 4 says effort follows the model, and your own Goal line says "unless the caller names others". Pass reasoning_effort=run_effort only when model came from the run, and "" otherwise. Please update the matching spec sentence in subagent.md and add one test for each case. — crew-pr-reviewer (deep re-check)
A continuation (spawn_continue without a model, a spawn_steer follow-up, a resume after a gateway restart) requested no model and no reasoning effort, so it ran on the role or provider default instead of the model and effort the run was spawned with. The continuation prelude keeps the model the caller pinned at spawn unless the caller names one, and keeps the run's reasoning effort only with it: effort follows the model, so a caller that names a model gets that model's own effort resolution. A run still in memory supplies its per-spawn model and effort; after a restart they come from state.json, where the crash-safe spawn write records the caller's own pin as pinned_model beside the per-spawn effort. A restart reads pinned_model rather than requested_model, the effective pin, which also holds the sub-agent role pin and a routed tier: those resolve again for the continuation, as they do for a run still in memory. The spec sentence that said a continuation resolves effort fresh (role pin, else default) describes the inherited behavior instead.
ac69ef8 to
d5f1d1f
Compare
|
Both points are fixed in the amended commit, rebased onto main (365d87c). Restart reads a different model source (Design CONCERNS). The spawn's provenance write now also records the caller's own pin, Effort carried over a named model (First Principles CONCERNS). The prelude now passes The two |
iamwhatever
left a comment
There was a problem hiding this comment.
This makes spawn_continue, spawn_steer follow-ups and post-restart continuations reuse the run's model and effort by resolving them in _continue_prelude_impl, the one prelude every continuation path goes through, so the root cause is fixed there. Both points from our CHANGES_REQUESTED on ac69ef8 are handled on d5f1d1f. run.py now records the caller's own pin as pinned_model (from info.model), and after a restart the prelude reads that field, not requested_model, so a role pin or a model.route tier is no longer frozen into a pin. I checked that _route_unpinned_start only reads info.model and never writes it, and that info.reasoning_effort is the per-call value (the role effort is applied separately at run.py:4160), so the effort side cannot freeze a role pin either. The effort is now passed only when the caller names no model, which follows rfc-worker-model-inheritance rule 4, and the subagent.md sentence was rewritten to match. Records written before this change have neither field and request neither, as before. The Opus advisory is real but not a defect: original is always the root run, so a bare continuation after one that named model-b goes back to the spawn pin, and the rewritten spec says exactly that ("keeps the model the caller pinned at spawn"), the same way delegation and backend are inherited. Base is main, checks are green, and the new tests cover each case and are shown red on main and on the previous head. — crew-pr-reviewer (deep re-check)
Problem / Motivation
Goal: A continuation of a sub-agent run uses the model and reasoning effort the run was spawned with, unless the caller names others.
A continuation of a sub-agent run requests no model and no reasoning effort, so it runs on the role default (
agent.role_models['subagent']/agent.role_efforts['subagent']) or the provider's default instead of the model and effort the run was spawned with. Every continuation path does this:spawn_continuewithout amodel:_continue_prelude_implhandsspawnthe caller'smodel(None) and noreasoning_effort.spawn_steerfollow-up (mode='follow_up'): the watcher callscontinue_conversation_asyncwith no model, and that call has no effort parameter.state.jsonrecordsrequested_modelat spawn, but the continuation does not read it, and the effort is not recorded at all.Why it matters
A caller that pins a run to
model-aathigheffort gets its follow-up turns from another model at another effort, and nothing in the reply says so. The continuation's own record showsrequested_model="auto". Because "auto" means unpinned, the downgrade warning ("Requested X, served Y") cannot fire for it.Not a goal
Two behaviors reviewers should know, both deliberate:
spawn_continuenames another model.spawn_continuehas no effort parameter, and adding one is not part of this change. Sospawn_continue(model="model-b")on a run spawned athighrunsmodel-bathigh.SubagentInfo.model), not the storedrequested_model. A run whose model came from the role default re-resolves the role default on a continuation, as before. After a gateway restart onlystate.jsonis left, so the continuation uses the storedrequested_model, which is the effective pin and includes a role pin, and skips"auto"(an unpinned run).Also not a goal: carrying the run's backend into a continuation (#18150 does that), or the other per-spawn options the continuation does not carry (
allowed_tools,bare).What changed (motivation → approach → change)
_continue_prelude_implalready inherits the context groups, the delegation and the memory store for that reason, but not the model or the effort.state.json.src/kiro_crew/subagent_manager/continuation.py: the prelude keeps the model the caller pinned at spawn unless the caller names one, and passes the run's reasoning effort only while it keeps that model. A caller that names a model gets that model's own effort resolution (role pin, else default), because effort follows the model (docs/request-for-change/rfc-worker-model-inheritance.md, rule 4). After a restart the pin comes frompinned_model, not fromrequested_model: that is the effective pin and also holdsagent.role_models['subagent']and amodel.routetier, so carrying it would freeze whatever the run happened to resolve, which a run still in memory does not do. On the async paths (spawn_continueover HTTP, the follow-up watcher) the state comes from the snapshot the caller already read off the event loop.src/kiro_crew/subagent_manager/run.py: the crash-safe spawn write that recordsrequested_model/resolved_modelbefore thesubagent_spawnevent also records the caller's own pin aspinned_model(SubagentInfo.model) andreasoning_effort.docs/system-specs/modules/subagent.md: thereasoning_effortentry said a continuation "resolves effort fresh (role pin, else default), the same parity asmodel". That sentence came with the per-call effort parameter in feat: add per-call reasoning_effort parameter to spawn_run (#4725) #4732, whose description names extendingspawn_continueas "follow-up work, not part of this minimal-surface change". It describes the inherited behavior instead, including that a named model carries no effort. No record indocs/decisions/covers continuation model or effort.Not a goalbullets above describe the head this one replaces: the effort no longer carries over a model the caller names, and a restart reads the caller's pin, as the in-memory path does.Backwards compatibility
modelonspawn_continuestill wins, and the effort then resolves for that model, as before this change.pinned_modelnorreasoning_effortin itsstate.json. After a restart its continuation requests no model and no effort, as before this change.Tests
test/test_subagent_continuable.py:model-a/high;read_statepatched) it keeps the recordedpinned_model(model-a) andhigh; a record whose caller pinned nothing requests no model even though itsrequested_modelnames one, and so does a record without the field;agent.role_models['subagent'], in memory and after a restart;follow_up_runfollow-up, dispatched by the watcher, keepsmodel-a/high;model="model-b"is requested and carries no effort, in memory and after a restart.test/test_subagent_provenance_write.py: the spawn's provenance write records the run's effort (high, and""for a run spawned without one) and the caller's own pin aspinned_model(the caller's model,""when the model came from the role pin).-n 0, 3 of 3 serial runs): 8 failed, 232 passed each, the same eight every run: the three continuation tests, the two effort cases and the threepinned_modelcases of the write. The tests that pin what a continuation must not carry (a role pin after a restart, a named model's effort, a record with no caller pin) pass on main, which carries nothing. They fail on the previous head of this PR, which readrequested_modelafter a restart and carried the effort over a named model: with the two files copied onto that head, 8 failed, 232 passed in 3 of 3 runs (the five guards and the threepinned_modelcases).kiro_crew.subagentorsubagent_manager, or namecontinue_conversation,spawn_continue,follow_up_runorpinned_model(minustest/test_service.pyandtest/test_codex_session_mcp.py, which act on the real user home), run together with-n 8: 21526 passed, 14 skipped, 5 xfailed, 2 failed. The two failures,test/test_home_pin_survives_monkeypatch_undo.py::test_the_guard_accepts_a_scratch_home(that run's pytest temp root sat under the data home, which the guard refuses) andtest/test_open_slots_persistence.py::test_cancelled_restore_keeps_the_keys_it_never_read(a restore-timing premise under load), pass when their two files run alone: 144 passed in 3 of 3 runs.The spawn write records
{'requested_model': 'model-req', 'resolved_model': 'model-served'}with no effort and no pin (assert None == 'high',assert None == 'model-req').Manual verification
Not run against a live gateway. The tests drive the real
SubagentManagercontinuation and run code with the mock session manager the continuation tests already use, and read what each continuation asks the provider for fromget_or_create.Screenshots / video
None; no UI change.
Related Issues
No issue found.
continuation.pyandrun.pymerge without a conflict, and_continue_prelude_implnow carries the backend from feat(subagents): let spawn_run pick the backend a sub-agent runs on #18150 and the model and effort from this PR. Indocs/system-specs/modules/subagent.mdthe branch keeps both lines: this PR's rewritten last sentence of thereasoning_effortbullet, then feat(subagents): let spawn_run pick the backend a sub-agent runs on #18150'sbackendbullet.continue_conversation_implcode shape and does not change main's continuation code.Pattern harvest
Rule candidate: review-prompt
Pattern: a per-spawn option that the continuation prelude (
_continue_prelude_impl) does not carry into the resumed run, so a continuation runs on the default instead of what the run was spawned with.A per-spawn option that the continuation prelude does not carry is one defect class: the backend (#18150), and here the model and the effort. The prelude does not carry
allowed_toolsorbareeither (no match for either in_continue_prelude_impl); they are not examined here.Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement