fix: forward CHOIR_AGENT_TOKEN to codex mcp-stdio via env_vars#688
Merged
brickfrog merged 2 commits intoJul 9, 2026
Merged
Conversation
Owner
Author
|
Choir: GitHub Actions rollup reports all checks successful on the latest head — re-check review/merge policy on GitHub (not an approval or merge signal by itself). |
Owner
Author
|
Choir: GitHub Actions rollup reports all checks successful on the latest head — re-check review/merge policy on GitHub (not an approval or merge signal by itself). |
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.
Summary
Codex leaves'
choir mcp-stdiosubprocesses launched with zero CHOIR_* env vars: codex's MCP stdio launcher builds each server's environment from scratch (env_clear()+ a DEFAULT_ENV_VARS whitelist in rmcp-client'screate_env_for_mcp_server;shell_environment_policyonly governs shell/exec tool calls, not MCP subprocesses), and choir's codex MCP entry (codex_mcp_override_args) configured no per-server env forwarding. Registration then had noCHOIR_AGENT_TOKENand the server rejected every codex leaf (choir-ghl9, P0). This adds a names-onlymcp_servers.choir.env_vars=["CHOIR_AGENT_TOKEN"]override so codex forwards the token from its own environment — on this MCP override surface the token value never rides argv (the pre-existing token exports inlaunch_env_prefix/TL init command strings are a separate, out-of-scope surface).Codex 0.144.0 config-schema findings (task step 1)
codex mcp add --helpexposes--env <KEY=VALUE>→ themcp_servers.<name>.envvalue map (rejected here: it would embed the secret in argv)."env" (optional): Environment variables to set for the server.and"env_vars" (optional): Environment variables to allow and forward.—env_varsentries are names whose values are read from codex's local environment.codex mcp -c 'mcp_servers.x.env_vars=["CHOIR_AGENT_TOKEN"]' listaccepts the field and showsCHOIR_AGENT_TOKEN=*****(value resolved from codex's env, masked). Also ran the exact full override shape choir now emits (command/args/env_vars/cwd) — parses clean. Unknown fields are silently ignored, so the masked-value display is the positive proof the field is live. TL audit additionally confirmed the mechanism against codex-rs source (rmcp-client/src/utils.rs + stdio_server_launcher.rs).Why only CHOIR_AGENT_TOKEN (task step 3)
Audited the mcp-stdio registration path: agent identity, role, parent/branch/workspace, terminal target, and
listen_udsall come from the per-leaf.choir/config.local.toml(written at spawn;mcp_servers.choir.cwdpoints at the worktree) plus the--role/--nameargs already in the server argv. The CHOIR_* env identity vars are only a fallback for when that file lacks identity (local_cfg_from_env_lookup), which never applies to spawned codex leaves. The token (format_registration_request,src/transport/transport.mbt:84) is the single env-only input, so it is the entire forward list — no blanket CHOIR_* glob.What changed
src/workspace/launch.mbt:codex_mcp_override_argsemits-c mcp_servers.choir.env_vars=["CHOIR_AGENT_TOKEN"].src/workspace/workspace_test.mbt: new test asserts the env_vars entry is present for all roles and that no argv element carries aCHOIR_AGENT_TOKEN=assignment or anmcp_servers.choir.env./env=value map..choir/config.toml: rewrote the[model.codex]comment — the outage was model-independent (not gpt-5.6-luna) and the scrub comes from codex's MCP launcher whitelist, not shell_environment_policy; model/effort values unchanged.Verification
moon test --target native: 2267 passed, 0 failed (RED first: the new test failed before the fix).moon run src/bin/choir_lint --target native: pass.Verification
Generated by Choir from commands executed in the leaf workspace.
moon test --target nativemoon run src/bin/choir_lint --target native