Skip to content

List pooled accounts' Claude models in the Claude Code picker - #7401

Merged
ymichael merged 3 commits into
mainfrom
bb/triage-and-resolve-issue-7329-thr_3hhqfxxx6j
Nov 10, 2026
Merged

ymichael merged 3 commits into
mainfrom
bb/triage-and-resolve-issue-7329-thr_3hhqfxxx6j

Conversation

@ymichael

@ymichael ymichael commented Nov 10, 2026 •

Copy link
Copy Markdown
Collaborator

Human comments

What was wrong

Two problems kept new Claude models out of the picker behind Account Pooler routing:

  1. With the pool's ANTHROPIC_BASE_URL/ANTHROPIC_AUTH_TOKEN, Claude Code has no claude.ai login. It skips its served model catalog ([servedCatalog] off (not_claude_ai_auth)), and its initialize models are only the ones cached in ~/.claude.json under an earlier personal login (here Fable 5.1). No env flag brings the catalog back; setting either variable alone is enough to get the stale list.
  2. The Claude Code bridge parsed model/list params as z.object({}) and probed with its own process env. It dropped the envVars bb sends with each request, so plugin-contributed settings, the pool's included, never reached model discovery. A machine whose daemon had no Claude settings got Claude Code's no-login public catalog, which is why some pooled machines did show Fable 5.2; others showed the stale list.

What changed

  • account-pool: new GET /claude/v1/models hub route, forwarded to Anthropic's /v1/models with a pooled account's credentials (the Claude adapter strips the claude/ prefix). The pool contributes BB_CLAUDE_MODELS_URL pointing at it, and neutralizes it with the other routing variables for isolated nested instances. The skill reference documents it.
  • provider-claude-code: model/list parses params with the protocol's modelListParamsSchema and probes with the same env sessions use (buildSessionEnv(envVars)). The 2-minute memo keeps one entry per env set. When BB_CLAUDE_MODELS_URL is set, the bridge pages through it, and the pooled accounts' list sets the picker rows: Claude Code's default first, then the rest newest first, with the efforts from capabilities.effort. Claude Code still supplies the default, its alias entries (selected-only, for threads saved with opus, claude-fable-5-1[1m], ...), and descriptions for models both lists share. A 404 (a parent pool without the route) keeps Claude Code's list. Other failures, or an empty list, fail the listing, so a partial catalog is never published.
  • No server/daemon wire change: envVars was already part of model/list params.

Differences from #7389, which has the same core idea: this lets the accounts' list set the rows instead of appending it after Claude Code's stale list; keeps the bridge memo (per env) instead of removing it; it treats a 404 from an older parent pool as "no account catalog" instead of failing the Claude list; and it leaves out the cross-provider refresh/polling/SDK/CLI changes.

How you verified

  • New tests:
    • Bridge: model/list passes each request's envVars to the probe and caches per env. This failed before the parser fix.
    • Account list: rows newest first after the default, Claude Code aliases kept and models outside the account list dropped, pagination, effort mapping, 404 fallback, and failure on 5xx or an empty list.
    • Memo: one entry per env set.
    • Pool: the route forwards to upstream /v1/models with the account token. This fails without the prefix strip.
  • pnpm exec turbo run test typecheck --filter=bb-plugin-provider-claude-code --filter=bb-plugin-account-pool: 441 + 394 tests pass. Lint is clean for both plugins.
  • Live, on a pnpm start:worktree server on a host with no Claude login:
    • With the parent pool on current main (404 on the new route), the picker keeps Claude Code's 4 models with no error.
    • With a stand-in parent pool that serves the route from Anthropic using a real pooled OAuth token, the stand-in logged GET /claude/v1/models?limit=1000 from the worktree hub, and bb provider models claude-code listed 15 models including claude-fable-5-2 (default still Opus 5.5). After the ordering change, the real bridge against real Claude Code and Anthropic responses lists Opus 5.5 (default), Fable 5.2, Haiku 5.5, Sonnet 5.5, Fable 5.1, then older models.
  • Confirmed directly that Anthropic's /v1/models accepts a pooled subscription OAuth token without the OAuth beta header.

Fixes #7329

🤖 Generated with Claude Code

AGENT GENERATED

ymichael and others added 3 commits November 10, 2026 10:32
Behind Account Pooler routing, Claude Code has no claude.ai login, so it
skips its served model catalog and its initialize response lists only the
models cached in ~/.claude.json under an earlier personal login. New
models such as Claude Fable 5.2 never reach bb's picker even though the
pooled accounts can use them.

