feat(sessions): accept a per-session Claude model on POST /api/sessions - #514
Open
irisitymichaelgrundberg wants to merge 2 commits into
Open
irisitymichaelgrundberg wants to merge 2 commits into
irisitymichaelgrundberg wants to merge 2 commits into
Conversation
POST /api/sessions takes an optional `model`, and a Claude session launches with `claude --model <id>`. It wins over the app-wide default model and writes nothing to disk, unlike `modelOverride`, which stays as it is and still writes the case's .claude/settings.local.json. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
… claude SessionState now carries the model a session launched with, and both recovery constructors (mux recovery and reboot restore) pass it back, so a recovered session relaunches on the same --model rather than the account default. A top-level `model` sent with any other CLI is refused, since those take their model in their own config object, and an empty string means no per-session model, as it does for modelOverride. CLAUDE.md now describes both routes for a Claude model. The tests pin which of `model` and `modelOverride` reaches the launch and which the case file, and that a model opening with a dash renders as --model's value. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
irisitymichaelgrundberg
marked this pull request as ready for review
October 2, 2026 04:49
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #513 (the Claude half).
A caller can now start one Claude session on a chosen model without writing anything to disk.
POST /api/sessionstakes an optionalmodel, and the session launches withclaude --model <id>.Why
The only per-request way to pick Claude's model has been
modelOverride, which the route writes into<workingDir>/.claude/settings.local.json. That model outlives the session, and every laterclauderun in the directory starts on it, including runs outside Codeman. A caller that wants one session on Fable and the next on Sonnet has no way to say so without editing the user's checkout.What it does
modelinCreateSessionSchema. It is optional, at most 100 characters, and uses the same character set as the registry'smodel-claudepattern. A value the schema accepts therefore can't be refused at launch. An empty string means no per-session model, as it does formodelOverride.claude-settings-file, the route now takesbody.modelfirst and falls back to the app-wide default model as before. The session hands it to the existing--modelslot in Claude's launch template.modelOverrideis unchanged. A caller who wants the model written into the case still sends that field. If a caller sends both, the file getsmodelOverrideand this session runs onmodel.codexConfig.model, so the route refuses a top-levelmodelfor them withINVALID_INPUT. Otherwise it would be dropped without a word. The check keys on the registry's model-source capability, so the branch adds no CLI id check.SessionStatenow carriesmodel, the model the session launched with. Mux recovery inserver.tsand reboot restore both pass it back, so a recovered session relaunches on the same--modeland not on the account default. Sessions launched on the app-wide default model keep that one across a restart too.CLAUDE.mdused to say model choice goes throughsettings.local.json, "NOT--model". It now describes both routes:modelOverridewrites a lasting default into the case, andmodelsets one session's launch flag. The endpoint reference inskills/codeman/reference/endpoints.mdand its plugin mirror listmodelamong the create fields. That paragraph's two line references had gone stale, so they now name the handler andsessionCapacityMessage().Testing
npm testpasses, as do typecheck, lint and format.test/routes/session-routes-claude-model.test.tscreates sessions throughapp.inject(), starts each one, and reads the model the session hands the mux. It covers:modelandmodelOverridesent together, where the launch getsmodeland the case file getsmodelOverride;modelsent with codex refused before any session is made.test/session-model-recovery.test.tschecks thattoState()carries the model and that a session rebuilt from that state launches on it.restoreMuxSessions()can't be reached under vitest, so a source check pins both recovery constructors, the waytest/remote-wake.test.tspins its wiring.test/cli-registry-spawn-golden.test.tspins how a model renders, including one that opens with a dash: it lands as--model "--dangerously-skip-permissions", and Claude's option parser, Commander, takes the word after--modelas its value.No changeset, following the repository's convention for contributors.
🤖 Generated with Claude Code