Skip to content

feat(session-control): session_create takes a model for the new session - #14049

Merged
iamwhatever merged 2 commits into
kirodotdev:mainfrom
Pearcekieser:feat/session-create-model
Sep 27, 2026
Merged

iamwhatever merged 2 commits into
kirodotdev:mainfrom
Pearcekieser:feat/session-create-model

Conversation

@Pearcekieser

@Pearcekieser Pearcekieser commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: Let an agent choose the model a session starts on when it opens one with session_create.

An agent that opens a new session with session_create cannot choose its model. The tool takes title, agent and folder only, so every session it opens starts on the agent's or the global default. Subagents do not have this gap: spawn_run and spawn_continue already take model.

Why it matters

A conductor that fans work out to worker sessions has to leave them all on one model, or the person has to open each tab and change the dropdown by hand.

Not a goal

  • Changing the model of a session that already exists (a separate session_set_model tool).
  • Widening the shared model-id check, for example to accept [1m] ids; that check is shared with spawn_run, spawn_continue and cron_add.
  • Making the dashboard's model-pick route persist an idle session's model on its own.

What changed (motivation → approach → change)

session_create takes an optional model. The new session starts pinned to it, the same way a person's pick in the model dropdown pins it.

Step Where What happens
Format check src/kiro_crew/validation.py SESSION_CREATE_SCHEMA.model uses the same model-id pattern and length cap as spawn_run.model
Transport src/kiro_crew/mcp_dashboard.py, dashboard/handlers/session_control.py The tool sends model to POST /api/session-control/create only when set, and its reply names the model
Guard and pin dashboard/session_control.py Before anything is allocated, create_session refuses with model_rejected when the id is longer than MAX_SHORT_STRING or breaks _MODEL_NAME_RE (the HTTP route does not run the MCP schema, so the bound lives here), when redact() would change the id (a credential-shaped value is never stored or broadcast) or when the picker's own _model_rejected_reason refuses it. It then sets slot.model and bumps _model_pick_gen as a human pick does
Restart dashboard/session_control.py The birth metadata line records model, so an idle new session keeps it across a restart

Omitting model behaves exactly as before. session_fork still takes no model override, because it copies the source session's model. src/kiro_crew/docs/session-control.md and the owning spec docs/system-specs/modules/session-control.md document the new argument, its metadata field and its SEL detail. The tool description names no concrete model id. It states that an id the account cannot serve is accepted at create time and withheld at the session's first turn, which then runs on the account's default with a notice in that session's transcript.

The second commit is a one-line main fix that this PR carries so its checks can pass. #14181 left prepare-pr/SKILL.md at 68015 bytes, over the 68000-byte ceiling in test_review_repair_routing_skill.py, so Backend Tests shard 3 fails on main. The commit drops the clause "never edit the goal" from the proportionality step, because the frozen-goal paragraph already says only the user may edit the goal. If main gets its own fix first, a rebase drops this commit.

Backwards compatibility

Compatible: model is optional and omitted callers get the old behaviour and the old metadata line.

Tests

  • test/test_session_control.py: a named model is pinned on the slot, bumps the pick generation, is returned, and is written to birth metadata. Omitting it leaves no pin and no metadata key. A model the picker guard rejects, and a credential-shaped id, each refuse the create with model_rejected, leave no slot behind, and the credential case does not echo the id. Route-level tests drive model through POST /api/session-control/create: a valid id pins the created slot, and a bad-charset id comes back as a model_rejected refusal. Over-length and bad-charset ids are refused in the core too.
  • test/test_mcp_dashboard_folders.py: the tool forwards model in the create payload, sends no key when it is omitted, and rejects a malformed id before any HTTP call.

Manual verification

N/A: unit coverage exercises the tool, the route and the core; the model reaches the backend through the same slot.model path the dropdown and session_fork already use.

Screenshots / video

N/A: backend and MCP tool change only; no website/ files are touched.

Related Issues

Fixes #14033

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

@Pearcekieser
Pearcekieser requested review from a team and smeyffret September 26, 2026 00:20
@Pearcekieser