The pool now serves GET /claude/v1/models with a pooled account's
credentials and contributes BB_CLAUDE_MODELS_URL. The Claude Code bridge
adds every model from that list the CLI did not report. A hub without the
route (an older parent pool) answers 404 and keeps the CLI list; other
failures fail the listing so a partial catalog is never published.

Fixes #7329

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The Claude Code bridge parsed model/list params as an empty object and
probed with its own process environment, dropping the envVars bb sends
with each request. Plugin-contributed settings such as Account Pooler
routing never reached model discovery: a machine whose daemon had no
Claude settings listed Claude Code's no-login public catalog, and the
pool's BB_CLAUDE_MODELS_URL could not take effect.

Parse model/list with the protocol's params schema, probe with the same
environment sessions use, and keep one memoized catalog per environment.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Appending the accounts' models after Claude Code's stale list put Fable
5.1 above Fable 5.2 and could keep a model the accounts no longer serve.
When the pool returns its list, the picker rows now come from it, newest
first after Claude Code's default. Claude Code still supplies the
default, its alias entries for threads saved with them, and descriptions
for models both lists share. An empty account list fails the listing.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ymichael
ymichael merged commit 8b23232 into main Nov 10, 2026
38 checks passed
@ymichael
ymichael deleted the bb/triage-and-resolve-issue-7329-thr_3hhqfxxx6j branch November 10, 2026 19:56
ymichael added a commit that referenced this pull request Nov 19, 2026
## Human comments

## What was wrong

