Skip to content

feat(models): set Claude Code's effort per model in each account - #173

Merged
uwuclxdy merged 13 commits into
uwuclxdy:mommyfrom
siddicky:feat/model-effort
Nov 25, 2026
Merged

uwuclxdy merged 13 commits into
uwuclxdy:mommyfrom
siddicky:feat/model-effort

Conversation

@siddicky

@siddicky siddicky commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Closes #168.

This PR adds per-model reasoning effort to each account, following the design suggested in #168: the effort row keeps working as it does today while model is [default], and saves the effort for the selected model only while a model is selected. It implements the example from that comment as given: with xhigh set on sonnet and opus selected with its own effort, claude --model sonnet runs at xhigh and claude runs at opus's level.

There's one commit per part, two docs commits, and three fix(models) commits with fixes from review.

  1. feat(profile) adds a [model_effort] table to config.toml. It's keyed by a model row value (a tier such as sonnet, 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 with effort.
  2. feat(models) writes the levels into settings.json. Each level lands as modelSettings.<model>.effortLevel, the key Claude Code's /effort writes, so a model keeps its level across /model and claude --model.
    • Where levels come from. They come from the table and, while the model row names one model, from effort. A value Claude Code keeps per model (low, medium, high, xhigh) is then that model's level.
    • The env carrier. CLAUDE_CODE_EFFORT_LEVEL outranks every per-model level, so effective_effort writes it empty in that case. With model unset, on opusplan (two models), or with a max or custom effort (no per-model form), the carrier works exactly as before.
    • Key names. A tier with a [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-0 and claude-opus-4-0), because an exact canonical key beats every other spelling in the same file. Other ids are written as given.
    • Switch. A switch lands the levels in ~/.claude/settings.json through a new record, ~/.clauth/model-effort.json. It follows the same rules as base-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. A pending guard covers a live write that fails after the record's pre-write.
    • Sessions. A session's runtime build first puts back the levels a switch wrote into the live file, so a clauth start after clauth switch a never inherits a's levels.
    • Settings sync. The sync now keeps a pinned model per account, matched by canonical name, and keeps syncing every other model's settings. KeyPath::Nested now names its parent so the env and modelSettings rules can't mix.
  3. feat(runtime) gives a swapped session the new account's levels in the same write as the existing CLAUDE_CODE_EFFORT_LEVEL handover (set_settings_effort, formerly set_settings_env_key). A model only the outgoing account pinned goes back to what a fresh launch would write.
  4. feat(tui) routes the Setup tab's effort row by the model row. Under [default] or opusplan it edits the account-wide effort as before. Under a selected model it edits that model's entry and clears effort.
  5. 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

  • opusplan keeps 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.
  • No max per model. Claude Code 2.1.316's settings schema for modelSettings.<model>.effortLevel is low | medium | high | xhigh, and it drops anything else without a warning. Under a selected model the cycle leaves max out, and a typed value outside those four is refused. max is still available account-wide.
  • Existing configs keep working. An account with model = "opus" and effort = "high" now runs opus at high and other models at their own level, where before high covered every model. A max or custom effort stays account-wide.
  • The switch record is a separate file. base-env.json is version-pinned with deny_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) in src/model_effort.rs.

User-visible changes

  • The effort row edits the selected model's level while model names one model. Under a model its cycle is unset, low, medium, high, xhigh. I left max out 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; set model to 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 the model row reseeds the effort row.
  • claude --model <other> no longer inherits a selected model's effort. With model = "opus" and effort = "high", CLAUDE_CODE_EFFORT_LEVEL is now written empty and high lands under opus only. I changed this because the env var outranks every per-model level, so keeping it would make per-model effort impossible.
  • A new [model_effort] block appears in each generated config.toml, as a commented example until it's set.
  • A switch writes per-model levels into ~/.claude/settings.json and records the user's own in the new ~/.clauth/model-effort.json (0600). A record that doesn't parse refuses the switch, fails a shared clauth start, and pauses the settings sync, as base-env.json does.
  • A model some account pins stops syncing across accounts' sessions, all of its settings included. The sync rules modelSettings per model object, so for a pinned model a /effort and also a /autocompact (autoCompactWindow) or maxEffortLevel stay with the account. Every other model's settings sync as before.
  • On the active account, an edit to a selected model's level reaches a running claude without a restart, after a short delay. Claude Code picks up the modelSettings change from settings.json on its own; before this change the edit went through the env carrier.
  • Two new log lines, once per account and process: an invalid [model_effort] value, and per-model levels that an account-wide effort overrides.

