diff --git a/src/servers/sidecar/claude/user-instance.ts b/src/servers/sidecar/claude/user-instance.ts index 5f90ea67..603bf69f 100644 --- a/src/servers/sidecar/claude/user-instance.ts +++ b/src/servers/sidecar/claude/user-instance.ts @@ -126,6 +126,18 @@ const ANTHROPIC_PROXY_PORT = process.env.ANTHROPIC_PROXY_PORT ?? '5051'; function ensureAnthropicEnv(): void { process.env.ANTHROPIC_BASE_URL ??= `http://127.0.0.1:${ANTHROPIC_PROXY_PORT}`; + // Without this, every platform chat session is capped at 200K context while the same `claude` in a + // terminal gets Opus 5's full 1M — for no reason other than the proxy hop above. + // + // The CLI decides 1M eligibility with `provider === 'firstParty' && Fp()`, where `Fp()` is + // `!ANTHROPIC_BASE_URL || new URL(ANTHROPIC_BASE_URL).host === 'api.anthropic.com'`. Pointing the + // base URL at 127.0.0.1 fails that host check, so the client silently drops to 200K — the model is + // fine (`claude-opus-5` is `native_1m: true`) and so is the account; only the hostname is wrong. + // + // The assertion this flag makes is true here: the proxy forwards verbatim to api.anthropic.com and + // preserves `anthropic-beta` (see proxy.ts), so first-party is exactly what is on the other end. Do + // not set it on a base URL that points anywhere else. + process.env._CLAUDE_CODE_ASSUME_FIRST_PARTY_BASE_URL ??= '1'; if (process.env.ANTHROPIC_API_KEY) return; const secret = readProxySecretFromDisk();