fix(runtime): strip reintroduced Anthropic routing env

Prevent settings-profile Claude launches from reintroducing
routing/auth env after the final env merge.

- re-strip ANTHROPIC_BASE_URL, ANTHROPIC_AUTH_TOKEN, and
  ANTHROPIC_API_KEY after merging envVars
- preserve model-selection env such as ANTHROPIC_MODEL and
  ANTHROPIC_DEFAULT_SONNET_MODEL
- add a regression test covering explicit settings-profile
  overrides that try to reintroduce routing env

Verification:
- bun test tests/unit/utils/claudecode-env-stripping.test.ts
- bun run validate
This commit is contained in:
Wooseong Kim
2026-04-22 14:08:37 +09:00
parent 5881a505d9
commit 1fd2fb83fb
2 changed files with 24 additions and 1 deletions
+4 -1
View File
@@ -177,10 +177,13 @@ export function execClaude(
const mergedEnv = envVars
? { ...baseEnv, ...claudeLaunchEnv, ...envVars, ...webSearchEnv }
: { ...baseEnv, ...claudeLaunchEnv, ...webSearchEnv };
const effectiveMergedEnv = stripInheritedAnthropicRoutingEnv
? stripAnthropicRoutingEnv(mergedEnv)
: mergedEnv;
// Strip Claude Code nested session guard env var to allow CCS delegation
// (Claude Code v2.1.39+ sets CLAUDECODE to detect nested sessions)
const env = stripClaudeCodeEnv(mergedEnv);
const env = stripClaudeCodeEnv(effectiveMergedEnv);
if (profileType !== 'account') {
try {