Skip to content

forward model override env vars from shell to agent processes#2263

Merged
arnestrickmann merged 3 commits into
generalaction:mainfrom
sergeym-monday:emdash/fixing-claude-code-settings-z9ym6
May 28, 2026
Merged

forward model override env vars from shell to agent processes#2263
arnestrickmann merged 3 commits into
generalaction:mainfrom
sergeym-monday:emdash/fixing-claude-code-settings-z9ym6

Conversation

@sergeym-monday
Copy link
Copy Markdown
Contributor

@sergeym-monday sergeym-monday commented May 28, 2026

Summary

  • Adds ANTHROPIC_DEFAULT_HAIKU_MODEL, ANTHROPIC_DEFAULT_OPUS_MODEL, ANTHROPIC_DEFAULT_SONNET_MODEL, and ANTHROPIC_SMALL_FAST_MODEL to AGENT_ENV_VARS so model override env vars set in the user's shell profile are forwarded to spawned agent processes
  • Adds CLAUDE_CODE_SUBAGENT_MODEL, CLAUDE_CODE_DISABLE_BACKGROUND_TASKS, and CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS for the same reason

Why

buildAgentEnv() creates a minimal environment from an explicit allowlist, so any var not in AGENT_ENV_VARS is 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

  • Run pnpm run typecheck — passes
  • Run pnpm run lint — passes (pre-existing unrelated warning only)
  • Open a Claude Code session inside Emdash with model override vars set in shell profile; confirm context window matches what the terminal shows

🤖 Generated with Claude Code

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 28, 2026

Greptile Summary

This PR adds 7 environment variable names to the AGENT_ENV_VARS allowlist in src/main/core/pty/pty-env.ts so that model-override and feature-flag env vars set in a user's shell profile are forwarded to Claude Code processes spawned by Emdash.

  • Adds ANTHROPIC_DEFAULT_HAIKU_MODEL, ANTHROPIC_DEFAULT_OPUS_MODEL, ANTHROPIC_DEFAULT_SONNET_MODEL, and ANTHROPIC_SMALL_FAST_MODEL to expose Anthropic model-override vars (e.g. for extended context windows set via tools like axcli).
  • Adds CLAUDE_CODE_DISABLE_BACKGROUND_TASKS, CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS, and CLAUDE_CODE_SUBAGENT_MODEL to expose Claude Code feature-flag vars to spawned agent processes.

Confidence Score: 5/5

Safe 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 if (agentApiVars) block, which has no effect on behavior. No existing logic is touched.

No files require special attention.

Important Files Changed

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)"]
Loading

Reviews (1): Last reviewed commit: "forward model override env vars from she..." | Re-trigger Greptile

Copy link
Copy Markdown
Contributor

@arnestrickmann arnestrickmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your second contribution, @sergeym-monday - appreciate it!

This looks good to me. Thanks for the addition!

@arnestrickmann arnestrickmann merged commit e626b6f into generalaction:main May 28, 2026
1 check passed
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.

2 participants