The model option's currentValue names the model in use, not 'default' or an alias #12

Merged
city-root merged 2 commits from worker/claudeacp-9lf into main 2026-11-12 16:22:09 +00:00
Contributor

What was wrong

The model option's current value (and its values) were entries of claude's list of models: default, opus, sonnet. A session pinned to --model claude-opus-5-5 showed default, and so did one with no --model. Claude 2.1.322 answers initialize with current_model: null whatever --model says (probed), and lists default and opus as one model, claude-opus-5-5, so the agent had only the alias to show.

The first commit is a test that fails on main and shows this; the second is the fix.

What changes

The option's values are the list's resolvedModel (the alias where claude names none), one value for entries that share an id. The current value is the id of the model the session runs on:

  • at start: the id --model / _meta.claudeCode.options.model names (an alias is read as the id it resolves to; an id the list doesn't name, such as --model claude-opus-4-1, is kept as it is and keeps the effort and fast options of the listed model of its kind), else the id the default resolves to;
  • after a switch (the client's, claude's system/init, a refusal's fallback): the new model's id.

What a client must send

Reading changes, sending does not. A client that keys on the old values (default, opus, sonnet) has to key on ids; the changelog entry is marked Breaking for that. To set the option a client sends one of its values, as before; an id or an alias of claude's list is still accepted, and claude is told the alias as before. Setting the id a session is pinned to is a no-op; setting the listed model of its kind switches to it.

Behaviour to know: a --model that matches no model of the list at all (neither by id, alias nor by containing an alias) now shows as given, with no effort or fast option, as a fallback model already did; before it showed default with the default's options.

Checks

go vet, go test ./..., golangci-lint run (v2): clean. New: TestModelOptionNamesModel, TestModelOptionSet, TestModelOptionFollowsClaude, TestModelOptionPinnedID, against the list claude 2.1.322 really sends. Existing option tests updated to ids. README (config options) and CHANGELOG updated. The rexcity half of the feature is rexcity-49in3.

Bead: claudeacp-9lf

## What was wrong The model option's current value (and its values) were entries of claude's list of models: `default`, `opus`, `sonnet`. A session pinned to `--model claude-opus-5-5` showed `default`, and so did one with no `--model`. Claude 2.1.322 answers `initialize` with `current_model: null` whatever `--model` says (probed), and lists `default` and `opus` as one model, `claude-opus-5-5`, so the agent had only the alias to show. The first commit is a test that fails on main and shows this; the second is the fix. ## What changes The option's values are the list's `resolvedModel` (the alias where claude names none), one value for entries that share an id. The current value is the id of the model the session runs on: - at start: the id `--model` / `_meta.claudeCode.options.model` names (an alias is read as the id it resolves to; an id the list doesn't name, such as `--model claude-opus-4-1`, is kept as it is and keeps the effort and fast options of the listed model of its kind), else the id the default resolves to; - after a switch (the client's, claude's `system/init`, a refusal's fallback): the new model's id. ## What a client must send **Reading changes, sending does not.** A client that keys on the old values (`default`, `opus`, `sonnet`) has to key on ids; the changelog entry is marked **Breaking** for that. To set the option a client sends one of its values, as before; an id or an alias of claude's list is still accepted, and claude is told the alias as before. Setting the id a session is pinned to is a no-op; setting the listed model of its kind switches to it. Behaviour to know: a `--model` that matches no model of the list at all (neither by id, alias nor by containing an alias) now shows as given, with no effort or fast option, as a fallback model already did; before it showed `default` with the default's options. ## Checks `go vet`, `go test ./...`, `golangci-lint run` (v2): clean. New: `TestModelOptionNamesModel`, `TestModelOptionSet`, `TestModelOptionFollowsClaude`, `TestModelOptionPinnedID`, against the list claude 2.1.322 really sends. Existing option tests updated to ids. README (config options) and CHANGELOG updated. The rexcity half of the feature is rexcity-49in3. Bead: claudeacp-9lf
Shows the behaviour the bead reports, against claude 2.1.322's real list of
models (probed with an initialize request): its answer has current_model
null whatever --model says, so the agent resolves the option from the
command line, and the option's value is the list's alias: "default" with no
--model or --model claude-opus-5-5, "sonnet" for --model sonnet. Default
and "opus" both resolve to claude-opus-5-5 and are two values of the list.

These tests fail on main and pass with the next commit.
fix: the model option's current value is the id of the model in use (claudeacp-9lf)
All checks were successful
CI / Changelog (pull_request) Successful in 5s
CI / Lint (pull_request) Successful in 32s
CI / Test (pull_request) Successful in 42s
c875d0169f
The option's values were the entries of claude's list of models ("default",
"opus", "sonnet"), so a session pinned to --model claude-opus-5-5, or with
no --model at all, showed "default"; claude 2.1.322 answers initialize with
current_model null whatever --model says, so the agent had only the list to
go by, and lists the default and "opus" as one model, claude-opus-5-5.

Now the option's values are the entries' resolvedModel (the alias where
claude names none), one value for entries that share an id, and the current
value is the id of the model the session runs on:

- at start, the id --model or _meta.claudeCode.options.model names: an alias
  is read as the id it resolves to; an id the list doesn't name is kept as
  it is (config.pinned when it only loosely names a listed model, so the
  option keeps that model's effort and fast mode), else the model the
  default resolves to;
- after a switch of the client's, claude's own (system/init, a refusal's
  fallback) or a /model, the new model's id.

What a client sends doesn't change: setModel still looks a value up by id,
alias or loosely, and tells claude the alias. Setting the id a session is
pinned to is a no-op; setting the listed model of its kind switches.

Validation: TestModelOption* (new; the first commit shows them failing on
main), the existing option tests updated to ids, go vet, golangci-lint
v2, and claude 2.1.322's real initialize answer for the list the tests use.
city-root-review left a comment

Review of c875d0169f for claudeacp-9lf. Checks of the head: success.

Verdict

pass

Findings

  • [minor] claudeacp/config.go:195: the comment "The values are ids, so the current one is among them" is not true for a session pinned to an id the list doesn't name (--model claude-opus-4-1, which TestModelOptionNamesModel itself expects as claude-opus-4-1[claude-opus-5-5 …]) or for a refusal's fallback model. The current value is outside the values there, as it already was for a fallback before this change. Reword the comment to say so. A client that renders a select only from its values will show such a session without a selected entry, which is worth one clause in the README.
  • [minor] claudeacp/config.go:300-310 (modelSwitched): the news is now judged on the shown value only. A session pinned to claude-opus-4-1 (model=opus, pinned=claude-opus-4-1) that gets a PostModelSwitch to claude-opus-4-1 ends with c.model="claude-opus-4-1", pinned="": modelInfo() is nil, so the effort and fast options are gone. The function returns false, and the client is not told. That switch is unlikely in practice (a fallback goes to another model), so this does not block. Comparing c.model as well as the shown value would cover it.

Verified

  • Read the work bead claudeacp-9lf, the PR description, the README of main (there is no REVIEW.md, AGENTS.md or CLAUDE.md) and the whole diff (8 files, +222 −46). The change does what the bead asks:
    • with --model, the current value is the id --model names (an alias read as its resolvedModel, an unlisted id kept as given);
    • without --model, it is the id the default resolves to;
    • after a switch (the client's set, system/init, PostModelSwitch), it is the new model's id.
  • The bead asked to show the current behaviour first. At e2a734d (the test commit alone), go test -run TestModelOption ./claudeacp fails on all three new tests (default[default opus fable sonnet haiku] where claude-opus-5-5[…] is wanted, and so on). At the head they pass.
  • What a client sends: the PR says reading changes and sending does not. The changelog entry is marked Breaking, and the README's config-options line describes the new values. setModel still accepts an option value, an id or an alias and sends claude the alias (TestModelOptionSet, TestModelOptionPinnedID, the updated TestSetConfigOption). I traced lookup for --model claude-opus-5-5: it maps to the default entry by resolvedModel and shows claude-opus-5-5, which is the Worker's case from the bead.
  • Merge into origin/main (1d1bd8d): clean, a fast-forward.
  • Run on the merged tree with the city's variables removed: go build ./..., go vet ./..., go test -race -shuffle=on ./... all ok. golangci-lint v2.15.0 (built from the module cache): 0 issues. The changelog checker, built from mikluko/changelog at 087d7e8 (v2.1.0, the commit the workflow pins) and run with the action's defaults and -fragments= -base=main: valid=true.
  • Not run: govulncheck, which needs the vulnerability database over the network. The change adds no dependency.
  • Not a finding, and present before this change: a pinned session's context window is still that of the listed model of its kind (currentModel returns c.model, not pinned).
Review of c875d0169fa97e7ae4173993e70e821df7fd4296 for claudeacp-9lf. Checks of the head: success. ### Verdict pass ### Findings - [minor] claudeacp/config.go:195: the comment "The values are ids, so the current one is among them" is not true for a session pinned to an id the list doesn't name (`--model claude-opus-4-1`, which `TestModelOptionNamesModel` itself expects as `claude-opus-4-1[claude-opus-5-5 …]`) or for a refusal's fallback model. The current value is outside the values there, as it already was for a fallback before this change. Reword the comment to say so. A client that renders a select only from its values will show such a session without a selected entry, which is worth one clause in the README. - [minor] claudeacp/config.go:300-310 (`modelSwitched`): the news is now judged on the shown value only. A session pinned to `claude-opus-4-1` (`model=opus`, `pinned=claude-opus-4-1`) that gets a PostModelSwitch to `claude-opus-4-1` ends with `c.model="claude-opus-4-1"`, `pinned=""`: `modelInfo()` is nil, so the effort and fast options are gone. The function returns false, and the client is not told. That switch is unlikely in practice (a fallback goes to another model), so this does not block. Comparing `c.model` as well as the shown value would cover it. ### Verified - Read the work bead claudeacp-9lf, the PR description, the README of `main` (there is no REVIEW.md, AGENTS.md or CLAUDE.md) and the whole diff (8 files, +222 −46). The change does what the bead asks: - with `--model`, the current value is the id `--model` names (an alias read as its `resolvedModel`, an unlisted id kept as given); - without `--model`, it is the id the default resolves to; - after a switch (the client's set, `system/init`, PostModelSwitch), it is the new model's id. - The bead asked to show the current behaviour first. At e2a734d (the test commit alone), `go test -run TestModelOption ./claudeacp` fails on all three new tests (`default[default opus fable sonnet haiku]` where `claude-opus-5-5[…]` is wanted, and so on). At the head they pass. - What a client sends: the PR says reading changes and sending does not. The changelog entry is marked **Breaking**, and the README's config-options line describes the new values. `setModel` still accepts an option value, an id or an alias and sends claude the alias (`TestModelOptionSet`, `TestModelOptionPinnedID`, the updated `TestSetConfigOption`). I traced `lookup` for `--model claude-opus-5-5`: it maps to the `default` entry by `resolvedModel` and shows `claude-opus-5-5`, which is the Worker's case from the bead. - Merge into `origin/main` (1d1bd8d): clean, a fast-forward. - Run on the merged tree with the city's variables removed: `go build ./...`, `go vet ./...`, `go test -race -shuffle=on ./...` all ok. `golangci-lint` v2.15.0 (built from the module cache): 0 issues. The changelog checker, built from mikluko/changelog at 087d7e8 (v2.1.0, the commit the workflow pins) and run with the action's defaults and `-fragments= -base=main`: `valid=true`. - Not run: `govulncheck`, which needs the vulnerability database over the network. The change adds no dependency. - Not a finding, and present before this change: a pinned session's context window is still that of the listed model of its kind (`currentModel` returns `c.model`, not `pinned`).
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
mikluko/claudeacp!12
No description provided.