Repository navigation
fix(kas): start an unpinned kas chat on kiro-cli's chat.defaultModel - #34155
Conversation
KAS reads no cli.json, so an unpinned KAS chat started on KAS's own default instead of the model kiro-cli's chat.defaultModel names. The cold start now reads the setting off the loop and applies it with AcpSessionHandle.set_model(model, inherit=True). An inherited model is served (_resolved_model_id) and marked on the handle (inherited_model, the applied spelling after the KAS fold), but _model stays unpinned, so effort binding, _effort_model and the engine-fallback promotion still read the session as unpinned and nothing persists it into the slot. Any other set_model clears the mark, a promotion clears it, and new_conversation and the MCP re-injection swap carry it. A model that does not land keeps the existing session-start notice. Fixes #33023
UX Review (Opus 5.5) — ⏭️ skippedRevision |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Nothing blocks. Each item addresses issue #33023's gap. The base spec's own shortcut ("Upgrade to carrying it once the pin mark lives with the session handle") already records this as the planned follow-up. What this change shipsInventory (7 items) — 7 justifiedIntent: someone who set a default model in kiro-cli gets that model on unpinned KAS chats in Kiro Crew, without pinning it again. FIX.
[FIRST-PRINCIPLES-REVIEWED] 787d57d Description read[DESCRIPTION-READ] d67f0d51e85bb7837dbef34b98ca1f882d5c4e6d646906b1617d200731c8a757 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 inherited mark sits on the handle, Notes
[DESIGN-REVIEWED] 787d57d Description read[DESCRIPTION-READ] f2bb0989865fcd9aa3fb63ce91f2701de03574ab284082989e58625d8d811a4f 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: |
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
This review checked head 787d57d. The KAS cold start change only runs when the backend is KAS and no model is pinned. set_model(inherit=True) never writes _model, so the code that reads a pin still sees an unpinned session. The mark is cleared on every set_model call and on an engine promotion. The Kiro path does not change. Harness identity is checked positively, the cli.json read stays off the event loop, and acp-client.md is updated in the same commit. PR Readiness is green on this head. Of the two open PRs for #33023, this one should stay, and #34146 can close.
Done well: the mark lives on the session handle and stores the model spelling that was actually applied. The tests pin each writer that clears it, including picking a different model and then picking the same one back.
Optional:
- Add a test where
set_modelraises on the inherit path, both at start and innew_conversation. Then the "not fatal" claim is pinned and so is the notice for a model KAS refuses. - Add a test in test_kas_mcp_live_reinject.py that checks the MCP re-injection swap carries
inherited_modelover. - Under Related Issues, add "Part of #33744" for the
new_conversationrow. That keeps the issue from asking for work this PR already ships.
…f crash-looping (#33802) A home directory copied to another machine can leave kiro-cli's unpacked KAS engine (<data dir>/kas/<version>-<sha>/) without its node_modules. kiro-cli only checks that the directory exists, so every `kiro-cli acp --agent-engine v3` exits with "failed to canonicalize KAS server path: .../acp-server.js" and never re-extracts. Kiro Crew showed a generic process death and the warm pool retried every 30 s forever. The spawn entry now reads that line from a failed start's stderr. When the path sits in kiro-cli's own data dir, <version> is a real directory and the server entry does not resolve, it moves <version> to <data dir>/<version>.kas-broken-<UTC> (outside kas/, which kiro-cli sweeps) and starts once more. Otherwise, or when the second start fails the same way, the provider raises AcpKasExtractBroken, one non-retryable message naming the directory and the mv command, and the warm pool stops respawning until the directory is moved. agent.kas_repair_kiro_cli_extract (default true) turns the move off. A start that succeeds runs none of this. kas_extract_repair.repair is recorded in test/link_screen_sites.py as a site that refuses every link: a symlinked or junctioned kas/<version> is never moved, and os.rename on a real directory follows no link. Closes #33762 Co-authored-by: Raymond Chen <chenmingwei23@users.noreply.github.com> Backport note: release has four fail-closed agent switches, not main's five: agent.conductor_own_child_verbs is unreleased. loader_pipeline.py adds only kas_repair_kiro_cli_extract to release's list, and its comment names it after kas_persist_mcp_sign_in and counts five; test_config_load_pipeline_field_defaults.py adds only that key's row. acp_runtime_start.py keeps release's kas_cli_settings import line (main also imports kiro_cli_default_model there for #34155, unreleased) and adds the AcpKasExtractBroken import. Every other file applies as on main. (cherry picked from commit 2404187)
Problem / Motivation
Goal: A KAS chat with no model pinned in Kiro Crew starts on the model kiro-cli's
chat.defaultModelnames, as it does on kiro-cli.kiro-cli starts a chat on its
cli.jsonchat.defaultModelwhen nothing pins a model. KAS reads nocli.json, so on KAS the same chat starts on KAS's own default (gap P1-37 in the kiro-cli -> KAS migration list). Since #33222 the user only gets a notice naming the setting.Why it matters
Anyone who set a default model in kiro-cli and moved to the KAS engine (Kiro Crew's default backend) silently gets a different model on every unpinned chat, cron and channel session, and has to pin the model again in Crew to get it back.
Not a goal
cli.json(recorded as a shortcut in the spec).agent.modelbehave: they still win over the kiro-cli setting.kas_cli_settings.py.What changed (motivation → approach → change)
Symptom: an unpinned KAS chat runs KAS's default, not
chat.defaultModel. Root cause: Crew never applied the setting, because the three earlier attempts in #33023 all made the inherited model look like a pin (dropping an unpinned reasoning effort) or kept a raw marker on the provider that drifted from what the handle applied.Approach, following the issue's design, with the mark on the handle:
AcpSessionHandle.set_model(model, *, inherit=False). Withinherit=Truethe switch goes through the same KAS spelling fold and served-list resolution as any substitute, then records the applied spelling in_resolved_model_id(soserved_modelreports it) and in a newinherited_modelfield._modelkeeps its unpinned value, so every "is this pinned?" reader (_bind_unbound_effort,_effort_model, the engine-fallback promotion atengine_fallback.py) still answers no, and nothing persists it into a slot. Any otherset_modelcall clears the mark, so picking away and back makes a real pin.acp_runtime_start.py: a KAS cold start whose configured model is empty orautoreadschat.defaultModeloff the loop (asyncio.to_thread, not in the factory) and applies it withinherit=True. If it does not land (not served, or refused), the existing notice from fix(kas): name kiro-cli's chat.defaultModel when a KAS chat does not start on it #33222 names it.engine_fallback.py: a promotion clears the mark, so a fresh conversation does not put back a model the engine moved off.session_provider.pynew_conversation: re-applies an inherited model withinherit=True(a failure leaves KAS's default and is not fatal).session_provider_mcp_reinject.py: the swap carries the mark to the reloaded handle.kas_cli_settings.default_model_noticenow takes the model (the caller already read it) and says the chat could not start on it.docs/system-specs/modules/acp-client.mdsection on kiro-clichat.defaultModelon KAS.Backwards compatibility
Compatible: only a session with no Crew pin on KAS changes, and only when kiro-cli's
cli.jsonnames a model the account serves; every pinned path and every other harness is unchanged, andset_model's new keyword defaults to the old behaviour.Removes nothing: the notice is kept for the case where the inherited model does not land; no key, field or public function is removed.
Tests
test_acp_kas_effort.py: an inherited id is sent under its folded KAS spelling, served, marked, and not pinned; an explicit pick to the same model clears the mark and pins it; an unserved inherit records no mark; an unbound reasoning effort binds to the inherited model; an engine promotion drops the mark.test_acp_provider.py: an unpinned KAS cold start applieschat.defaultModelwithinherit=Trueand records no notice, a pinned or non-KAS start does not; an inherit that does not land records the notice.test_acp_session_provider.py:new_conversationre-applies an inherited model as inherited (the respawn case).test_kas_cli_settings.py: notice andautocases updated to the new signature.test_session_handle_bindings.py:set_modelsignature pin and the owner's written-fields list updated.Proof: PROVEN test/test_acp_kas_effort.py::test_an_engine_promotion_drops_the_inherited_mark, test/test_acp_session_provider.py::TestNewConversation::test_an_inherited_model_is_reapplied_as_inherited, test/test_kas_cli_settings.py::test_the_default_model_notice_names_the_model_and_the_picker, test/test_session_handle_bindings.py::test_each_member_keeps_its_kind_shape_and_owner[set_model] (head 787d57d)
Reproduced on main: with the new tests copied onto a main worktree, 12 fail (set_model takes no
inherit, the cold start never applies the setting,new_conversationre-applies nothing, a promotion keeps the mark). Locally: the 101 related backend test files at-n 2pass, plus black, isort, flake8, mypy, comment-history, brand, harness-parity, line-cap and docs-lint.Manual verification
N/A — not run against a live KAS engine from this host; the handle tests drive the real
AcpSessionHandle.set_modelKAS branch with the config-option write mocked.Related Issues
Fixes #33023
Sibling sweep
Swept: git grep -n -e "set_model(" -e "_model = " -- src/kiro_crew/acp src/kiro_crew/providers src/kiro_crew/session_allocation_parts
Sibling: src/kiro_crew/acp/engine_fallback.py -- changed here
Sibling: src/kiro_crew/acp/session_provider.py -- changed here
Sibling: src/kiro_crew/acp/session_provider_mcp_reinject.py -- changed here
Sibling: src/kiro_crew/session_allocation_parts/get_or_create.py -- not affected -- a post-claim switch is an explicit pin and clears the mark
Sibling: src/kiro_crew/subagent_manager/run_start.py -- not affected -- subagents keep KAS's default, listed under Not a goal
Pattern harvest
Not generalizable: the inherited-versus-pinned distinction is specific to kiro-cli's own default model setting, which only KAS fails to read.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
Contributed under the project's Apache-2.0 license.