Copy link
Copy Markdown
Contributor Author

Intent: let an agent choose the model a session starts on when it opens one with session_create, the way spawn_run already lets it choose a subagent's model.
Not a goal: changing the model of an existing session, a model override on session_fork, or per-agent models on the blocking spawn_sub_agents.

@github-actions github-actions Bot added fork Pull request from a fork (external contributor) readiness: action required A blocking check or review needs attention labels Sep 26, 2026
@Pearcekieser
Pearcekieser force-pushed the feat/session-create-model branch from 63158a5 to cdcd75f Compare September 26, 2026 01:06
@Pearcekieser

Copy link
Copy Markdown
Contributor Author

Rebased onto main 5bbc6f7 with no code change, to re-run the fork GPT/Opus review lanes: on the previous head (63158a5) they reported "could not run" after the CI app hit its installation API rate limit (Resolve desktop matrix logged API rate limit exceeded for installation at 00:22Z). The remaining Backend Tests reds on that head also fail on main itself (test_sandbox_protected_name_holds.py leaf-only counts, and test_spawn_approval_channel_delivery_2381.py, which #14052 fixes).

@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 Sep 26, 2026
@github-actions

github-actions Bot commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Fable 5, fork) — ✅ PASS

Design-level review of f7404f9b7aef28a90f7bc98d2ffe4b6f345a3519 via the fork AI-review pipeline — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

Design-Verdict: PASS

Verify at merge time that main still needs the piggy-backed prepare-pr/SKILL.md byte-shave commit; if main was fixed independently, rebase to drop it.

(I confirmed the carry-along fix is sound: base SKILL.md is 68015 bytes against the test's 68000 ceiling, and the deleted clause is redundant — "only the user may edit it" survives at line 365 of the skill and in AGENTS.md's frozen-goal section.)

Suggestions

  • The lazy in-function import of _model_rejected_reason from chat_handlers dodges a circular import; a small follow-up moving that guard to chat_utils (beside _normalize_model, which this PR already imports from there) would remove the workaround for all three of its callers.

[DESIGN-REVIEWED] f7404f9

@github-actions

github-actions Bot commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Fable 5, fork) — ✅ PASS

Premise-level review of f7404f9b7aef28a90f7bc98d2ffe4b6f345a3519 via the fork AI-review pipeline — 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/CONCERNS are advisory.

First-Principles-Verdict: PASS

No test pins the tool description's promise that an unservable-but-well-formed id is withheld at first turn with only a transcript notice — verify that fallback fires.

What this change ships

Inventory (7 items) — 6 justified

Intent: let an agent pick the model a session it opens starts on (ADDITION, linked issue #14033).

  1. session_create takes an optional model; the new session starts pinned to it, like a dropdown pick — justified
  2. A malformed, credential-shaped or picker-refused id fails the whole create with model_rejected, allocating nothing — justified
  3. The tool's success reply now says on model `X` when one was pinned — justified
  4. Birth metadata records model, so an idle new session keeps it across a restart — justified
  5. The create's SEL audit record carries model (empty when none asked) — justified
  6. Spec and packaged docs document the argument in the same commit — justified
  7. prepare-pr SKILL.md drops the "never edit the goal" clause — rides along: declared; unwedges red main (68015 bytes vs the 68000 ceiling in test_review_repair_routing_skill.py, verified on base), and the surviving frozen-goal paragraph ("only the user may edit it") keeps the pinned decision

[FIRST-PRINCIPLES-REVIEWED] f7404f9

@github-actions

github-actions Bot commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

GPT 5.6 Review (fork) — ✅ no blocking findings

Reviewed f7404f9b7aef28a90f7bc98d2ffe4b6f345a3519 via the fork AI-review pipeline; updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] f7404f9

@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 Sep 26, 2026
@github-actions

github-actions Bot commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5 Review (fork) — ✅ no blocking findings

Reviewed c239240f579d9c32e9d2af03a45db50e897728d5 via the fork AI-review pipeline; updated in place on each push.

Review details

