Repository navigation
feat(sessions): accept a per-session Claude model on POST /api/sessions - #514
Merged
Ark0N merged 2 commits intoOct 4, 2026
Merged
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
Ark0N
pushed a commit
that referenced
this pull request
Oct 4, 2026
…dvisor (#514, #515, #530 landing) Maintainer merge-time fixes for the three PRs that landed together on the session create / launch / persistence path. #514 findings (bot verdict merge-with-fixes): - minor, fixed: SessionState.model was published and persisted for every mode, so a codex/opencode cron session reported the app-wide Claude default it never ran on. toState() now emits it only where the new cliTakesSessionModel() holds (registry capability model.source === 'claude-settings-file', no CLI id branch). POST /api/sessions uses the same helper for its non-claude refusal, so refusal and publication cannot drift. Recovery then hands back undefined for other modes on its own. - nit, fixed: the `model` schema admitted a leading dash (and '.', '['). The first character must now be a letter or digit; still a subset of the registry's model-claude pattern, so nothing accepted is refused at launch. - nit, fixed (reject, the consistent choice): `model` with attachRemoteSession was silently dropped. Now a 400 INVALID_INPUT, as #514 does for non-claude CLIs and quick-start does for remote cases. advisorModel (#530) gets the same refusal there. effort and envOverrides keep their older silent ignore on that branch so no existing caller breaks. #515 finding (bot verdict merge, one nit): - nit, fixed: the types/session.ts @fileoverview described CodexConfig as (model, resumeSessionId); it now lists reasoningEffort, bypass, animations and renderMode too. Audit of the merged combination (not reviewed before): - The conflict resolutions in session.ts (toState), types/session.ts, reboot-restore-routes.ts, server.ts (restoreMuxSessions), CLAUDE.md and skills/codeman/reference/endpoints.md (+ plugin mirror) keep both sides correctly; nothing was lost or doubled. - A claude session with both `model` and `advisorModel` launches with `--model <id>` and ONE merged `--settings` JSON (ultracode + advisorModel, or advisorModel beside `--effort <level>`), on the tmux template (including the resume || new variant and with the statusLine exporter) and on the direct-PTY fallback. Both values (and effort) survive restoreMuxSessions onto a dead pane, a reboot restore into a fresh pane, and restartCli/dead-pane respawn via _buildRespawnPaneOptions. - quick-start and ralph-loop take no per-session `model` (matching #514's scope, POST /api/sessions only) and launch on the app-wide default, which toState now persists for claude, so recovery stays consistent. - No defect found in the combination beyond the findings above. Noted, not changed: advisorModel is still published for any mode a caller sends it with (launch-inert there; the UI and skill send it for claude only). Tests: test/session-model-recovery.test.ts pins the pair through both recovery shapes for effort ultracode/high/none, the recovery constructors' fields, the tmux-manager builder hop, and the codex/opencode/shell non-publication; test/advisor-model.test.ts pins the launch lines and a real direct-PTY Session's pty.spawn argv; the route test covers flag-shaped models, attach refusals and the published fields. Docs: SessionState.model docstring, the reboot-restore-registry header, the golden test comment and the CLAUDE.md model/advisor bullets. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Owner
|
Merged and shipped in 1.34.0. Thanks @irisitymichaelgrundberg! Keying the non-Claude refusal on the registry's model source instead of a CLI id, and carrying the model through both recovery paths, is exactly right. The CLAUDE.md rewrite of the "NOT A few items were applied while landing (06c4c7d):
|
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