Repository navigation
feat(models): set Claude Code's effort per model in each account - #173
Merged
Merged
Conversation
added 9 commits
November 7, 2026 22:32
Claude Code keeps a reasoning effort per model under `modelSettings.<model>.effortLevel`, while clauth's `effort` is one value for the whole account. Add a `[model_effort]` table to each account's config.toml, keyed by a `model` row value (a tier alias such as `sonnet`, or a model id), so an account can hold a level for each model it uses. The table sits apart from `[models]`, because presets replace `[models]` as a whole, and leaves the scalar `effort` as it is. It is modelled like `[env]`: every subkey is a modelled string, the generated config.toml carries its doc block and a commented `# [model_effort]` example, and the in-place writer edits it through the same table path `[env]` now shares (`edit_string_table`). A switch onto the account and a duplicate carry the table along with `effort`. Nothing reads the table yet; the next commit writes it into settings.json.
An account's per-model levels now land as `modelSettings.<model>.effortLevel`, the key Claude Code's `/effort` writes, so each model keeps its own level across `/model` and `claude --model`. The levels come from the `[model_effort]` table and, while the `model` row names one model, from the scalar `effort`: a value Claude Code keeps per model (low, medium, high, xhigh) is then that model's level instead of an account-wide one. `CLAUDE_CODE_EFFORT_LEVEL` outranks every per-model level, so `effective_effort` writes it empty in that case. With the row unset or on `opusplan` (two models), and for a `max` or custom scalar, which has no per-model form, the scalar stays on the carrier exactly as before. Keys follow Claude Code's own: a tier with a `[models]` row resolves to that row's id, a tier without one stays its alias (Claude Code resolves an alias key itself), and a Claude model id is written under its canonical name, with the dated, `-vN`, `[1m]`/`[2m]`, Bedrock and Vertex spellings mapped to one name, because within one settings file an exact canonical key beats every other spelling. Other ids are written as given. A `[model_effort]` value Claude Code would drop is skipped and logged once, and so is a table the account-wide effort overrides. A switch writes the levels into `~/.claude/settings.json` through a new record, `~/.clauth/model-effort.json`, with `base-env.json`'s rules: before covering a level the user set, the record saves it; a switch to an account that does not pin the model, or a switch-off, puts it back (or removes the key when there was none) unless the user changed it meanwhile; and an entry carries `pending` across the window between the record's pre-write and the live write, so a failed live write never turns the previous account's level into the user's. A record that does not parse refuses the apply. It is a separate file because `base-env.json` is version-pinned with `deny_unknown_fields`, so an older clauth still running after an update would refuse a new field. A session's runtime `settings.json` is built from the live file, so the build first puts back every level the record says clauth still owns there: a session started after `clauth switch a` never inherits a's levels, while a level the user set since stays. The settings sync now rules `modelSettings` per model, by canonical name: a model any account pins, or the record still covers, keeps its own level in each member, while every other model's settings (a `/effort` on a model no account pins) sync as before. `KeyPath::Nested` carries its parent object so the `env` and `modelSettings` rules never mix. An unreadable record pauses the sync like an unreadable `base-env.json`.
A live session moved to another account already took that account's `CLAUDE_CODE_EFFORT_LEVEL` through the swap's effort handover. It now takes the account's per-model levels too, in the same single write (`set_settings_effort`, formerly `set_settings_env_key`), so the session ends up with what a fresh launch on the account would write. The handover reads the incoming account's levels under the hold the caller already owns, writes them into the session's `modelSettings`, and puts every other pinned model (a model any account pins, by canonical name) back to the level a launch would see over the live `~/.claude/settings.json`, so a level only the outgoing account pinned never stays behind. A model no account pins is shared, so the swap leaves it to the settings sync. If the sync's view is unreadable, only the incoming levels land; an unreadable member hands over the carrier alone, logged, and the swap stands either way, as before. Whether a running Claude Code re-reads `modelSettings` on its own is not verified. If it reads them only at start, the new levels apply from the session's next restart, while the carrier still applies live.
The maintainer's suggestion on the issue: keep the `effort` row as it is while `model` is `[default]`, and when a model is selected, save the effort for that model only. The row now does that: - With `model` unset or on `opusplan`, it edits the account-wide `effort`, exactly as before, `max` and custom values included. `opusplan` stays account-wide because it runs two models. - With `model` naming one model (a tier or a model id), it shows and edits that model's level in `[model_effort]`. The cycle runs unset, low, medium, high, xhigh: `max` is left out because Claude Code keeps only those four per model. A typed value outside them is refused with a toast that names the four and points at `[default]` for an account-wide value. - An account that predates this (say `model = "opus"`, `effort = "high"`) shows its `effort` as opus's level, which is how it now applies. The first edit under the selected model moves the value into `[model_effort]` and clears the scalar. - Changing the `model` row reseeds the effort row, so it always shows the level of the model it now edits. The hints say which one the row edits: "reasoning effort for this model in this account" or "no level for this model: /effort and Claude Code's default apply" under a model, the existing account-wide hints otherwise.
Document the `[model_effort]` table and how `effort` behaves once the `model` row names a single model, under a new "Effort per model" section in Configuration: - the four values Claude Code keeps per model, and that `max` or a custom value stays on `CLAUDE_CODE_EFFORT_LEVEL` - how keys are written (tier through its `[models]` row, alias, or canonical Claude id) - precedence, including the account-wide carrier, the project, local and flag settings above the user layer, and Claude Code's `maxEffortLevel` caps - what a switch, a `clauth start` session and a swap do with the levels Also covered: the config.toml key table, the Setup tab's `effort` row (its cycle drops `max` under a model and refuses other values), the new `~/.clauth/model-effort.json` in the storage layout and in SECURITY.md's file table, and the `modelSettings` levels in both switch-rewrite lists. The swap section says plainly that whether a running Claude Code re-reads `modelSettings` is unverified.
An adversarial review of the per-model effort change found these, now fixed: - Two takeovers in a row whose live writes both failed lost the user's own level. The second pre-write set `pending` to the first takeover's level, which never landed, instead of to the level still live. It now records the live value clauth owns. - A swap restored the outgoing account's models from a walk of every profile's config.toml. One unrelated config that did not parse skipped the restore, and the outgoing account's levels stayed in the session. The swap plan now carries the outgoing account's own levels (read before the credentials move), and the handover restores a model only while the session still holds that account's level. A level the user changed in the session is kept, as uwuclxdy#168's proposal promises. - A live `~/.claude/settings.json` that did not read aborted the whole swap handover, `CLAUDE_CODE_EFFORT_LEVEL` included, so the session kept the outgoing account's account-wide effort. The carrier now lands regardless, and the per-model half is logged on failure. - A tier alias pinned without a `[models]` row (`sonnet = "xhigh"`) protected only the key `sonnet` in the settings sync, while `/effort` writes the tier's model under its canonical id. That id synced to the other accounts and beat their own alias pins. An alias pin now holds every `claude-<tier>-` id. - Canonical names now fold a dotted version (`claude-sonnet-4.5`) and a `-vN@YYYYMMDD` Vertex spelling, as Claude Code does. A moving alias such as `-latest` names no fixed model and stays as written. - The Setup tab's effort row looked up only the literal `model` value, so a `[model_effort]` entry under the selected tier's full id showed as unset and survived a clear. The row now reads and replaces every key that lands on the selected model. - The `+ new` form accepted a typed `max` under a selected model and saved it account-wide. It now refuses it as the saved account's row does. Each fix has a test that pins it.
Claude Code 2.1.316 reads a `-latest` or `-fast` trailer after a versioned Claude name as the same model (`claude-sonnet-4-5-latest` keys as `claude-sonnet-4-5`), so clauth now folds it too; a name with no version (`claude-opus-latest`) stays as written. On macOS a swap's settings handover waits for its Keychain legs. While those legs stay unlanded the session still carries the outgoing member's levels, so a swap that retargets meanwhile now takes back the armed retry's outgoing levels instead of those of the member the cell names, and an adopted retry, whose swap is gone, reads them from the member whose store the retry leaves. When two `[model_effort]` keys name the same model, the entry spelled like the `model` row wins, then the first in the table, and the Setup tab's effort row shows that same entry, so the row and a launch agree.
Claude Code 2.1.316 keys Sonnet 4 and Opus 4 as `claude-sonnet-4-0` and `claude-opus-4-0`, the only catalog ids that differ from the folded first-party name, so clauth now writes those keys for every spelling of the two models. A `-latest` or `-fast` trailer is dropped only after a name in Claude Code's versioned grammar, so an unknown id such as `claude-custom-123-latest` stays as written. The Setup tab's effort row shows the level a launch lands for the selected model first, so an entry Claude Code drops no longer hides the scalar that runs.
uwuclxdy
requested changes
Nov 9, 2026
uwuclxdy
left a comment
Owner
There was a problem hiding this comment.
Thanks for the detailed issue and PR. Four design changes before this can merge, and one question.
Design
- One record. The per-model levels should ride
base-env.jsonas a new field with a version bump, not a second file with its own copy of the pre-write/landed logic. An older clauth then refuses the bumped record loudly, where a separate file lets it silently leave the previous account's levels in~/.claude/settings.json(your "Not in this PR" case). It also gets the existing write-failure seams (FailBaseEnvSave,FailLiveSettingsWrite) for free. - Running sessions keep their effort. An empty
CLAUDE_CODE_EFFORT_LEVELputs a running session back to the model default within a second or two, and a running Claude Code builds its per-model table once at startup and never rebuilds it from a settings change (the/modelpicker reads that same cached table). So a swap orclauth switchontomodel = "opus",effort = "low"drops live sessions to opus's default, where today they getlow. The swap handover and an active-account Setup edit should write the selected model's level into that session's env var; a fresh launch keeps"". Inside a moved session/model sonnetthen keeps opus's level until a restart, which is fine. - Only
effortLevelper account. Keeping the wholemodelSettings.<model>object per account stopsautoCompactWindowandmaxEffortLevelfrom syncing too, for every pinned model. OnlymodelSettings.<model>.effortLevelshould stay per account. - Key naming. Claude Code canonicalizes every
modelSettingskey itself when it reads the file, and resolves a bare alias through the reading session'sANTHROPIC_DEFAULT_<TIER>_MODEL, so a key written as the alias, or as the[models]id as given, already lands on the model the session runs, Bedrock, Vertex and non-Claude ids included. The one gap is that an exact canonical key from a user's own/effortbeats an alias in the same file, which we'd cover by writing the level over every existingclaude-<tier>-*key too, with the record putting them back on a switch away.
Question: is a level per tier enough for your setups (the per-subscription opus and the gateway account from #168), or do you need levels per exact model id, e.g. claude-sonnet-4-5 and claude-sonnet-5-5 at different levels in one account? Per tier lets us drop the canonicalization entirely.
Tests
- each new user-visible string (both hints, both refusals, both log lines) gets an assertion by equality, so reverting the copy reds.
apply_runtimewith a record present and nomodelSettingsin the base, a non-objectmodelSettings, and a record from another version have no test.- the
build_claude_settings_jsondoc comment still sayseffortLevelis never written there.
This was referenced Nov 16, 2026
siddicky
pushed a commit
to siddicky/clauth
that referenced
this pull request
Nov 16, 2026
siddicky
pushed a commit
to siddicky/clauth
that referenced
this pull request
Nov 16, 2026
uwuclxdy
added a commit
that referenced
this pull request
Nov 24, 2026
The Setup row, a moved session and an edit or clear all read one decider, so they agree on what clauth hands Claude Code. refs #173
siddicky
added a commit
to siddicky/clauth
that referenced
this pull request
Nov 26, 2026
Brings in the per-model effort work from uwuclxdy#173. The four conflicts keep both features: modelPicker and modelSettings effort levels are written side by side, the [model_picker] and [model_effort] doc blocks both render, and the doc-digest and table-set tests list both tables.
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.
Summary
Closes #168.
This PR adds per-model reasoning effort to each account, following the design suggested in #168: the
effortrow keeps working as it does today whilemodelis[default], and saves the effort for the selected model only while a model is selected. It implements the example from that comment as given: withxhighset onsonnetandopusselected with its own effort,claude --model sonnetruns atxhighandclauderuns at opus's level.There's one commit per part, two docs commits, and three
fix(models)commits with fixes from review.feat(profile)adds a[model_effort]table to config.toml. It's keyed by amodelrow value (a tier such assonnet, or a model id) and sits outside[models], because presets replace[models]as a whole. It's modelled like[env]: a doc block, a commented example, and the same in-place table writer, which[env]now shares (edit_string_table). A switch and a duplicate carry it along witheffort.feat(models)writes the levels intosettings.json. Each level lands asmodelSettings.<model>.effortLevel, the key Claude Code's/effortwrites, so a model keeps its level across/modelandclaude --model.modelrow names one model, fromeffort. A value Claude Code keeps per model (low,medium,high,xhigh) is then that model's level.CLAUDE_CODE_EFFORT_LEVELoutranks every per-model level, soeffective_effortwrites it empty in that case. Withmodelunset, onopusplan(two models), or with amaxor customeffort(no per-model form), the carrier works exactly as before.[models]row is written under that row's id, and a tier without one under its alias. A Claude id is written under Claude Code's canonical name, with the dated,-vN,[1m], dotted-version,-latest, Bedrock and Vertex spellings mapped to one name (Sonnet 4 and Opus 4 under their catalog ids,claude-sonnet-4-0andclaude-opus-4-0), because an exact canonical key beats every other spelling in the same file. Other ids are written as given.~/.claude/settings.jsonthrough a new record,~/.clauth/model-effort.json. It follows the same rules asbase-env.json: save the user's own level before covering it, and put it back on a switch away or a switch-off unless the user changed it meanwhile. Apendingguard covers a live write that fails after the record's pre-write.clauth startafterclauth switch anever inherits a's levels.KeyPath::Nestednow names its parent so theenvandmodelSettingsrules can't mix.feat(runtime)gives a swapped session the new account's levels in the same write as the existingCLAUDE_CODE_EFFORT_LEVELhandover (set_settings_effort, formerlyset_settings_env_key). A model only the outgoing account pinned goes back to what a fresh launch would write.feat(tui)routes the Setup tab'seffortrow by themodelrow. Under[default]oropusplanit edits the account-wideeffortas before. Under a selected model it edits that model's entry and clearseffort.docs(wiki)adds a "Effort per model" section to Configuration and updates the Setup tab row, the config key table, the storage layout, and both switch-rewrite lists (SECURITY.md, wiki/Security.md).Design calls on top of the suggestion in #168
opusplankeeps the account-wide effort. It runs opus in plan mode and sonnet otherwise, so a single per-model level has no one model to land on.maxper model. Claude Code 2.1.316's settings schema formodelSettings.<model>.effortLevelislow | medium | high | xhigh, and it drops anything else without a warning. Under a selected model the cycle leavesmaxout, and a typed value outside those four is refused.maxis still available account-wide.model = "opus"andeffort = "high"now runs opus athighand other models at their own level, where beforehighcovered every model. Amaxor customeffortstays account-wide.base-env.jsonis version-pinned withdeny_unknown_fields, so an older clauth still running after an update would refuse a new field in it. Generalizing that record instead is doable if you'd prefer it, and the new record sits behind two functions and one plan type (apply_live,apply_runtime,LivePlan) insrc/model_effort.rs.User-visible changes
effortrow edits the selected model's level whilemodelnames one model. Under a model its cycle isunset,low,medium,high,xhigh. I leftmaxout because Claude Code drops it per model. A typed value outside those four gets a toast: "effort not saved / a model's own level is one of low, medium, high, xhigh; setmodelto default for an account-wide value". The hints read "reasoning effort for this model in this account" and "no level for this model: /effort and Claude Code's default apply". Changing themodelrow reseeds the effort row.claude --model <other>no longer inherits a selected model's effort. Withmodel = "opus"andeffort = "high",CLAUDE_CODE_EFFORT_LEVELis now written empty andhighlands under opus only. I changed this because the env var outranks every per-model level, so keeping it would make per-model effort impossible.[model_effort]block appears in each generated config.toml, as a commented example until it's set.~/.claude/settings.jsonand records the user's own in the new~/.clauth/model-effort.json(0600). A record that doesn't parse refuses the switch, fails a sharedclauth start, and pauses the settings sync, asbase-env.jsondoes.modelSettingsper model object, so for a pinned model a/effortand also a/autocompact(autoCompactWindow) ormaxEffortLevelstay with the account. Every other model's settings sync as before.claudewithout a restart, after a short delay. Claude Code picks up themodelSettingschange fromsettings.jsonon its own; before this change the edit went through the env carrier.[model_effort]value, and per-model levels that an account-wide effort overrides.Not in this PR
modelSettingsas shared and doesn't know the record, so its switches leave the previous account's levels in place until a current clauth applies.Testing
cargo fmt --all -- --checkpasses.cargo clippy --locked --all-targets --all-features -- -D warningspasses on each commit.cargo test --locked --all-features: 10985 passed, 54 failed, 15 ignored on the lib suite at the feature commits. After the review fixes,-- --skip usage::schedulergives 10624 passed and 1 failed; that one (mcp::startup_tests::startup_herdr_heal_follows_the_saved_update_toggle) spawns a process and passed on three reruns alone. Onmommyatceb3ab36, on my machine: 10960 passed, 54 failed. The 25 extra passes are the tests this PR adds, and the 54 failures are the same tests on both.usage::scheduler, and all fail withchild … never finished its exec(the 10 s deadline in the test fixture'sawait_exec).-- usage::scheduler), they fail the same way on both trees: 629 passed, 54 failed. So this is how this machine runs spawned processes, not load. This PR doesn't touch the scheduler.Every integration test binary passes (
cargo test --locked --all-features --test '*', 18 binaries).The new tests are in
tests/inline/model_effort.rs,settings_sync.rs,tui_app.rs,tui_render_config.rsandprofile.rs. They cover:pendingguard);Manual check with a release build of this branch on Claude Code 2.1.316. An account with
model = "opus"and[model_effort] opus = "high",sonnet = "xhigh"was launched withclauth start. In the session,/model opusshowedhighand/model sonnetshowedxhigh. Afterclauth switch work, plainclaude --model sonnetstarted atxhigh, and a/effortlevel set as the default in plainclaudecame back after switching away. Editing a level on the Setup tab during a running session reached/modelwithout a restart, after a short delay.Screenshots (c6d579f, throwaway HOME, an API-key account whose [models] map opus to kimi-k3.1-pro-uncensored and sonnet and haiku to deepseek-v4.1-flash-1017-uncensored, with effort = "high" and [model_effort] sonnet = "low")
The /model shots are Claude Code 2.1.323 reading the settings.json this branch builds for that account, in a throwaway config dir with a dummy key and a base URL that goes nowhere.
Checklist
sk-ant-*, no~/.claude/~/.clauthcontents)cargo fmt --all -- --check,cargo clippy --locked --all-targets --all-features -- -D warningsandcargo test --locked --all-featurespass locally (fmt and clippy pass; 54 scheduler tests fail the same way onmommy, see Testing)AI