Nothing blocks — two advisory findings, both new prose asserting behaviour the code does not implement.

FINDING — src/kiro_crew/dashboard/session_control.py:2309 — the comment says slot._model_pick_gen += 1 "marks it as an explicit choice, so the fallback restore probe treats it exactly as it treats a human pick rather than as a backfilled value", but every reader of that counter compares it only against a snapshot taken later (slot._fallback_pick_gen = slot._model_pick_gen, chat_runner.py:1805; stale=slot._model_pick_gen != slot._fallback_pick_gen, chat_runner.py:1913; _refusal_pick_gen at 2094/2181; the relative rollback at chat_handlers.py:8941-8972), so a birth value of 1 and of 0 produce identical staleness verdicts and the protection the comment and the new test docstring name does not exist → Fix: keep the bump as convention but state what is true (the counter is only ever read as a delta from a snapshot taken at fallback activation), or add the mechanism that actually fences a birth pin and pin it with a swap-then-restore test.

FINDING — src/kiro_crew/mcp_dashboard.py:477 — "an id from that same list, or 'auto'" promises parity with the session's model dropdown, but _MODEL_NAME_RE (^[a-zA-Z0-9][a-zA-Z0-9._-]*$, applied both in SESSION_CREATE_SCHEMA and inline in create_session) rejects ids that list serves: with agent.acp_backend="claude" the rows carry the advertised bracketed spelling (_cc_models replaces the registry row's model_name with the advertised id, e.g. global.anthropic.claude-opus-4-8[1m], which api_chat_slot_model accepts and stores in slot.model), and auto:jev is a row too — so an agent copying a picker id gets a model_rejected / ValidationError blaming the charset → Fix: narrow the sentence to the spellings this field accepts (bare dotted/canonical id or auto), or fold the advertised spelling to its canonical key before the charset check.

[OPUS-REVIEWED] c239240

@Pearcekieser
Pearcekieser force-pushed the feat/session-create-model branch from cdcd75f to 2ced0b3 Compare September 26, 2026 01:35
@Pearcekieser

Copy link
Copy Markdown
Contributor Author

mechanism: redact() comparison before allocation in create_session

  • Credential-shaped model IDs reach the dashboard unredacted

fixed in 2ced0b3: create_session now refuses with model_rejected when redact(model) != model, before any slot is allocated, so the value is never stored, persisted or broadcast.
The refusal text does not echo the id; test_create_refuses_a_credential_shaped_model pins code, non-disclosure and zero allocation.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author
  • Use 'auto' alone as the description's example

fixed in 2ced0b3: the session_create model description names no concrete id; it points at the model dropdown's list or 'auto' and says an id the account cannot serve fails at the session's first turn.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author
  • Owning spec does not list the new model field

fixed in 2ced0b3: docs/system-specs/modules/session-control.md now documents the model argument and model_rejected refusal, lists model among the birth-metadata fields written when set, and adds model to the create's SEL record fields.

@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 Sep 26, 2026
@Pearcekieser

Copy link
Copy Markdown
Contributor Author
  • _MODEL_NAME_RE rejects advertised Claude IDs containing [1m]

rebutted (advisory, kept as-is): session_create.model deliberately uses the same _MODEL_NAME_RE that spawn_run.model, spawn_continue.model and cron_add.model already use (validation.py), so an agent can name exactly the ids it can already pin for a subagent.
Widening only this field would make session_create accept ids those siblings refuse; if bracketed suffixes should be accepted, that is one change to _MODEL_NAME_RE for all four fields, outside this PR's intent.

@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 Sep 26, 2026
@Pearcekieser

Copy link
Copy Markdown
Contributor Author
  • session_create model description misstates what happens to an unentitled id

fixed in 16dd34a: confirmed in chat_runner._pinned_model_verdict that an unentitled pin is withheld and the turn runs on the account default; the description now says the id is accepted at create, withheld at the first turn, and signalled only by a notice in that session's transcript.
Head also rebased onto main 694f619, which carries #14056's fix for the inherited Backend Tests reds.

