Summary
`mcp__cmux__spawn_agent` unconditionally prepends Claude-Code-specific env vars `MCP_CONNECTION_NONBLOCKING=1 CLAUDE_CODE_NO_FLICKER=1` to every spawn command, including `cli=codex`, `cli=cursor`, `cli=gemini`, `cli=kiro`. These env vars are meaningless to non-Claude-Code CLIs and shouldn't leak into those contexts.
Evidence
From the 2026-04-11 session, spawning with `cli=codex`:
```
cd ~/Gits/brainlayer && MCP_CONNECTION_NONBLOCKING=1 CLAUDE_CODE_NO_FLICKER=1 codex
```
The two env vars are Claude Code specific — they exist to stabilize Claude Code's alt-screen rendering for terminal parsers (see `cmuxlayer/src/agent-engine.ts` history — they were originally added in a PR that scoped them to Claude Code specifically, but the scoping was lost).
Why this matters
- Behavioral contamination risk: Future Codex/Cursor/Gemini versions might interpret these env vars differently (unlikely today, but fragile)
- Debugging confusion: A user looking at the actual shell command run is shown Claude-Code-specific vars on a Codex launch, which is genuinely misleading. This was the exact bug that caused me to add an incorrect `unset` in a downstream orchestrator command in this session — a cascade of errors from one leak.
- Violates least-surprise: `spawn_agent cli=codex` should yield a clean `codex` invocation, not `VAR=1 VAR=1 codex`
- Breaks the `no_flicker` env var's intended purpose: if it was needed for Claude Code's rendering, it's wasted telemetry on other CLIs
Root cause hypothesis
Somewhere in cmuxlayer's agent dispatch (likely `src/agent-engine.ts` or similar), the env-var prefix is applied to the shell command regardless of the `cli` field on the agent spec. Probably something like:
```ts
const cmd = `cd ${repo} && MCP_CONNECTION_NONBLOCKING=1 CLAUDE_CODE_NO_FLICKER=1 ${cliBinary}`;
```
when it should be:
```ts
const envPrefix = cli === 'claude'
? 'MCP_CONNECTION_NONBLOCKING=1 CLAUDE_CODE_NO_FLICKER=1 '
: '';
const cmd = `cd ${repo} && ${envPrefix}${cliBinary}`;
```
Suggested fix
Scope the Claude-Code-specific env vars to `cli === 'claude'` only. Other CLIs get no prefix.
Workaround
Use `mcp__cmux__new_split` + `send_input` with the repoGolem launcher (e.g. `brainlayerCodex -s`) — the launcher handles its own env without the spawn_agent prefix logic.
Related: sibling issue on spawn_agent state-parser stuck in booting.
Summary
`mcp__cmux__spawn_agent` unconditionally prepends Claude-Code-specific env vars `MCP_CONNECTION_NONBLOCKING=1 CLAUDE_CODE_NO_FLICKER=1` to every spawn command, including `cli=codex`, `cli=cursor`, `cli=gemini`, `cli=kiro`. These env vars are meaningless to non-Claude-Code CLIs and shouldn't leak into those contexts.
Evidence
From the 2026-04-11 session, spawning with `cli=codex`:
```
cd ~/Gits/brainlayer && MCP_CONNECTION_NONBLOCKING=1 CLAUDE_CODE_NO_FLICKER=1 codex
```
The two env vars are Claude Code specific — they exist to stabilize Claude Code's alt-screen rendering for terminal parsers (see `cmuxlayer/src/agent-engine.ts` history — they were originally added in a PR that scoped them to Claude Code specifically, but the scoping was lost).
Why this matters
Root cause hypothesis
Somewhere in cmuxlayer's agent dispatch (likely `src/agent-engine.ts` or similar), the env-var prefix is applied to the shell command regardless of the `cli` field on the agent spec. Probably something like:
```ts
const cmd = `cd ${repo} && MCP_CONNECTION_NONBLOCKING=1 CLAUDE_CODE_NO_FLICKER=1 ${cliBinary}`;
```
when it should be:
```ts
const envPrefix = cli === 'claude'
? 'MCP_CONNECTION_NONBLOCKING=1 CLAUDE_CODE_NO_FLICKER=1 '
: '';
const cmd = `cd ${repo} && ${envPrefix}${cliBinary}`;
```
Suggested fix
Scope the Claude-Code-specific env vars to `cli === 'claude'` only. Other CLIs get no prefix.
Workaround
Use `mcp__cmux__new_split` + `send_input` with the repoGolem launcher (e.g. `brainlayerCodex -s`) — the launcher handles its own env without the spawn_agent prefix logic.
Related: sibling issue on spawn_agent state-parser stuck in booting.