Every provider bridge built the environment for the CLI it starts by
hand, and each one did it differently. Claude Code passed the thread env
through. Codex passed `codex app-server` only an allow-list of three
names (`CODEX_OPENAI_BASE_URL`, `CODEX_POOL_AUTH_TOKEN`, `CODEX_HOME`)
and stripped every other `BB_*` name. So `BB_THREAD_ID`,
`BB_THREAD_STORAGE` and plugin-contributed variables such as
`BB_CODEX_BRIDGE_APP_SERVER_COMMAND` never reached the app-server or the
MCP servers and hooks it starts. Pi and ACP dropped the contributed env
when listing models. All four providers ran their health and
installation probes with the bridge's own `process.env`, and the server
never sent them the contributed env, so a plugin-supplied
`BB_CLAUDE_CODE_EXECUTABLE` worked for threads while the composer still
said "not installed". A spawn primitive already has one owner (#6194,
#6394); env composition had none. Background notes: C6 in
thr_qchecuan6n's `verify/host.md`.

Live repro on main (installed bb built from `1320c88e8ab`, Nov 16; the
bridge code is unchanged on main): `ps eww` on a running `codex
app-server` lists no `BB_THREAD_ID`, `BB_THREAD_STORAGE` or
`BB_PROJECT_ID`. A Claude Code CLI under the same daemon has all three.

### Issues and patches from this root cause

| | Item | What happened |
|---|---|---|
| open | #4960 | Codex app-server lacks thread identity, so MCP servers
cannot tell which thread they serve. **Fixed.** |
| open | #7179 | Contributed `CODEX_HOME` /
`BB_CODEX_BRIDGE_APP_SERVER_COMMAND` never reach the app-server.
**Fixed** (the `CODEX_HOME` half had already been patched by #6887). |
| open | #7614 | Claude Code installation status and health ignore a
contributed `BB_CLAUDE_CODE_EXECUTABLE`. **Fixed** for the server and
bridge. The app's cached host CLI status still refreshes only on reload;
that is a separate query-policy issue. |
| merged patch | #3056 | Added the pool URL and token to the Codex
allow-list. **Deleted** (the allow-list is gone). |
| merged patch | #6887 | Added `CODEX_HOME` to the Codex allow-list.
**Deleted.** |
| merged patch | #7401 | Gave Claude `model/list` the contributed env,
Claude only. Now one rule for all four providers. |
| merged patch | #5352 | Pi catalog inherited a stale
`PI_BB_TOOLS_FILE`. Kept, in `catalogCliEnv`. |
| related | #6939 | Codex rebuilds its session when a turn's env vars
change. Unchanged; it now rebuilds onto an env that actually carries
them. |
| not this class | #4417 | bb CLI dir prepended to PATH. That is a PATH
policy choice, not composition. Not changed. |

With the builder in place from the start, #4960, #7179 and #7614 could
not have happened, and #3056, #6887 and #7401 would not have been
needed. Each of those patched one provider for one name.

## What changed

- **One builder.** `buildProviderCliEnv(envVars)` in
`@bb/provider-bridge-protocol/bridge-kit`, exported to plugins as
`experimental_buildProviderCliEnv`. It returns the bridge env minus
bridge-only runtime vars, plus the request's `envVars` (valid shell
names). On Windows a request var replaces an inherited one whatever its
case, so a thread `PATH` never sits beside an inherited `Path`.
- **All four bridges use it** for session CLIs, model listing, health
and installation probes, and read their launch overrides from its
result:
- Codex: deleted `appServerLaunchEnv`, `buildAppServerEnv` and
`APP_SERVER_LAUNCH_ENV_NAMES`. `resolveAppServerLaunch` now takes the
CLI env and has no `process.env` default.
- Pi: deleted `buildPiChildEnv`. `resolvePiLaunch` reads the child env.
The model-list catalog is keyed by cwd + contributed env. A thread no
longer uses that catalog: the session starts Pi, asks that same process
for its models (`get_available_models`), picks the exact `provider/id`
match with the existing rules (canonical first, then one exact id;
ambiguity rejected), and switches with `set_model` and
`set_thinking_level`, the way T3 Code does. Model resolution therefore
always uses the Pi the thread's env selects, and no second Pi process
starts. A model missing from the list is retried like the existing
transient login miss; a mid-thread model change is checked against the
running Pi before the session is rebuilt.
- Claude: `buildSessionEnv` is now the builder plus Claude's two
entrypoint tweaks.
- ACP: session, model list (now including the request `envVars`), model
selection, maintenance and the agent probe. The thread-start model-list
command drops the per-thread names, so thread starts share the cached
catalog.
- **ACP's cached model list drops thread identity.**
`withoutThreadIdentityEnv(envVars)` in the bridge kit (internal, not
exported to plugins) removes `BB_THREAD_ID`, `BB_THREAD_STORAGE`,
`BB_PROJECT_ID` and `BB_ENVIRONMENT_ID` from the ACP thread-start list
command, so thread starts share the cached list.
- **Probes take an env.** `experimental_resolveExecutablePath`,
`experimental_commandOutput`, `experimental_readCliVersion`,
`experimental_npmLatestVersion` and `experimental_probeNpmGlobalPackage`
take the env as an argument. Claude, Codex, Pi and ACP maintenance pass
it through.
- **Wire change, `HOST_DAEMON_PROTOCOL_VERSION` 269 → 270.** The
`provider.*` host commands `list_models`, `list_commands`, `health`,
`installation.status` and `installation.run` now require
`contributedEnv`, and the runtime sends `envVars` on the matching
sessionless bridge requests (`model/list`, `commands/list`,
`provider/health`, `provider/installation/*`): the adapter command types
require it, so the type system rejects any request built without it.
`provider.usage` carries no env, as before: probing through the Account
Pooler's routing env reports the machine as signed out (checked live:
the local Claude account returns its Ultra limits, the same probe with
the pool's `ANTHROPIC_BASE_URL`/`ANTHROPIC_AUTH_TOKEN` returns
`unauthenticated`).
- **Bridge compatibility:** the SDK-facing bridge param schemas
(`modelListParamsSchema`, `commandListParamsSchema`,
`providerMaintenanceParamsSchema`) keep `envVars` optional. A bridge
built against the new SDK still accepts requests without it, as the echo
provider's tests and the package smoke send. Those schemas were already
`.passthrough()`, so a bridge built against the previous SDK accepts the
new field. `protocol.test.ts` covers both shapes. The server resolves
the env with `resolveHostProviderEnv` (shared with the model catalog
store, which already did this inline) and puts it in its status and
command-list cache keys. The runtime forwards it as `envVars`. The
thread-start installation gate passes the thread's contributed env and
includes it in its cache key.
- **Reads that bypassed the CLI env:**
- Claude's command list starts the CLI with the request's env and caches
per folder + contributed env.
  - Codex auth reads `CODEX_HOME` from the probe env.