@Pearcekieser
Pearcekieser force-pushed the feat/session-create-model branch from 2ced0b3 to 16dd34a Compare September 26, 2026 02:06
@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 Sep 26, 2026
@Pearcekieser
Pearcekieser force-pushed the feat/session-create-model branch from 16dd34a to 30c8385 Compare September 26, 2026 02:35
@Pearcekieser
Pearcekieser force-pushed the feat/session-create-model branch from d9ea711 to fae5a01 Compare September 26, 2026 15:17
@Pearcekieser

Copy link
Copy Markdown
Contributor Author

Rebased onto main 7b2da39c53 now that #14138 has merged. The cherry-picked registry commit dropped out, so this PR is back to the single feature commit (fae5a01b33, same code as before). The new head also re-runs the Backend Tests (3.12, 2) shard that flaked on the previous head, so no manual re-run is needed.

@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 Sep 26, 2026
@Pearcekieser

Copy link
Copy Markdown
Contributor Author

Head fae5a01: every check and both AI reviews are green except Backend Tests (Windows) (6), which failed on test_spawn_approval_channel_delivery_2381.py::test_an_authorized_destination_still_posts_through_the_transport_gate. This PR does not touch that file, and all 39 tests in it pass locally on this head. Could a maintainer re-run the failed jobs? As a fork contributor I can't. Thanks.

@Pearcekieser
Pearcekieser force-pushed the feat/session-create-model branch from fae5a01 to 819887a Compare September 27, 2026 04:43
@Pearcekieser

Copy link
Copy Markdown
Contributor Author

Rebased onto main e4e6ed7 as 819887a with no code change, to re-run CI. The earlier ask for a maintainer re-run is withdrawn. The Windows shard 6 failure (test_spawn_approval_channel_delivery_2381.py, assert False is True) is in a file this PR does not touch, and it passes locally on the new head along with this PR's tests (428 passed).

@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 Sep 27, 2026
@Pearcekieser
Pearcekieser force-pushed the feat/session-create-model branch from 819887a to c239240 Compare September 27, 2026 05:35
@Pearcekieser

Copy link
Copy Markdown
Contributor Author

Rebased onto main 55580af as c239240 with no code change, to re-run CI. Windows shard 8 failed on test_decisions_memory_recall_reachable.py with a Windows PermissionError (Errno 13). This PR does not touch that file, and it passes locally on the new head.

@Pearcekieser

Copy link
Copy Markdown
Contributor Author

New head f887d28. Main is red on test_review_repair_routing_skill.py (prepare-pr SKILL.md is 68015 bytes against a 68000 ceiling since #14181), so this PR now carries a one-line trim as a second commit; a rebase drops it if main gets its own fix. I also added the Goal line and Not a goal section that the PR template now requires. The Windows shard 5 failure (test_wake_judge_feedback.py) is in a file this PR does not touch.

@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 Sep 27, 2026
spawn_run and spawn_continue already take a per-run model, but session_create
had no way to pick one, so a conductor opening worker sessions could not put
them on a different model than the default. Add an optional model argument:
held to the spawn_run model-id charset by the schema, refused with
model_rejected by the same guard the dashboard model picker runs, pinned on
the slot with the pick-generation bump a human pick gets, and recorded in the
persist-at-birth metadata so an idle child keeps it across a restart.
kirodotdev#14181 left the skill at 68015 bytes, so test_slim_skills_do_not_regrow_duplicate_guidance_or_wire_model_ids fails on main. Drop the duplicate 'never edit the goal' clause; the frozen-goal paragraph already says only the user may edit it.
@Pearcekieser

Copy link
Copy Markdown
Contributor Author

Rebased onto main 94bcda2 as f7404f9 with no code change, to re-run the Opus review, which ended "review incomplete" on f887d28. Every other check passed on that head.

@Pearcekieser
Pearcekieser force-pushed the feat/session-create-model branch from f887d28 to f7404f9 Compare September 27, 2026 07:08
@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 readiness: checking Automated validation is still running labels Sep 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fork Pull request from a fork (external contributor)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

session_create cannot choose a model for the new session

2 participants