feat(models): serve the KAS bundle picker from the engine model select
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
- Changing how the kiro-cli routes (Kiro CLI, or KAS through kiro-cli's relay) list models. They keep
--list-modelsand the kiro-cli readiness gate unchanged. - A cold-start probe that starts the engine only to read its model list. Before the first chat on a fresh gateway the picker offers
auto; the first session fills it. - Inventing a context window the engine does not report. A row without a known window carries none.
- The other kiro-cli call sites in #21843 (
whoami,update,--version).
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 (nomodelsobject 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,autoalone 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 reachesreject_if_kiro_unverified,_fetch_kiro_catalogor_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 throughKasLoginService(the service the dashboard and thekirocrew kasverbs 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:
GET /api/modelscold → 200,autoalone.- One chat turn on a fresh slot → the session spawned from the installed bundle (
engines/kas/0.66.33/.../acp-server.js). GET /api/models→ 200, 21 rows, every row withrate_multiplier(1.0 … 4.4), 19 with acontext_window, 2 without (no source knows them).POST /api/chat/slots/{slot}/modelwith a non-autorow, then a turn → the engine'ssession/newfor the slot reportsmodel.currentValue= that id.gateway.loghas no kiro-cli spawn.- 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:
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:
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.