- The Claude skills config dir reads `CLAUDE_CONFIG_DIR` from the
thread's CLI env.
- **`windowsHide` default:**
- `forkHostProcess` and `spawnHostProcessSync` default it to `true`, as
`spawnHostProcess` and `execHostFile` already did. This covers the
plugin-host and watcher forks and the CLI re-exec.
- The CLI re-exec inherits stdio. libuv only adds `CREATE_NO_WINDOW`
when no stdio is inherited, so the re-exec keeps its console.
- The browser-automation supervisor script sets it on its detached
child.
- Nine call sites that passed `windowsHide: true` to a helper that
already defaults it no longer do.
- **Lint:** a new `bb/no-raw-child-process` rule rejects value imports,
`import x = require(...)`, `require`, `process.getBuiltinModule`,
dynamic imports and re-exports of `node:child_process`, `child_process`,
`cross-spawn` and `execa` in apps/packages/plugins TS. Exempt:
`@bb/process-utils/src`, tests, test-support, scripts,
`provider-parity`, `connect-next` (hosted service), Vite configs, and
`apps/desktop/src/bb-process.ts` (the Linux-only AppImage bridge
bootstrap, which runs before the toolchain loads). It is a custom rule
because oxlint overrides replace `no-restricted-imports` per file, so
the `apps/server` block would have dropped a repo-wide ban. The one
production bypass, `workspace-processes.ts` (`ps`/`lsof`), now uses
`execHostFileCallback`.
- **Docs and surfaces:** `docs/provider-bridge-protocol.md` (Child
processes), `docs/provider-plugin-api.md`, the plugin-authoring
`providers.md`, `docs/api_to_audit.md` entries, the Plugin Guide
symbols, Turbo inputs for the protocol tests (Pi + ACP sources), and the
SDK bump to 0.6.163.

## Decisions for review

These change what users or plugin authors can see:

1. **Codex app-server now gets the full thread env**, the same as Claude
Code: thread identity, `BB_CLI`, `BB_SERVER_URL`, the thread `PATH`
(with bb's CLI dir) and all contributed vars. MCP servers, hooks and
anything codex starts see them. Codex shell commands already saw these
through `shell_environment_policy`.
2. **Contributed launch overrides now take effect**:
`BB_CODEX_BRIDGE_APP_SERVER_COMMAND`/`_ARGS` and
`BB_PI_BRIDGE_COMMAND`/`_ARGS` from a plugin pick the CLI. Before, only
the daemon's machine env could.
3. **Installation status and health now use the host's contributed
env.** A plugin-shipped Claude Code counts as installed, and the
composer unblocks after the status refreshes. Usage keeps reporting the
machine's own sign-in.
4. **Pi resolves a thread's model inside the thread's own Pi process and
requires Pi 0.84.3.** Pi 0.84.0–0.84.2 saved every RPC
`set_model`/`set_thinking_level` as the user's global default in
`~/.pi/agent/settings.json` (checked in the 0.84.2 package; fixed in
0.84.3, Aug 24), which is why bb previously pinned the model with launch
flags. `PI_MINIMUM_SUPPORTED_VERSION` is now 0.84.3, so older installs
get bb's existing "Update Pi" prompt. Pi 1.5.2 `set_model` records a
model change in the session transcript and leaves settings untouched
(checked live). The model-picker catalog is now one process per distinct
contributed env instead of one per cwd.
5. **No provider env on `bb.host` calls.** An earlier revision added
`ExperimentalHostCallOptions.providerEnv`. It is removed: a host worker
applies only the first of several overlapping calls' env, and any plugin
could have requested another provider's contributed secrets.
Native-roots lookup and the ACP agent probe use the host env, as on
main.
6. **SDK maintenance probes take an optional env.**
`experimental_resolveExecutablePath`, `experimental_commandOutput`,
`experimental_readCliVersion`, `experimental_npmLatestVersion` and
`experimental_probeNpmGlobalPackage` accept an optional last `env`
argument. Without it they behave exactly as before (the bridge's own
environment), so existing third-party plugins keep building and
typechecking. First-party bridges always pass
`buildProviderCliEnv(params.envVars)`. **Accepted in review:** items 1–4
as described. Item 6 was changed at review from a required argument to
an optional one.

## How you verified

- **Guard test first:**
`packages/provider-bridge-protocol/src/contract-tests/provider-cli-env.test.ts`
drives all four bridges in-process through one table. A wrapper records
the env the spawned CLI actually receives (the mocked Agent SDK `query`
options for Claude). Rows per provider:
- thread CLI receives every thread var (`BB_THREAD_ID`,
`BB_THREAD_STORAGE`, `BB_PROJECT_ID`, `BB_ENVIRONMENT_ID`, a contributed
`BB_*` and non-`BB_*` var, thread PATH first; no
`ELECTRON_RUN_AS_NODE`);
  - model-list CLI receives the contributed env;
  - launch settings come from the thread env;
- installation status and health probe the CLI the contributed env
selects (skipped on Windows; it uses sh fakes);
  - installation run plans against that CLI (Claude, Codex, Pi);
- the command-list CLI receives the contributed env and launch override
(Claude). This row fails on the previous head. The run bridges already
applied `envVars`; their gap was on the wire, and the required schema
fields now close it.

On main, **10 of 16 rows fail**: Codex thread (#4960), Codex launch
(#7179), Codex/Pi/ACP model list, Pi launch, and the Claude/Codex/Pi/ACP
probes (#7614). All pass on this branch.
- **Provider-parity replays (Pi):** the committed Pi recordings were
made while the bridge passed `--provider`/`--model`, so they hold no
`get_available_models`/`set_model`/`set_thinking_level` on the session
child. `replay-provider-child.mjs` now answers those (when the script
does not expect them) from the models the recording itself reports and
the replayed state. Without that change `pi/fork` fails locally with the
same `unansweredRequests` error CI showed; with it all 80 parity and
scenario replays pass.
- `bridge.model-resolution.test.ts` (Pi): with the bridge's own
`BB_PI_BRIDGE_COMMAND` pointing at a missing binary and the thread env
carrying a working one, a thread starts on `fake-provider/fake-model`.
Before the Pi change it failed with `spawn …/missing-pi ENOENT`. The
existing canonical, slash, ambiguity and missing-model cases pass
unchanged; `bridge.settings.test.ts` now expects
`set_model`/`set_thinking_level` on start, resume and fork.
- **Pi thread start, real `pi` 1.5.2 driven through the bridge** (picker
lists models, then three threads start; `thread/start` latency): main
~210 ms in the picker's folder and ~400–700 ms for the first thread in
another folder; this branch ~210 ms in both. An intermediate revision
that resolved through a thread-env catalog measured ~395 ms for the
first thread in the picker's folder, which is what this change removes.
- `provider-maintenance-kit.test.ts`: the probes called with no env
argument resolve, version and run a CLI through the bridge's own
environment (today's behaviour); an explicit env overrides it.
- `host-process-windows-hide.test.ts`: fails on main for
`forkHostProcess` only, passes now. `no-raw-child-process.test.mjs`
covers the rule. The rule flags main's `workspace-processes.ts`, and the
repo now lints clean under it.
- Server: `provider-states.test.ts` checks that health and installation
status carry a plugin's `BB_CLAUDE_CODE_EXECUTABLE` to the host with a
host-scoped context. Daemon: dispatch forwards `contributedEnv`, and the
gate key separates contributed envs.
- **Live before/after with a local plugin** contributing
`BB_REPRO_MARKER`, a wrapper `BB_CODEX_BRIDGE_APP_SERVER_COMMAND`, and a
fake `BB_CLAUDE_CODE_EXECUTABLE` that reports `9.9.9`. On main: the
Codex app-server had no
`BB_THREAD_ID`/`BB_THREAD_STORAGE`/`BB_PROJECT_ID` or marker, the
wrapper never ran, and Settings → Updates showed the system `claude
2.1.325` even after a restart. On this branch: the app-server has all of
them, it launches through the wrapper, Updates shows `9.9.9`, and Codex
and Pi threads reply `ok`.
- **Earlier live after-check:** I started this branch with `pnpm
start:worktree` (isolated data dir) and spawned a Codex thread. The turn
replied `ok`. `ps eww` on its `codex app-server` shows
`BB_THREAD_ID=thr_atcfaipne3`, the thread's `BB_THREAD_STORAGE`, and
`BB_SERVER_URL`/`BB_PROJECT_ID`/`BB_ENVIRONMENT_ID`.
- Locally: `pnpm exec turbo run typecheck --filter='...[origin/main]'`
(green), `turbo run lint --filter='[origin/main]'`, and targeted tests
in provider-bridge-protocol, provider-bridge-acp, provider-codex,
provider-claude-code, provider-pi, agent-runtime, process-utils,
host-daemon (gate, dispatch, app), server (installations, model catalog,
provider states) and scripts. Full suites are left to CI.
- Not verified: the `windowsHide` fork and sync-spawn defaults on a real
Windows console. They are unit-tested only.

Fixes #4960
Fixes #7179
Fixes #7614

> AGENT GENERATED

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
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.

Account Pooler: Claude Code model picker never shows new models (CLI skips its served model catalog without a claude.ai login)

1 participant