Skip to content

feat(models): serve the KAS bundle picker from the engine model select - #23618

Merged
iamwhatever merged 1 commit into
mainfrom
feat/kas-bundle-model-picker
Oct 27, 2026
Merged

iamwhatever merged 1 commit into
mainfrom
feat/kas-bundle-model-picker

Conversation

@CrysisDeu

@CrysisDeu CrysisDeu commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: On the KAS bundle route, the chat model picker lists the models the engine serves, with their credit multipliers, without ever starting kiro-cli.

With agent.acp_backend: kas and agent.kas_bundle: true the host may have no kiro-cli at all. GET /api/models only knew the kiro-cli chat --list-models catalog behind kiro-cli's readiness gate, so the picker stayed on auto, showed no context windows and no credit multipliers, and the degraded 503 poll kept trying to start kiro-cli every 8 seconds.

Why it matters

The bundle route is the no-kiro-cli install (#21843). A picker stuck on auto means a bundle user cannot choose a model at all, and the cost badge and context meter have nothing to show. It is also one of the kiro-cli call sites that blocks turning the bundle route on by default.

Not a goal

What changed (motivation → approach → change)

Measured first, on the bundled engine with kiro-cli off the PATH and Crew's own vault sign-in (test/fixtures/acp_frames/kas/bundle-session-live.jsonl): session/new carries no models object. The list is the configOptions model select alone; each option carries _meta.kiro.rateMultiplier, and none carries a structured context window. So the select is the catalog on this route, and the design follows the measurement.

Part What it does
agent_sdk/kas_model_catalog.py Turns a KAS session's model select into --list-models-shaped rows (model_id, model_name, display_name, description, rate_multiplier) and keeps the last one in memory. Positive KAS identity; the session's own advertised list is untouched. A select is what ONE account is served, so every session/new and session/load notes the vault identity fingerprint it went out under (kas_model_catalog.vault_identity over auth/bridge.vault_identity_fingerprint, read off the loop by the KAS harness as it builds the session payload -- SessionExtras.vault_identity, "" on every other host -- and carried on the handle as request_vault_identity), record_catalog keeps it with the rows and refuses a response without one, and recorded_catalog_snapshot(identity) yields the rows only to that fingerprint. The fingerprint is read from the vault itself, so the fence holds whichever process changed the account -- the dashboard's sign-in card or kirocrew kas login / kas logout in a shell -- and the sign-in service needs no hook (auth/service.py is unchanged). Per request, not per process: the engine takes its credential per call, so a long-lived runtime records for whoever is in the vault at its next session.
acp/session_handle_model_selection.py, acp/session_handle_class.py, acp/runtime_session_create.py, acp/runtime_session_load.py The shared-runtime driver records the select when a session opens (KAS runs on AcpRuntime only), stamped with the vault identity the session's request went out under, taken from the harness's own session payload (acp/harness/kas.py, acp/harness/base.py), so the Kiro construction path gains no step (H13) and nothing is read while a start permit is held.
dashboard/handlers/models_kas_bundle.py The bundle route's GET /api/models: readiness is the installed engine plus Crew's vault (coded 503s kas_bundle_not_installed / kas_bundle_sign_in_required), auto alone while cold (a fresh process, or a vault that now names another account than the rows were recorded for -- the handler reads the vault's fingerprint on every request and again after its one await, the advertised-store persist), the recorded rows once a session has advertised, context_window only where model_registry.model_window knows the id, and the same refresh_kiro_catalog admission feeding the acp vocabulary bucket and the prices. No entitlement narrowing: the select already is the signed-in account's list.
dashboard/handlers/agents.py api_models dispatches on the existing positive two-fact agent_sdk.kas_bundle.kas_bundle_route() (off the loop) before the kiro-cli path. A route is not a harness, so this is not a capability set.
components/KasLoginGate.tsx, pages/developer/KiroSignInCard.tsx An authorized Crew sign-in and a sign-out drop the browser's model-list caches (clearCachedModels + reset of ['available-models'], the pair the Agent Harness switch uses), since that list is refetched only on a session spawn.
specs and docs model-selection.md, harness-parity.md, acp-client.md, agent-host-contract.md, the feature map and configuration.md describe the route.

The picker's rows have the shape it already reads, and the dashboard already refetches the list when a session spawns; the picker component itself is unchanged (its credit-multiplier badge keeps main's sr-only explanation).

This PR adds no "is the bundle route on" predicate of its own: it calls the shared agent_sdk.kas_bundle.kas_bundle_route(). Folding the other copies into it is #23858.

Backwards compatibility

Compatible: the kiro-cli routes take exactly the code path they took before (pinned by test_api_models_kas_bundle.py::TestDispatchFromApiModels); the bundle route previously answered a permanent 503.

Removes nothing: only a new branch and new modules are added; no key, field, route or function goes away.

Tests

  • test/test_kas_model_catalog.py: the measurement (no models object on the bundle fixture), the row shape, the price field, grouped options, the id and count bounds, that only a KAS session records, the vault identity fence (rows served only to the fingerprint they were recorded for, a late response from the previous account not served to the next, an empty vault matching nothing, a request without a fingerprint refused, a long-lived runtime recording for each request's account, only a KAS request reading the vault), and that the driver never adopts the select as an advertised list.
  • website/src/test/KiroSignInCard.test.tsx: sign-out and an authorized sign-in reset the ['available-models'] query and drop the localStorage model cache.
  • test/test_api_models_kas_bundle.py: both coded 503s, auto alone while cold, multipliers and only known windows on recorded rows, the registry feed, an account switch during the persist await answering cold while an unchanged account serves the snapshot, and that the bundle route never reaches reject_if_kiro_unverified, _fetch_kiro_catalog or _entitled_kiro_models (a retained kiro-cli session's list must not narrow the bundle account's picker) while the kiro-cli routes still take their gate; and, against a real vault, that a sign-out plus sign-in through KasLoginService (the service the dashboard and the kirocrew kas verbs both build) or a second sign-in over an outranked slot turns the picker cold, a sign-out answers the sign-in-required 503, and a same-account token rewrite keeps the rows.
  • test/fixtures/acp_frames/kas/bundle-session-live.jsonl + .expected.json: the live bundled-engine capture (pruned to the product's own routing entry per the corpus rules).

Manual verification

Isolated gateway from this worktree, own KIROCREW_HOME, agent.kas_bundle: true, engine from kirocrew kas install (KAS 0.66.33), Crew vault sign-in, PATH without kiro-cli:

  1. GET /api/models cold → 200, auto alone.
  2. One chat turn on a fresh slot → the session spawned from the installed bundle (engines/kas/0.66.33/.../acp-server.js).
  3. GET /api/models → 200, 21 rows, every row with rate_multiplier (1.0 … 4.4), 19 with a context_window, 2 without (no source knows them).
  4. POST /api/chat/slots/{slot}/model with a non-auto row, then a turn → the engine's session/new for the slot reports model.currentValue = that id.
  5. gateway.log has no kiro-cli spawn.
  6. The dashboard built from this worktree against that gateway shows the populated picker (screenshots below).

Screenshots / video

The chat model picker on the isolated bundle-route gateway (KAS 0.66.33 from kirocrew kas install, no kiro-cli on PATH, Crew vault sign-in), after one chat turn: 21 rows from the engine's model select with their credit multipliers. The transcript behind it shows the first turn on auto (resolved by the engine) and the second on the picked claude-opus-5.5.

Light:

Model picker on the KAS bundle route, light

Dark:

Model picker on the KAS bundle route, dark

Those two frames were grabbed the instant the picker attached, mid-way through its 300ms animate-slide-up entrance (opacity 0 → 1), which is why the user bubble under the popover shows through in them. The popover's surface is bg-bg-elevated, an opaque token in every palette; it does not let anything through once the entrance has settled.

Picker after the entrance settles

The built SPA from this head through website/scripts/lib/stub-dashboard-api.mjs (the same stub harness the repo's picker captures use), the same transcript under the popover, frame taken 700ms after the listbox attached. Computed background-color of the dialog: rgb(33, 29, 37) dark, rgb(255, 255, 255) light; opacity: 1 in both. (These frames were taken when this PR also renamed the badge; that change is dropped, and the badge renders as on main.)

Dark:

Model picker, entrance settled, dark

Light:

Model picker, entrance settled, light

Related Issues

Refs #21843
Refs #23858 (one predicate for "is the KAS bundle route on"; this PR adds the fourth copy, #23657 the fifth)

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

Contributions are accepted under the project's Apache-2.0 license; see the Licensing section of CONTRIBUTING.md.

@CrysisDeu
CrysisDeu requested review from a team and KiroCrewCaptain as code owners October 24, 2026 01:30
@github-actions

github-actions Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ✅ PASS

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

UX-Verdict: PASS

Nothing blocks: this PR adds no new controls, and the blind reader correctly read the newly filled model rows as models they could switch to.

Notes

  • The blind reader could not tell what the "1.0x / 2.0x / 1.3x / 4.4x" badges measure ("a guess on cost, no idea what the colours mean"). Their only explanation is sr-only text inherited from main. Since this PR's purpose is to show these multipliers to bundle users, a follow-up should add a visible "credits per turn" hint.

[UX-REVIEWED] f4b12b5

Description read

[DESCRIPTION-READ] 715e2d9fd6c9602640e0813ab3b926ee1aa8d6a5e8b0665f64b61d2224125422

That sha256 names everything this verdict read: the PR description, plus the 7 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 added the readiness: checking Automated validation is still running label Oct 24, 2026
@github-actions

github-actions Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

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

Design-Verdict: PASS

No design-level concerns: the bundle-route picker reads the engine's measured model select, kept per vault identity and dispatched ahead of the unchanged kiro-cli path.

Notes

  • Every KAS session now reads the vault (vault_identity in KasHarness), including the kiro-cli relay route where nothing reads the recording. It's one off-loop file read, but limiting the stamp to kas_bundle_route() would leave the relay route's session start exactly as before.

[DESIGN-REVIEWED] f4b12b5

Description read

[DESCRIPTION-READ] 760862b5fa24084c22298562d7cf46cfccde9b5738487d048878cefd248368d7

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 Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of f4b12b5e988b36b5e90eabbe5c4e137f47e07a2c — 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. Every item is aimed at the bundle route's missing model list and reuses the existing catalog admission, cache-clear and route predicate. One note: on the relay route the recording has no reader.

Notes

  • Item 7 — oversized: per the module docstring, "a KAS session on either route records; only the bundle-route picker READS it". So every KAS session on kiro-cli's relay route now reads the vault and writes _recorded, and nothing reads either one. Subtraction: skip the vault_identity read and the record_catalog call when kas_bundle_route() is false. The relay route then keeps main's session-start path exactly.

What this change ships

Inventory (8 items) — 7 justified

Intent: let a user on the no-kiro-cli KAS bundle route choose a chat model and see its credit cost. This is an ADDITION.

  1. On the bundle route, the picker lists the engine's served models with credit multipliers — justified
  2. Before any session on the bundle route, the picker answers 200 with auto alone instead of the permanent degraded 503 — justified
  3. The bundle route answers coded 503s for "engine not installed" and "sign-in required" — justified
  4. The picker goes back to auto alone when the vault account changes, until that account's first session — justified
  5. A dashboard sign-in or sign-out drops the browser's cached model list — justified
  6. Bundle rows feed the acp vocabulary bucket and the cost-badge prices through refresh_kiro_catalog — justified
  7. Every KAS session on either route reads the vault fingerprint and records the select — oversized: the relay-route recording has no reader
  8. A config-load exception inside kas_bundle_route() now also returns False — undeclared

[FIRST-PRINCIPLES-REVIEWED] f4b12b5

Description read

[DESCRIPTION-READ] 1d9849098bb17e67c89cd172da50c314c577e47eefc9ded76c0567cc034fd4e1

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 Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

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

Review details

No findings.

[OPUS-REVIEWED] f4b12b5

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

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

@github-actions

github-actions Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings (all downgraded on adjudication)

GPT 6.1 flagged blocking issues on f4b12b5e988b36b5e90eabbe5c4e137f47e07a2c; Opus 5.5 adjudication downgraded every one of them. Downgraded: the remedy each one needs is disproportionate to the harm it prevents. Adjudication downgraded all 1 blocking finding(s): the remedy each one requires is disproportionate to the harm it prevents.

This comment is updated in place on each push.

Review details

BLOCKING -- website/src/pages/developer/KiroSignInCard.tsx:39 -- In-flight model requests repopulate the cleared account cache

clearCachedModels()
void queryClient.resetQueries({ queryKey: ['available-models'] })
Trigger: Sign-out completes while an earlier /api/models response is in flight. That response reaches AcpAdapter.fetchAvailableModels after the clear but before the reset’s signed-out 503 resolves. Neither useAvailableModelsQuery nor api.models propagates cancellation, so the earlier request still writes localStorage.
Outcome: The reset request’s error fallback reads the repopulated cache, restoring the signed-out account’s models and credit multipliers in the picker instead of auto alone.
Anchor: defect
Fix: Advance a fetch generation in clearCachedModels; discard superseded completions before they update model caches or health flags.
Sites: website/src/components/KasLoginGate.tsx:824 (authorized and cancel-confirmed sign-in); website/src/pages/developer/AgentBackendTab.tsx:394; website/src/components/KiroPrerequisiteGate.tsx:1150; shared writer website/src/providers/adapters/acp.ts:429 and fallback readers website/src/providers/adapters/acp.ts:412, website/src/providers/adapters/acp.ts:443.

[BLOCK-MERGE-DOWNGRADED] f4b12b5
[GPT-REVIEWED] f4b12b5

Adjudication (Opus 5.5) — is blocking on each finding proportionate?

F1: The harm is LOW. The failure needs a /api/models response that is still in flight when sign-out happens and that lands after clearCachedModels (acp.ts:109-115) has run. That response then rewrites the cache at acp.ts:429, and the fallback reader at acp.ts:443 serves it. When it happens, the user sees stale model names in their own browser on a single-user agent. While signed out, no turn can run with those names anyway. The stale list goes away on the next sign-in (KasLoginGate.tsx:824, which clears the cache again) or on the next successful live fetch (acp.ts:429). Before this PR, sign-out never cleared the cache (KiroSignInCard.tsx:36-40 is new). So in this narrow window the race only falls back to the old behaviour; it causes no new harm.
The real fix is a fetch-generation counter shared by acp.ts and every place that clears or writes the cache: four clear sites, the writer, and the health flags. That is a new ordering contract built only for this rare race, and it costs more than the harm it prevents.

[ADJUDICATION] f4b12b5e988b36b5e90eabbe5c4e137f47e07a2c total=1 uphold=0 downgrade=1
DOWNGRADE F1 website/src/pages/developer/KiroSignInCard.tsx:39 reason=disproportionate-remedy
[GPT-ADJUDICATED] f4b12b5e988b36b5e90eabbe5c4e137f47e07a2c

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

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Oct 24, 2026
@CrysisDeu
CrysisDeu force-pushed the feat/kas-bundle-model-picker branch from 94949cd to b2b9b96 Compare October 24, 2026 02:24
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Oct 24, 2026
@CrysisDeu
CrysisDeu force-pushed the feat/kas-bundle-model-picker branch from b2b9b96 to 7ea7f6c Compare October 24, 2026 03:33
@CrysisDeu

Copy link
Copy Markdown
Contributor Author

Replying to the First Principles notes on b2b9b96 (both PASS notes, carried onto the head that follows):

  • Note 6 (unread timestamp) — fixed in the next head: _recorded is now the plain row list, the tuple and the time import are gone.
  • Note 7 (a fourth "is the bundle route on" predicate) — not taken here. The three existing readers (agent_sdk/backend_install.py, kiro_prerequisite_service.py, acp/harness/kas.py) each load the config themselves at call time, off-loop, in their own module's import context; kas_bundle_route(cfg) takes the config api_models has already loaded and adds the backend fact the others get from their call site. Pointing those three at one predicate is a refactor of the probe, setup and spawn paths, which this PR's Not a goal keeps unchanged. Worth doing when the next KAS bundle route by default: replace the remaining kiro-cli calls (whoami, list-models, update, doctor) so the desktop app can drop the bundled kiro-cli-chat #21843 call site lands and a fifth copy would appear.

@CrysisDeu
CrysisDeu force-pushed the feat/kas-bundle-model-picker branch 4 times, most recently from bdf8dd2 to 8515ccc Compare October 24, 2026 04:41
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Oct 24, 2026
@CrysisDeu
CrysisDeu force-pushed the feat/kas-bundle-model-picker branch from 8515ccc to 50e7e2d Compare October 24, 2026 04:56
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Oct 24, 2026
@CrysisDeu
CrysisDeu force-pushed the feat/kas-bundle-model-picker branch 3 times, most recently from 3eb50c7 to a2a33c5 Compare October 24, 2026 06:26
@CrysisDeu

Copy link
Copy Markdown
Contributor Author

On the GPT finding at website/src/components/KasLoginGate.tsx (a late /api/models reply from account A re-writing the browser cache after B signed in), which the adjudication downgraded as a disproportionate remedy: not taken. The conditions are A's fetch still in flight at the moment B's sign-in lands, a later fetch for B failing (the only time the browser serves its cached list), and no session having spawned in between; the next successful fetch overwrites the cache. Guarding that needs a fetch-generation counter threaded through AcpAdapter.fetchAvailableModels, its cache write and the degraded-flag update, which is a change to the kiro-cli routes' picker as well -- outside this PR's goal, and more machinery than the glitch it prevents. The other finding on this head (a sign-out whose later slot delete fails skipping the identity-change hook) is fixed in the next head: the hook runs in a finally around the deletes, with a service test.

@CrysisDeu
CrysisDeu force-pushed the feat/kas-bundle-model-picker branch from 881b1ee to 99184c3 Compare October 25, 2026 13:54
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Oct 25, 2026
@CrysisDeu

Copy link
Copy Markdown
Contributor Author

@iamwhatever -- re-review requested on 99184c32f5. Every ask from r124 (on f91e085) is addressed, with pointers:

  1. Consolidation issue for the bundle-route predicate copies: refactor: one predicate for "is the KAS bundle route on" (five copies today) #23858 ("one predicate for 'is the KAS bundle route on'"), listing every copy with its path including this PR's models_kas_bundle.kas_bundle_route(cfg); linked from this description (What changed, Related Issues). Not consolidated here, as the issue says.
  2. Multiplier badge accessible name: fixed -- role="img" with the catalog sentence as aria-label and the same sentence as hover title (website/src/components/ModelDropdownList.tsx); test updated. Reply with the aria snapshot: feat(models): serve the KAS bundle picker from the engine model select #23618 (comment). The UX lane reads PASS on this head.
  3. Picker popover bleed-through: rebutted with evidence in the same reply (the popover's surface is opaque; the screenshot artefact was the backdrop).

Since then the PR was rebased onto main twice (one doc conflict in acp-client.md, resolved keeping both sides) and three AI-lane findings on the rebased heads were fixed: the cancel-settled sign-in now drops the model caches (#23618 (comment)), and the catalog's sign-in-generation fence is per request rather than per process, with the handler re-checking the generation after its one await (#23618 (comment)). GPT, Opus, Design, First Principles and UX all PASS on 99184c32f5; the remaining reds across the rounds were main's (#23933, since merged) and the ledgered flakes #23860 / #23965.

The part you flagged for a maintainer's human sign-off -- the KAS sign-in service's credential write and sign-out paths in src/kiro_crew/auth/service.py -- is unchanged since f91e085.

@iamwhatever

Copy link
Copy Markdown
Contributor

HOLD (sensitive change, human sign-off needed) at 99184c3.

The r124 requests are met: #23858 covers the predicate consolidation and is linked, the multiplier badge has an accessible name with a test, and the popover rebuttal holds up against the evidence. I found no defect. record_catalog refuses a recording from any request that went out under an earlier sign-in generation (kas_model_catalog.py#L155-L190), and the handler re-checks the generation after its one await. CI is green and there are no conflicts.

Still blocking:

  1. This PR changes the KAS sign-in service's credential-save and sign-out paths (service.py#L671-L703, #L867-L879). The change looks behaviour-preserving, but it needs a maintainer's human sign-off.
  2. Three First Principles notes on this head have no reply: the two 503 code constants have no reader in the dashboard, recorded_catalog() is called only from tests, and the badge's hover title is outside the goal. A short reply on each (keep with a reason, or drop) would clear this.

— crew-pr-reviewer (r126)

chenmingwei23
chenmingwei23 previously approved these changes Oct 26, 2026
@CrysisDeu

CrysisDeu commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor Author

Opus 5.5 blocking finding on 129bbd9008 (CLI kas login / kas logout skips forget_catalog): fixed, now at 89bf8ff048.

The finding was right. A shell sign-in runs in its own process, so a hook in the dashboard's service never fires for it. Calling forget_catalog in the CLI would not help, because the recording lives in the gateway's memory. The fix is a fence that every process can see, and on 89bf8ff048 it is the only fence:

  • Each KAS session/new / session/load is stamped with the vault identity fingerprint it went out under (kas_model_catalog.request_vault_identity, which reads auth.bridge.vault_identity_fingerprint off the loop; no vault read for any other backend). record_catalog keeps the stamp with the rows and refuses a response without one.
  • recorded_catalog_snapshot(identity) yields the rows only to that fingerprint. models_kas_bundle.api_models_kas_bundle reads the vault's fingerprint on every request, and again after its one await. So once the vault names a different account, whichever process wrote it, the picker answers cold. If the vault comes back to that account, the rows serve again.
  • The in-process sign-in generation, forget_catalog and the KasLoginService(on_identity_change=) hook are removed (First Principles, b7d5370b3b). src/kiro_crew/auth/service.py and dashboard/handlers/kas_login.py are back to main.

Tests: test/test_api_models_kas_bundle.py::TestTheRecordingFollowsTheVault uses a real TokenStore and KasLoginService: sign-out + sign-in → cold, a sign-in over an outranked slot → cold, sign-out → sign-in-required 503, a same-account rewrite → rows kept. test/test_kas_model_catalog.py::TestTheVaultIdentity covers the rest. Specs: model-selection.md, acp-client.md, kas-auth.md.

@CrysisDeu

CrysisDeu commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor Author

First Principles blocker on 129bbd9008 and again on 2d5254dd2b, "second copy of the bundle-route predicate": fixed by subtraction in e72c38e893 (head now b80a53d36a, where the shared predicate also reads the agent fields inside its own try, so a malformed config reads as the relay route as its docstring says).

models_kas_bundle.kas_bundle_route(cfg) and its tests are deleted. api_models now branches on the shared agent_sdk.kas_bundle.kas_bundle_route(), called off the loop. This PR adds no new copy. Folding the existing copies is still #23858: #23858

The 2d5254dd2b notes:

  • Item 8, two vault-fingerprint wrappers: fixed. There is now one, kas_model_catalog.vault_identity. The session stamp and the picker's match both read through it.
  • Item 4, the vault is read on relay-route KAS sessions too: kept, with a reason. The read is one local file, and it runs before the start permit. Gating it on the route would put a config reload on every session start. It would also make the recording depend on the route at session time, and that can change under a hot agent.acp_backend switch. The rows are only ever read on the bundle route.

@CrysisDeu

Copy link
Copy Markdown
Contributor Author

First Principles blocker 2 on 129bbd9008, "reversed badge decision": dropped in b7d5370b3b.

The title= did reverse the recorded choice (sr-only text in the tree, not a tooltip), and it was outside the goal. website/src/components/ModelDropdownList.tsx and website/src/test/ModelDropdownList.multiplier.test.tsx are back to main byte for byte: the badge keeps the aria-hidden glyph and the sr-only catalog sentence. This PR no longer touches the picker component. The description is updated to match.

@CrysisDeu

CrysisDeu commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor Author

First Principles item 4 (on_identity_change is a Callable with one consumer) and the b7d5370b3b blocker (the generation fence duplicates the identity fence): both done by subtraction in 89bf8ff048.

The vault-identity fence covers every case the generation covered: an account switch from any process, a late response from the previous account, and a switch during the handler's await (the fingerprint is read again after it). So the generation, sign_in_generation, forget_catalog, the request_sign_in_generation handle field and the on_identity_change hook are all deleted. src/kiro_crew/auth/service.py, dashboard/handlers/kas_login.py and test/test_kas_login_service.py are back to main, so this PR no longer changes the sign-in service at all. A same-account re-sign-in now keeps the rows, since the fingerprint does not move.

@CrysisDeu

Copy link
Copy Markdown
Contributor Author

@iamwhatever, the three First Principles notes from r126, one at a time (head b7d5370b3b):

  1. The two 503 code constants have no dashboard reader: kept, with a reason. The codes are this route's contract (named in acp-client.md) and are pinned by test_api_models_kas_bundle.py::TestReadiness. They also keep the 503 apart from kiro_prerequisite_required, the one code the dashboard turns into a kiro-cli login remedy (website/src/providers/adapters/acp.ts:442). A bundle-route 503 must never render that remedy. Today the dashboard shows the error text. The constants keep one spelling for the handler and its tests.
  2. recorded_catalog() is called only from tests: removed. It is gone from kas_model_catalog.py. The tests read through recorded_catalog_snapshot(identity), the reader's own entry point, which now also takes the vault identity (see the Opus fix above).
  3. The badge's hover title is outside the goal: dropped. ModelDropdownList.tsx and its test are back to main.

@CrysisDeu

CrysisDeu commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor Author

@iamwhatever, please re-review head 91b321bd34 (rebased onto main @ 04b5ecf6b3).

You flagged src/kiro_crew/auth/service.py for a maintainer's human sign-off. That file is no longer in this PR's diff: it and dashboard/handlers/kas_login.py are byte-identical to main.

@CrysisDeu

Copy link
Copy Markdown
Contributor Author

Findings on b7d5370b3b, all fixed in 89bf8ff048:

  • Opus 5.5 / GPT F1, start permit leaked if a cancel lands during the vault read (runtime_session_create.py:406): the read now runs inside the init-scope try, before gate.acquire. A cancel there goes through _finish_session_init(""), and no permit is held yet. The read is also out of start_t0 latency. In runtime_session_load.py the read was already inside the try whose finally closes the scope.
  • GPT F2, a shell sign-out during the persist await bypasses the post-await fence (models_kas_bundle.py:163): the handler now reads the vault fingerprint again after the await and answers cold if it moved. The generation check it replaced is gone. Pinned by test_an_account_switch_during_the_persist_await_turns_the_answer_cold.
  • Harness Parity Gate, H5 negative constant (kas_model_catalog.py:185, backend != ACP_BACKEND_KAS): now the positive == ACP_BACKEND_KAS.
  • First Principles, the generation fence duplicates the identity fence: removed, see feat(models): serve the KAS bundle picker from the engine model select #23618 (comment)

@CrysisDeu

Copy link
Copy Markdown
Contributor Author

GPT 6.1 blocking finding on 80660bd07e (H13: the Kiro construction path awaited a KAS catalog helper): fixed in 91b321bd34.

The read now lives in the KAS harness's own session payload. KasHarness.session_extras reads the vault identity, and acp/harness/base.py gives SessionExtras.vault_identity a "" default. create_session and load_session only take kas_extras.vault_identity from the payload they already build, and load_session does that inside its existing ACP_BACKEND_KAS branch. request_vault_identity is deleted. The Kiro path has no new call, no await and no branch. The read also stays out of the start-permit window, so the b7d5370b3b permit-leak fix still holds.

Pinned by test_kas_model_catalog.py::TestTheVaultIdentity::test_the_kas_harness_carries_the_vault_identity_and_kiro_reads_nothing.

@CrysisDeu

Copy link
Copy Markdown
Contributor Author

GPT 6.1 blocking finding on 91b321bd34 (a same-provider account switch reuses the previous catalog): deferred to #24942.

The finding is real. vault_identity_fingerprint has no field that tells two same-kind accounts apart when both get the same profileArn. That gap is not only in this PR: main's identity sweep (_crew_vault_fingerprint / _retire_sessions_on_identity_change) reads the same fingerprint and misses the same switch. The fix proposed in #24942 is a persisted sign-in marker in the vault, bumped on every KasLoginService save and folded into the fingerprint. It fixes both readers at once, and it touches auth/service.py and auth/store.py, so it ships as its own change rather than in this PR.

#24942

@CrysisDeu

Copy link
Copy Markdown
Contributor Author

/ai-review override gpt 91b321b deferred #24942: Owner decision: the same-provider, same-profileArn account-switch gap also exists in main's identity sweep, so it is fixed once for both in #24942 rather than reopening auth/service.py and store.py here.

@github-actions

Copy link
Copy Markdown
Contributor

Human judgment recorded

@CrysisDeu recorded a deferred release (class deferred) for the gpt AI finding on 91b321bd3402883ce8b9768951ff42485167d09b.

Owner decision: the same-provider, same-profileArn account-switch gap also exists in main's identity sweep, so it is fixed once for both in #24942 rather than reopening auth/service.py and store.py here.

This decision applies only to this commit. A new push requires a new judgment.

@CrysisDeu

Copy link
Copy Markdown
Contributor Author

/ai-review override gpt 91b321b pre-existing #24942: agent: per @CrysisDeu ruling, old bug. A same-provider switch with the same profileArn leaves vault_identity_fingerprint unchanged; main identity sweep already misses it. Fix tracked in #24942.

On the KAS bundle route (agent.acp_backend "kas" with agent.kas_bundle
on) the host may have no kiro-cli, yet GET /api/models only knew the
`kiro-cli chat --list-models` catalog behind kiro-cli's readiness gate,
so the picker stayed on `auto` with no context windows and no credit
multipliers, and the degraded 503 poll kept trying to spawn kiro-cli.

Measured on the bundled engine (KAS 0.66.33, no kiro-cli on PATH, Crew
vault sign-in; fixture kas/bundle-session-live.jsonl): session/new has
no `models` object. The list is the configOptions `model` select, each
option carrying _meta.kiro.rateMultiplier and no structured context
window. Both session drivers now record that select as the engine's
catalog (acp/kas_model_catalog.py, positive KAS identity; the session's
advertised list is untouched), and /api/models dispatches the bundle
route to handlers/models_kas_bundle.py before the kiro-cli path: bundle
readiness (installed engine, vault identity) instead of kiro-cli's
latch, `auto` alone while cold, the recorded rows with rate_multiplier
once a session has advertised, a context_window only where the registry
knows the id, and the same refresh_kiro_catalog admission feeding the
`acp` vocabulary bucket and the prices. The kiro-cli route is unchanged.

A recording belongs to one account: each KAS session request is stamped
with the vault identity fingerprint it went out under, and the picker
serves the rows only while the vault still names that account. The
fingerprint is read from the vault itself, so a sign-in or sign-out
from the dashboard or from `kirocrew kas login` / `kas logout` in a
shell turns the picker cold, with no hook in the sign-in service.

Refs #21843
Refs #23858
@github-actions

Copy link
Copy Markdown
Contributor

AI-review override not recorded: 91b321bd3402883ce8b9768951ff42485167d09b is not the current PR head. Re-run the command with f4b12b5e988b36b5e90eabbe5c4e137f47e07a2c.

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.

4 participants