Not in this PR

  • An older clauth can leave levels behind. One still running across the update (a daemon or TUI) treats modelSettings as 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 -- --check passes.

  • cargo clippy --locked --all-targets --all-features -- -D warnings passes 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::scheduler gives 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. On mommy at ceb3ab36, 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.

    • All 54 are in usage::scheduler, and all fail with child … never finished its exec (the 10 s deadline in the test fixture's await_exec).
    • Run alone (-- 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.rs and profile.rs. They cover:

    • the canonical-name and resolver rules;
    • a switch saving and restoring the user's level;
    • a level the user changes while covered;
    • a takeover whose live write fails after the record's pre-write (it fails without the pending guard);
    • a session started after a switch;
    • a torn record refusing both the build and the switch;
    • the swap handover;
    • the sync's per-model rule;
    • the Setup tab's routing, refusal and cycle.
  • 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 with clauth start. In the session, /model opus showed high and /model sonnet showed xhigh. After clauth switch work, plain claude --model sonnet started at xhigh, and a /effort level set as the default in plain claude came back after switching away. Editing a level on the Setup tab during a running session reached /model without 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")

    Setup: model opus, effort high, no max
    Setup: model set to sonnet, effort reseeds to low
    Claude Code /model: the custom Opus model at high effort
    Claude Code /model: the custom Sonnet model at low effort

    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

  • Secrets redacted from any pasted output (no sk-ant-*, no ~/.claude/~/.clauth contents)
  • cargo fmt --all -- --check, cargo clippy --locked --all-targets --all-features -- -D warnings and cargo test --locked --all-features pass locally (fmt and clippy pass; 54 scheduler tests fail the same way on mommy, see Testing)

AI

  • no AI
  • AI-assisted, I reviewed everything
  • AI did most of it under my direction

Abdullah Siddique 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.
@siddicky siddicky changed the title Feat/model effort feat(models): set Claude Code's effort per model in each account Nov 8, 2026

@uwuclxdy uwuclxdy left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.json as 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_LEVEL puts 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 /model picker reads that same cached table). So a swap or clauth switch onto model = "opus", effort = "low" drops live sessions to opus's default, where today they get low. 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 sonnet then keeps opus's level until a restart, which is fine.
  • Only effortLevel per account. Keeping the whole modelSettings.<model> object per account stops autoCompactWindow and maxEffortLevel from syncing too, for every pinned model. Only modelSettings.<model>.effortLevel should stay per account.
  • Key naming. Claude Code canonicalizes every modelSettings key itself when it reads the file, and resolves a bare alias through the reading session's ANTHROPIC_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 /effort beats an alias in the same file, which we'd cover by writing the level over every existing claude-<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_runtime with a record present and no modelSettings in the base, a non-object modelSettings, and a record from another version have no test.
  • the build_claude_settings_json doc comment still says effortLevel is never written there.

Comment thread src/claude.rs Resolved
Comment thread src/model_effort.rs Resolved
Comment thread src/model_effort.rs Resolved
Comment thread src/model_effort.rs Resolved
Comment thread src/model_effort.rs Resolved
Comment thread wiki/Configuration.md Resolved
Comment thread src/actions.rs Resolved
Comment thread src/profile.rs Resolved
Comment thread src/profile.rs Resolved
Comment thread src/runtime.rs Resolved
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
uwuclxdy added a commit that referenced this pull request Nov 24, 2026
uwuclxdy added a commit that referenced this pull request Nov 24, 2026
@uwuclxdy
uwuclxdy merged commit f770e19 into uwuclxdy:mommy Nov 25, 2026
6 checks passed
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature: set effort per model in each account

2 participants