forward model override env vars from shell to agent processes#2263
Conversation
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Greptile SummaryThis PR adds 7 environment variable names to the
Confidence Score: 5/5Safe to merge — the change is an additive allowlist expansion with no logic modifications. All seven new entries are inserted in correct alphabetical position and match legitimate Anthropic/Claude Code environment variable names. The only other diff line is a blank line inside the No files require special attention.
|
| Filename | Overview |
|---|---|
| src/main/core/pty/pty-env.ts | Adds 7 new entries to AGENT_ENV_VARS in correct alphabetical order; also introduces an incidental trailing blank line inside the agentApiVars block — no logic changes. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["User Shell Profile (~/.zshrc)"] -->|"sets ANTHROPIC_DEFAULT_*_MODEL\nANTHROPIC_SMALL_FAST_MODEL\nCLAUDE_CODE_* vars"| B["Emdash Main Process\n(process.env)"]
B --> C{"buildAgentEnv()"}
C -->|"agentApiVars = true"| D["Iterate AGENT_ENV_VARS allowlist"]
D -->|"key present in process.env?"| E["Forward to agent env"]
D -->|"key not in allowlist\n(silently dropped before this PR)"| F["Dropped"]
E --> G["Spawned Claude Code\nAgent Process"]
G -->|"Reads model override vars"| H["1M context / correct model"]
F --> I["200k default (wrong behavior)"]
Reviews (1): Last reviewed commit: "forward model override env vars from she..." | Re-trigger Greptile
arnestrickmann
left a comment
There was a problem hiding this comment.
Thank you for your second contribution, @sergeym-monday - appreciate it!
This looks good to me. Thanks for the addition!
Summary
ANTHROPIC_DEFAULT_HAIKU_MODEL,ANTHROPIC_DEFAULT_OPUS_MODEL,ANTHROPIC_DEFAULT_SONNET_MODEL, andANTHROPIC_SMALL_FAST_MODELtoAGENT_ENV_VARSso model override env vars set in the user's shell profile are forwarded to spawned agent processesCLAUDE_CODE_SUBAGENT_MODEL,CLAUDE_CODE_DISABLE_BACKGROUND_TASKS, andCLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMSfor the same reasonWhy
buildAgentEnv()creates a minimal environment from an explicit allowlist, so any var not inAGENT_ENV_VARSis silently dropped — even if the Emdash main process inherited it from the user's login shell.Tools like axcli set model override vars in
~/.zshrc(e.g.ANTHROPIC_DEFAULT_SONNET_MODEL=claude-sonnet-4-6[1m]) to unlock extended capabilities such as 1M context windows. Without this fix, Claude Code sessions spawned inside Emdash fall back to their hardcoded 200k default context window while the same Claude Code version launched directly from a terminal sees 1M — because the terminal sources the shell profile but Emdash's clean env does not include those vars.Test plan
pnpm run typecheck— passespnpm run lint— passes (pre-existing unrelated warning only)🤖 Generated with Claude Code