Repository navigation
Conversation
Claude Code, Codex, ACP and Pi each composed their CLI's environment differently. Codex passed only an allow-list of three names to codex app-server, so BB_THREAD_ID, BB_THREAD_STORAGE and plugin-contributed variables never reached it or the MCP servers it starts (#4960, #7179). Pi and ACP dropped the contributed env from model listing, and every provider's health and installation probes ignored it (#7614). - Add buildProviderCliEnv(envVars) to the bridge kit (SDK: experimental_buildProviderCliEnv). All four bridges build session, model-list, health and installation envs with it and read launch overrides from its result. Delete Codex appServerLaunchEnv and buildAppServerEnv and Pi buildPiChildEnv. - Carry the host's contributed provider env on provider.health and provider.installation.status (daemon protocol 267) and into the thread-start installation gate. - Maintenance kit probes take the env to search and run with. - Default windowsHide in forkHostProcess. - Add bb/no-raw-child-process: value imports of child_process, cross-spawn and execa outside @bb/process-utils fail lint. Move the one production bypass (workspace-processes) onto execHostFileCallback. - Contract test provider-cli-env.test.ts runs every rule against all four bridges; 10 of its 16 rows fail on main. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…e cleanup Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
ymichael
force-pushed
the
bb/class-fix-one-provider-cli-environment-builder-thr_f3mxwbdx3z
branch
from
November 17, 2026 20:31
d037c54 to
b73f814
Compare
…dowsHide gaps
- provider.list_commands, provider.usage and provider.installation.run
now require contributedEnv (protocol 267); every sessionless bridge
request (model/list, commands/list, provider/*) requires envVars.
- Claude's command list builds its CLI env from the request and caches
per contributed env. Codex auth, the Claude skills config dir, native
roots and the ACP agent probe read the provider's contributed env.
- Host calls gain a providerEnv option; native roots uses it.
- spawnHostProcessSync defaults windowsHide; the browser-automation
supervisor sets it; no-raw-child-process also bans
process.getBuiltinModule("node:child_process"). Drop explicit
windowsHide: true where the helper already defaults it.
- provider-cli-env rows for usage, commands/list and installation run.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ider-cli-environment-builder-thr_f3mxwbdx3z
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Requiring envVars in modelListParamsSchema, commandListParamsSchema and providerMaintenanceParamsSchema rejected requests from harnesses and runtimes that do not send it, such as the echo provider's tests and the package smoke's model/list. The runtime still always sends envVars (the adapter command types require it) and the daemon wire still requires contributedEnv. The schemas were already passthrough, so bridges built against the previous SDK accept the new field. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Nov 18, 2026
…ider-cli-environment-builder-thr_f3mxwbdx3z # Conflicts: # packages/domain/src/plugin-sdk-version.ts # packages/plugin-sdk/package.json # plugins/provider-pi/src/bridge/provider-maintenance.version.test.ts
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ider-cli-environment-builder-thr_f3mxwbdx3z # Conflicts: # packages/domain/src/plugin-sdk-version.ts # packages/host-daemon-contract/src/protocol.ts # packages/host-daemon-contract/test/contract.test.ts # packages/plugin-sdk/package.json # plugins/provider-codex/src/bridge/app-server-launch.test.ts # plugins/provider-codex/src/bridge/bridge.ts
… calls and usage - Pi resolves a thread's model against a catalog launched with the thread's env, so a contributed BB_PI_BRIDGE_COMMAND that the session uses also serves model resolution. Catalogs drop the per-thread names (experimental_withoutThreadIdentityEnv) so threads share one. - The ACP thread-start model-list command drops the same names, so thread starts reuse the cached catalog again. - Remove ExperimentalHostCallOptions.providerEnv: a host worker applies only the first overlapping call's env, and any plugin could request another provider's contributed secrets. - provider.usage carries no contributed env again. Probing through the Account Pooler's routing env reported the machine as signed out. - bb/no-raw-child-process also flags `import x = require(...)`. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ider-cli-environment-builder-thr_f3mxwbdx3z # Conflicts: # packages/domain/src/plugin-sdk-version.ts # packages/plugin-sdk/package.json # packages/provider-bridge-acp/src/bridge/bridge.ts
A Pi thread looked its model up in a separate catalog process before starting Pi with --provider/--model. With the thread env that lookup could not share the picker's catalog, so the first thread in the picker's folder waited ~200 ms for a second process. The session now starts Pi, asks that process for its models, picks the exact provider/id match (same rules as before: canonical first, then one exact id, ambiguity rejected), and switches with set_model and set_thinking_level. 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. Pi 0.84.0-0.84.2 saved every RPC set_model as the user's global default, so the minimum supported Pi is now 0.84.3. experimental_withoutThreadIdentityEnv leaves the SDK; only the ACP bridge uses the helper, internally. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Pi recordings were made while the bridge chose the model with --provider/--model, so they hold no get_available_models, set_model or set_thinking_level on the session child. The replay child now answers those, when the script does not expect them, from the models the recording reports and the replayed state, and answers the get_state that follows from that state. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ider-cli-environment-builder-thr_f3mxwbdx3z
Co-Authored-By: Claude Opus 5.5 <[email protected]>
ymichael
deleted the
bb/class-fix-one-provider-cli-environment-builder-thr_f3mxwbdx3z
branch
November 19, 2026 00:21
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
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-serveronly an allow-list of three names (CODEX_OPENAI_BASE_URL,CODEX_POOL_AUTH_TOKEN,CODEX_HOME) and stripped every otherBB_*name. SoBB_THREAD_ID,BB_THREAD_STORAGEand plugin-contributed variables such asBB_CODEX_BRIDGE_APP_SERVER_COMMANDnever 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 ownprocess.env, and the server never sent them the contributed env, so a plugin-suppliedBB_CLAUDE_CODE_EXECUTABLEworked 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'sverify/host.md.Live repro on main (installed bb built from
1320c88e8ab, Nov 16; the bridge code is unchanged on main):ps ewwon a runningcodex app-serverlists noBB_THREAD_ID,BB_THREAD_STORAGEorBB_PROJECT_ID. A Claude Code CLI under the same daemon has all three.Issues and patches from this root cause
CODEX_HOME/BB_CODEX_BRIDGE_APP_SERVER_COMMANDnever reach the app-server. Fixed (theCODEX_HOMEhalf had already been patched by #6887).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.CODEX_HOMEto the Codex allow-list. Deleted.model/listthe contributed env, Claude only. Now one rule for all four providers.PI_BB_TOOLS_FILE. Kept, incatalogCliEnv.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
buildProviderCliEnv(envVars)in@bb/provider-bridge-protocol/bridge-kit, exported to plugins asexperimental_buildProviderCliEnv. It returns the bridge env minus bridge-only runtime vars, plus the request'senvVars(valid shell names). On Windows a request var replaces an inherited one whatever its case, so a threadPATHnever sits beside an inheritedPath.appServerLaunchEnv,buildAppServerEnvandAPP_SERVER_LAUNCH_ENV_NAMES.resolveAppServerLaunchnow takes the CLI env and has noprocess.envdefault.buildPiChildEnv.resolvePiLaunchreads 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 exactprovider/idmatch with the existing rules (canonical first, then one exact id; ambiguity rejected), and switches withset_modelandset_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.buildSessionEnvis now the builder plus Claude's two entrypoint tweaks.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.withoutThreadIdentityEnv(envVars)in the bridge kit (internal, not exported to plugins) removesBB_THREAD_ID,BB_THREAD_STORAGE,BB_PROJECT_IDandBB_ENVIRONMENT_IDfrom the ACP thread-start list command, so thread starts share the cached list.experimental_resolveExecutablePath,experimental_commandOutput,experimental_readCliVersion,experimental_npmLatestVersionandexperimental_probeNpmGlobalPackagetake the env as an argument. Claude, Codex, Pi and ACP maintenance pass it through.HOST_DAEMON_PROTOCOL_VERSION269 → 270. Theprovider.*host commandslist_models,list_commands,health,installation.statusandinstallation.runnow requirecontributedEnv, and the runtime sendsenvVarson 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.usagecarries 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'sANTHROPIC_BASE_URL/ANTHROPIC_AUTH_TOKENreturnsunauthenticated).modelListParamsSchema,commandListParamsSchema,providerMaintenanceParamsSchema) keepenvVarsoptional. 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.tscovers both shapes. The server resolves the env withresolveHostProviderEnv(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 asenvVars. The thread-start installation gate passes the thread's contributed env and includes it in its cache key.CODEX_HOMEfrom the probe env.CLAUDE_CONFIG_DIRfrom the thread's CLI env.windowsHidedefault:forkHostProcessandspawnHostProcessSyncdefault it totrue, asspawnHostProcessandexecHostFilealready did. This covers the plugin-host and watcher forks and the CLI re-exec.CREATE_NO_WINDOWwhen no stdio is inherited, so the re-exec keeps its console.windowsHide: trueto a helper that already defaults it no longer do.bb/no-raw-child-processrule rejects value imports,import x = require(...),require,process.getBuiltinModule, dynamic imports and re-exports ofnode:child_process,child_process,cross-spawnandexecain apps/packages/plugins TS. Exempt:@bb/process-utils/src, tests, test-support, scripts,provider-parity,connect-next(hosted service), Vite configs, andapps/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 replaceno-restricted-importsper file, so theapps/serverblock would have dropped a repo-wide ban. The one production bypass,workspace-processes.ts(ps/lsof), now usesexecHostFileCallback.docs/provider-bridge-protocol.md(Child processes),docs/provider-plugin-api.md, the plugin-authoringproviders.md,docs/api_to_audit.mdentries, 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:
BB_CLI,BB_SERVER_URL, the threadPATH(with bb's CLI dir) and all contributed vars. MCP servers, hooks and anything codex starts see them. Codex shell commands already saw these throughshell_environment_policy.BB_CODEX_BRIDGE_APP_SERVER_COMMAND/_ARGSandBB_PI_BRIDGE_COMMAND/_ARGSfrom a plugin pick the CLI. Before, only the daemon's machine env could.set_model/set_thinking_levelas 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_VERSIONis now 0.84.3, so older installs get bb's existing "Update Pi" prompt. Pi 1.5.2set_modelrecords 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.bb.hostcalls. An earlier revision addedExperimentalHostCallOptions.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.experimental_resolveExecutablePath,experimental_commandOutput,experimental_readCliVersion,experimental_npmLatestVersionandexperimental_probeNpmGlobalPackageaccept an optional lastenvargument. 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 passbuildProviderCliEnv(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.tsdrives all four bridges in-process through one table. A wrapper records the env the spawned CLI actually receives (the mocked Agent SDKqueryoptions for Claude). Rows per provider:BB_THREAD_ID,BB_THREAD_STORAGE,BB_PROJECT_ID,BB_ENVIRONMENT_ID, a contributedBB_*and non-BB_*var, thread PATH first; noELECTRON_RUN_AS_NODE);envVars; their gap was on the wire, and the required schema fields now close it.On main, 10 of 16 rows fail: Codex thread (Codex app-server process does not carry the thread identity (BB_THREAD_ID), so MCP servers it launches cannot tell which thread they serve #4960), Codex launch (Codex provider: contributed env never reaches the app-server process, so CODEX_HOME and BB_CODEX_BRIDGE_APP_SERVER_COMMAND cannot be set per thread #7179), Codex/Pi/ACP model list, Pi launch, and the Claude/Codex/Pi/ACP probes (Claude Code provider: installation status and health ignore plugin-contributed BB_CLAUDE_CODE_EXECUTABLE, composer stays blocked #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 noget_available_models/set_model/set_thinking_levelon the session child.replay-provider-child.mjsnow answers those (when the script does not expect them) from the models the recording itself reports and the replayed state. Without that changepi/forkfails locally with the sameunansweredRequestserror CI showed; with it all 80 parity and scenario replays pass.bridge.model-resolution.test.ts(Pi): with the bridge's ownBB_PI_BRIDGE_COMMANDpointing at a missing binary and the thread env carrying a working one, a thread starts onfake-provider/fake-model. Before the Pi change it failed withspawn …/missing-pi ENOENT. The existing canonical, slash, ambiguity and missing-model cases pass unchanged;bridge.settings.test.tsnow expectsset_model/set_thinking_levelon start, resume and fork.Pi thread start, real
pi1.5.2 driven through the bridge (picker lists models, then three threads start;thread/startlatency): 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 forforkHostProcessonly, passes now.no-raw-child-process.test.mjscovers the rule. The rule flags main'sworkspace-processes.ts, and the repo now lints clean under it.Server:
provider-states.test.tschecks that health and installation status carry a plugin'sBB_CLAUDE_CODE_EXECUTABLEto the host with a host-scoped context. Daemon: dispatch forwardscontributedEnv, and the gate key separates contributed envs.Live before/after with a local plugin contributing
BB_REPRO_MARKER, a wrapperBB_CODEX_BRIDGE_APP_SERVER_COMMAND, and a fakeBB_CLAUDE_CODE_EXECUTABLEthat reports9.9.9. On main: the Codex app-server had noBB_THREAD_ID/BB_THREAD_STORAGE/BB_PROJECT_IDor marker, the wrapper never ran, and Settings → Updates showed the systemclaude 2.1.325even after a restart. On this branch: the app-server has all of them, it launches through the wrapper, Updates shows9.9.9, and Codex and Pi threads replyok.Earlier live after-check: I started this branch with
pnpm start:worktree(isolated data dir) and spawned a Codex thread. The turn repliedok.ps ewwon itscodex app-servershowsBB_THREAD_ID=thr_atcfaipne3, the thread'sBB_THREAD_STORAGE, andBB_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
windowsHidefork and sync-spawn defaults on a real Windows console. They are unit-tested only.Fixes #4960
Fixes #7179
Fixes #7614
🤖 Generated with Claude Code