Skip to content

fix(kas): start an unpinned kas chat on kiro-cli's chat.defaultModel - #34155

Merged
KiroCrewCaptain merged 1 commit into
mainfrom
fix/33023-kas-inherit-default-model
Nov 10, 2026
Merged

KiroCrewCaptain merged 1 commit into
mainfrom
fix/33023-kas-inherit-default-model

Conversation

@JLargent42

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: A KAS chat with no model pinned in Kiro Crew starts on the model kiro-cli's chat.defaultModel names, as it does on kiro-cli.

kiro-cli starts a chat on its cli.json chat.defaultModel when nothing pins a model. KAS reads no cli.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

  • Warm-pool processes started from another folder, and subagent sessions on a shared runtime, reading their own folder's cli.json (recorded as a shortcut in the spec).
  • Changing how an explicit pick, a slot pin or agent.model behave: they still win over the kiro-cli setting.
  • Any change to the telemetry half of 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). With inherit=True the switch goes through the same KAS spelling fold and served-list resolution as any substitute, then records the applied spelling in _resolved_model_id (so served_model reports it) and in a new inherited_model field. _model keeps its unpinned value, so every "is this pinned?" reader (_bind_unbound_effort, _effort_model, the engine-fallback promotion at engine_fallback.py) still answers no, and nothing persists it into a slot. Any other set_model call 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 or auto reads chat.defaultModel off the loop (asyncio.to_thread, not in the factory) and applies it with inherit=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.py new_conversation: re-applies an inherited model with inherit=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_notice now takes the model (the caller already read it) and says the chat could not start on it.
  • Spec: docs/system-specs/modules/acp-client.md section on kiro-cli chat.defaultModel on KAS.

Backwards compatibility

Compatible: only a session with no Crew pin on KAS changes, and only when kiro-cli's cli.json names a model the account serves; every pinned path and every other harness is unchanged, and set_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 applies chat.defaultModel with inherit=True and 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_conversation re-applies an inherited model as inherited (the respawn case).
  • test_kas_cli_settings.py: notice and auto cases updated to the new signature.
  • test_session_handle_bindings.py: set_model signature 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_conversation re-applies nothing, a promotion keeps the mark). Locally: the 101 related backend test files at -n 2 pass, 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_model KAS 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

  • 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

Contributed under the project's Apache-2.0 license.

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
@JLargent42
JLargent42 requested review from a team and KiroCrewCaptain as code owners November 9, 2026 22:15
@JLargent42 JLargent42 self-assigned this Nov 9, 2026
@JLargent42
JLargent42 requested a review from CrysisDeu November 9, 2026 22:15
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Nov 9, 2026
@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision 787d57da534f245fd31ce706a01f4d418f7e5f62 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 9, 2026

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 787d57da534f245fd31ce706a01f4d418f7e5f62 — 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. 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 ships

Inventory (7 items) — 7 justified

Intent: someone who set a default model in kiro-cli gets that model on unpinned KAS chats in Kiro Crew, without pinning it again. FIX.

  1. An unpinned KAS chat (cold start, configured model empty or auto) now starts on kiro-cli's chat.defaultModel — justified
  2. The session-start notice now appears only when that model fails to land, with reworded text — justified
  3. A fresh conversation re-applies the inherited model, and a failure there is not fatal — justified
  4. An MCP re-injection handle swap keeps the inherited mark — justified
  5. An engine-fallback promotion drops the inherited mark, so a fresh conversation doesn't restore the model the engine moved off — justified
  6. set_model gets an inherit keyword and the handle gets an inherited_model field; any other set_model call clears it — justified
  7. default_model_notice takes the model instead of re-reading cli.json — justified

[FIRST-PRINCIPLES-REVIEWED] 787d57d

Description read

[DESCRIPTION-READ] d67f0d51e85bb7837dbef34b98ca1f882d5c4e6d646906b1617d200731c8a757

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 9, 2026

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

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

Design-Verdict: PASS

Nothing blocks: the inherited mark sits on the handle, _model stays unpinned so the existing pin readers are unchanged, and every failure path falls back to KAS's default and shows the notice.

Notes

  • If KAS refuses an inherited model, set_model still sets model_pin_refused. Readers like provider_model_pin_refused in dashboard/chat_handlers.py and slot_model.py may then report a pin refusal on a session that never pinned anything, alongside the new notice. Clear model_pin_refused when inherit=True.
  • Manual verification says N/A against a live KAS engine. One live unpinned cold start with chat.defaultModel set would confirm that the extra session/set_model write at startup lands.

[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 .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 9, 2026

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed 787d57da534f245fd31ce706a01f4d418f7e5f62 — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 787d57d

Verdict parsed from the review's SHA-scoped output markers for commit 787d57da534f245fd31ce706a01f4d418f7e5f62.

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

@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of 787d57da534f245fd31ce706a01f4d418f7e5f62 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 787d57d

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 787d57da534f245fd31ce706a01f4d418f7e5f62 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 9, 2026
@KiroCrewCaptain
KiroCrewCaptain enabled auto-merge (squash) November 10, 2026 00:03

@KiroCrewCaptain KiroCrewCaptain left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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_model raises on the inherit path, both at start and in new_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_model over.
  • Under Related Issues, add "Part of #33744" for the new_conversation row. That keeps the issue from asking for work this PR already ships.

@KiroCrewCaptain
KiroCrewCaptain merged commit 9a67532 into main Nov 10, 2026
96 of 97 checks passed
@KiroCrewCaptain
KiroCrewCaptain deleted the fix/33023-kas-inherit-default-model branch November 10, 2026 00:04
bolichen97 pushed a commit that referenced this pull request Nov 10, 2026
…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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

readiness: passed Eligible automated validation passed for the current revision

Projects

None yet

Development

Successfully merging this pull request may close these issues.

KAS ignores kiro-cli's chat.defaultModel

2 participants