Repository navigation
Build the Claude Code model picker from Claude Code's own model list - #4084
Merged
SawyerHood merged 1 commit intoSep 22, 2026
Merged
SawyerHood merged 1 commit into
SawyerHood merged 1 commit into
Conversation
The picker was a hardcoded catalog with discovered models appended below it, so a new Claude Code default (Opus 5.5) appeared sixth under a generic alias label while the stale hardcoded Opus 5 stayed on top. The list now comes only from Claude Code's initialization report, in its order, with display names derived from the resolved model id and aliases offered as selected-only entries. The curated catalog, the selected-only legacy catalog, and the server-side fallback list are removed; an empty report counts as a discovery failure so the last stored catalog keeps serving. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
SawyerHood
deleted the
bb/yo-what-up-right-now-i-don-t-know-what-s-happeni-thr_yvuhy6ap7b
branch
September 22, 2026 18:42
andrewkchan
added a commit
that referenced
this pull request
Sep 22, 2026
Every automated check of bb's Claude Code model catalog replaces the Agent SDK's `query()` with a mock returning a fixture the repo authored itself, so an upstream CLI release that breaks the probe passes CI silently. The picker shipped broken for a week that way: `models.fallback` served a stale catalog until #4084 removed it, at which point the failure surfaced to users as "Could not load models for Claude Code." A test that catches this already exists — `integration.provider-basic.test.ts` "lists models" — but `test:integration` is referenced nowhere in `.github/`, so it only ever runs when someone remembers to run it locally against an authenticated CLI. Add a CI job that installs the latest Claude Code CLI, authenticates it from a repository secret, and runs that probe on pushes and same-repo pull requests. The CLI reads CLAUDE_CODE_OAUTH_TOKEN, which `claude setup-token` mints as a long-lived credential; the credentials file written by `/login` holds an ~8-hour access token and would start rotting immediately in an ephemeral runner. Two layers stripped that variable before the CLI could see it: - The bridge environment is an allowlist, and provider-claude-code declared only BB_CLAUDE_CODE_EXECUTABLE. This also meant a bb user authenticating Claude Code by token could not drive the provider at all, on any machine. - Turbo strips undeclared variables, so the live-CLI tasks dropped it before vitest started. BB_CLAUDE_CODE_EXECUTABLE was silently inert there too. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
andrewkchan
added a commit
that referenced
this pull request
Sep 22, 2026
Every automated check of bb's Claude Code model catalog replaces the Agent SDK's `query()` with a mock returning a fixture the repo authored itself, so an upstream CLI release that breaks the probe passes CI silently. The picker shipped broken for a week that way: `models.fallback` served a stale catalog until #4084 removed it, at which point the failure surfaced to users as "Could not load models for Claude Code." A test that catches this already exists — `integration.provider-basic.test.ts` "lists models" — but `test:integration` is referenced nowhere in `.github/`, so it only ever runs when someone remembers to run it locally against an authenticated CLI. Add a CI job that installs the Claude Code CLI, authenticates it from a repository secret, and runs that probe on pushes and same-repo pull requests. The job installs the native build through claude.ai/install.sh rather than the npm package. bb resolves `claude` from PATH and then `~/.local/bin`, so the native build is what most users run, and the two are not interchangeable despite sharing a version number: 2.1.280 native exits silently on `--setting-sources=` where 2.1.280 from npm answers normally. An npm-only job reports green through that regression, which is how this job first passed. The CLI reads CLAUDE_CODE_OAUTH_TOKEN, which `claude setup-token` mints as a long-lived credential; the credentials file written by `/login` holds an ~8-hour access token and would start rotting immediately in an ephemeral runner. Two layers stripped that variable before the CLI could see it: - The bridge environment is an allowlist, and provider-claude-code declared only BB_CLAUDE_CODE_EXECUTABLE. This also meant a bb user authenticating Claude Code by token could not drive the provider at all, on any machine. - Turbo strips undeclared variables, so the live-CLI tasks dropped it before vitest started. BB_CLAUDE_CODE_EXECUTABLE was silently inert there too. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
andrewkchan
added a commit
that referenced
this pull request
Sep 23, 2026
Every automated check of bb's Claude Code model catalog replaces the Agent SDK's `query()` with a mock returning a fixture the repo authored itself, so an upstream CLI release that breaks the probe passes CI silently. The picker shipped broken for a week that way: `models.fallback` served a stale catalog until #4084 removed it, at which point the failure surfaced to users as "Could not load models for Claude Code." A test that catches a broken probe already exists — `integration.provider-basic.test.ts` "lists models" — but `test:integration` is referenced nowhere in `.github/`, so it only ever runs when someone remembers to run it locally against an authenticated CLI. Add a CI job that installs the Claude Code CLI, authenticates it from a repository secret, and runs that probe on pushes and same-repo pull requests. It installs the native build through claude.ai/install.sh rather than the npm package, because bb resolves `claude` from PATH and then `~/.local/bin`, so the native build is the binary most users run. The job is expected to pass, including on this commit. It is general coverage for the probe, not a reproduction of the defect that motivated it: that one is specific to the macOS native build, which exits when the settings set it loads is empty. Linux does not exhibit it, so reproducing it needs a macOS leg. The CLI reads CLAUDE_CODE_OAUTH_TOKEN, which `claude setup-token` mints as a long-lived credential; the credentials file written by `/login` holds an ~8-hour access token and would start rotting immediately in an ephemeral runner. Two layers stripped that variable before the CLI could see it: - The bridge environment is an allowlist, and provider-claude-code declared only BB_CLAUDE_CODE_EXECUTABLE. This also meant a bb user authenticating Claude Code by token could not drive the provider at all, on any machine. - Turbo strips undeclared variables, so the live-CLI tasks dropped it before vitest started. BB_CLAUDE_CODE_EXECUTABLE was silently inert there too. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
andrewkchan
added a commit
that referenced
this pull request
Sep 23, 2026
Every automated check of bb's Claude Code model catalog mocks the Agent SDK's `query()`, so nothing in CI ever spawned a real `claude`. The test that would catch a broken probe already exists — `integration.provider-basic.test.ts` "lists models" — but `test:integration` is referenced nowhere in `.github/`. The picker broke exactly that way: the probe's `settingSources: []` made the CLI exit with code 0 and no output, reported as "Query closed before response received". `models.fallback` hid it until #4084 removed it. - Add a `provider-model-listing` CI job running the probe against a real, unpinned CLI. It passes today, and would have passed on the unfixed probe: the defect is specific to the macOS native build, which exits when the settings set it loads is empty, so a Linux runner cannot reproduce it. - Match the probe's setting sources to what `sdk-session.ts` already passes for real sessions, which fixes the picker. - Let CLAUDE_CODE_OAUTH_TOKEN reach the CLI. The bridge env allowlist declared only BB_CLAUDE_CODE_EXECUTABLE, and Turbo strips undeclared variables, so token auth never worked for any bb user and the documented executable override was inert under `test:integration`. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
andrewkchan
added a commit
that referenced
this pull request
Sep 23, 2026
## Human comments I am running into a bug on the Claude Code model picker where the models are not listing properly. It looks like we have some automated tests that download claude code and then run the bb probe against it to get the list of models to display in the picker, but they simply do not run in CI. This wires them up in CI. Note some changes are needed for secrets: 1. Passing the env var for `CLAUDE_CODE_OAUTH_TOKEN` through to the bridge process 2. Adding `CLAUDE_CODE_OAUTH_TOKEN` to the github repo secrets ## What was wrong Every automated check of bb's Claude Code model catalog mocks the Agent SDK's `query()`, so nothing in CI has ever spawned a real `claude`. A test that would catch a broken probe already exists — `integration.provider-basic.test.ts` "lists models" — but `test:integration` is referenced nowhere under `.github/`, so it only runs when someone remembers to run it locally. That gap surfaced when the picker started showing "Could not load models for Claude Code": the probe's `settingSources: []` made the CLI exit with code 0 and no output, which the SDK reports as `Query closed before response received`. It had been failing since at least Sep 16, hidden by `models.fallback` until #4084 removed it. ## What changed - `.github/workflows/ci.yml`: new `provider-model-listing` job on pushes and same-repo PRs. Installs the Claude Code CLI, authenticates from a `CLAUDE_CODE_OAUTH_TOKEN` secret, runs the model-listing probe against a real binary. - `plugins/provider-claude-code/src/bridge/model-list.ts`: the probe now uses `settingSources: ["user", "project", "local"]`, matching what `sdk-session.ts` already passes for real sessions. - `plugins/provider-claude-code/server.ts`, `turbo.json`: let `CLAUDE_CODE_OAUTH_TOKEN` reach the CLI. Two layers stripped it — the bridge env allowlist declared only `BB_CLAUDE_CODE_EXECUTABLE`, and Turbo strips undeclared variables. So token auth never worked for any bb user, not just CI, and the documented `BB_CLAUDE_CODE_EXECUTABLE` override was inert under `test:integration`. - `docs/configuration.md`, `claude-code-provider` skill: document both variables. Scope is the model-listing tests only, to keep the job fast and free of real model turns. The CLI version is unpinned (pinning would hide the breakage this job watches for), and it installs the native build, which is what bb resolves from `PATH` and `~/.local/bin`. ## Expected state of this job: green **This job passes, and would have passed on the unfixed probe too.** It is general regression coverage, not a reproduction of the defect that motivated it. That defect is specific to the macOS native build, which exits when the settings set it loads is empty. On CLI 2.1.280: ``` macOS, native, settingSources: [] -> FAIL Query closed before response received macOS, npm build, same config, [] -> OK Linux CI, native, authenticated,[] -> OK ``` So a Linux runner cannot reproduce it; a macOS leg could, and is the natural follow-up. A CLI that exits 0 with empty stdout and stderr also leaves bb nothing to report, which is worth filing upstream separately. ## How you verified - Probe fix confirmed against the real native CLI: `[]` fails, `["user","project","local"]` returns 5 models. Verified end to end in a dev build. - The CI job runs and passes on Linux with exactly one test selected: `✓ lists models`, `Tests 1 passed | 64 skipped (65)` — the filter is not silently matching zero tests. - Env plumbing proved with a shim: both variables reach the spawned process, while an undeclared control variable is still stripped. - `turbo run test typecheck --filter=bb-plugin-provider-claude-code`: passing. `turbo run test --filter=@bb/server`: 295 files passing, with one unrelated pre-existing failure (`bb-official-generator.test.ts`, a local git `%cI` format difference) that reproduces with these changes stashed. Fixes # > AGENT GENERATED Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
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.
Human comments
What was wrong
The Claude Code model picker was a hardcoded catalog (
model-catalog-data.ts) with Claude Code's reported models appended after it. When Claude Code 2.1.280 madeclaude-opus-5-5[1m]its default, BB did pick it up, but it landed sixth in the list under Claude Code's alias label, "Opus (1M context)". The stale hardcoded "Opus 5 (1M)" stayed at the top. Every model release needed a manual catalog edit to look right (#2833 was the last one, for Fable 5.1).What changed
plugins/provider-claude-code/src/model-list.ts: the picker is built only from Claude Code'sinitializationResult().models, in Claude Code's order, one entry per resolved model id.claude-opus-5-5[1m]→ "Opus 5.5 (1M)",claude-haiku-4-5-20251001→ "Haiku 4.5"). Ids that don't match theclaude-<family>-<major>[-<minor>]pattern keep Claude Code's own label.opus[1m],sonnet, …) become selected-only entries, labeled " alias".supportedEffortLevels, withxhighalso offeringultracode, as before.model-catalog-data.ts,model-catalog.tsandmodel-catalog.test.ts, along with the legacy selected-only catalog.plugins/provider-claude-code/server.ts: droppedmodels.fallback. BB already stores the last good catalog per host and serves it when a later probe fails, so the static list only showed up when a host's very first probe failed.plugins/provider-claude-code/src/bridge/model-list.ts: an empty model report now throws, so it counts as a failed probe instead of overwriting the stored catalog with nothing.models.fallbackpath with a test provider, and expect no fallback models for Claude Code.No wire change: the model-list shape is unchanged, so
HOST_DAEMON_PROTOCOL_VERSIONstays put. No CLI, guide or plugin API change.Behavior changes to be aware of:
opus,bestandfableare no longer listed. Threads and project defaults on those models recover to the default in the composer, and the next UI send switches them.bb thread update --model <dropped id>returns 400, and workflow literal selections naming a dropped model fail validation.bb thread spawn --model <id>still works because spawn doesn't check the catalog.LARGE_CLAUDE_CONTEXT_MODELSinsdk-extraction.tsis untouched, because Claude Code's model report carries no context window.How you verified
pnpm exec turbo run test typecheck --filter=bb-plugin-provider-claude-code: 363 tests pass. Newmodel-list.test.tscases cover Claude Code's order, derived names, aliases as selected-only entries, effort mapping, and following a changed default.bridge.test.tscovers the empty report being treated as a failure.pnpm exec turbo run test typecheck --filter=@bb/server: all passing excepttest/public/machine-environment.test.ts, which hit its 5 s timeout under full-suite load and passes when run alone.GET /api/v1/system/execution-options?providerId=claude-codereturns exactly Opus 5.5 (1M) (default), Fable 5.1, Sonnet 5 and Haiku 4.5, with the four aliases as selected-only entries. The model picker in the dev app UI shows the same list.🤖 Generated with Claude Code