Desktop app injects empty ANTHROPIC_API_KEY, bypasses Max plan subscription — context stuck at 200K

Resolved 💬 3 comments Opened Mar 20, 2026 by egittog-dotcom Closed Mar 24, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

Bug: Desktop app Code tab stuck at 200K context for Max 20x plan

Environment:

  • macOS 13.0 (Ventura)
  • Claude Desktop v1.1.7714
  • Claude Code engine v2.1.78
  • Max 20x plan (confirmed active)

Problem

Context window stuck at 200K instead of 1M on Desktop Code tab. The /context command confirms Tokens: 49.7k / 200k. Terminal CLI on the same machine, same account, shows 1M correctly.

Root causes found

1. Desktop app injects empty ANTHROPIC_API_KEY:
Running ps eww on the Claude Code child process (PID visible in Activity Monitor) shows:

  • ANTHROPIC_API_KEY= (empty string)
  • ANTHROPIC_BASE_URL=https://api.anthropic.com

These are NOT user-set environment variables. Confirmed by checking ~/.zshrc, env, and launchctl getenv. The Desktop app itself injects them when spawning the Code engine.

2. Feature flag mismatch:
In ~/.claude.jsoncachedGrowthBookFeatures:

  • tengu_cobalt_compass: true (1M should be enabled)
  • tengu_hawthorn_window: 200000 (overrides to 200K)

These flags contradict each other. Manually setting tengu_hawthorn_window: 1000000 gets overwritten on app restart — the server re-sends 200000 for Desktop client type.

3. OAuth token scope difference:
Desktop creates tokens with only: user:file_upload, user:inference, user:profile
Terminal CLI creates tokens with: user:file_upload, user:inference, user:mcp_servers, user:profile, user:sessions:claude_code

Missing user:sessions:claude_code scope may be related to 1M entitlement.

Steps to reproduce

  1. Max 20x plan account
  2. Open Claude Desktop app → Code tab
  3. Open new session, run /context
  4. Shows 200k instead of 1M
  5. Open Terminal, run claude, then /context → shows 1M

What was tried (none resolved)

  • Revoked all OAuth tokens on claude.ai/settings
  • Deleted all Keychain entries (Claude Safe Storage + Claude Code-credentials)
  • Cleared Electron cache (Cache, Code Cache, Session Storage)
  • Removed ~/.claude/.credentials.json
  • Unset ANTHROPIC_API_KEY and ANTHROPIC_BASE_URL via launchctl
  • Manually overrode tengu_hawthorn_window to 1000000 (server overwrites on restart)
  • Reinstalled app (both current and previous version)
  • Multiple logout/login cycles

Expected behavior

Desktop Code tab should provide 1M context for Max 20x plan users, same as Terminal CLI on the same account.

Related issues

  • #24317 (OAuth refresh token race condition)
  • #24485 (Desktop 403 while CLI works)
  • #32816 (Code/Cowork 403, CLI works)
  • #12383 (Separate Keychain entries, token accumulation)

What Should Happen?

Desktop Code tab should provide 1M context window for Max 20x plan users, identical to the Terminal CLI behavior on the same account. Running /context should show Tokens: X / 1M instead of Tokens: X / 200k. The Desktop app should not inject empty ANTHROPIC_API_KEY into the Code engine environment, and OAuth tokens created by the Desktop should include the same scopes as the CLI (including user:sessions:claude_code and user:mcp_servers). The feature flag tengu_hawthorn_window should return 1000000 for Max plan Desktop clients, consistent with tengu_cobalt_compass: true.

Error Messages/Logs

## /context output (Desktop Code tab)
Model: claude-opus-4-6
Tokens: 49.7k / 200k (25%)

## Feature flags from ~/.claude.json
tengu_cobalt_compass: true
tengu_hawthorn_window: 200000

## Process environment (ps eww on Claude Code child process)
ANTHROPIC_API_KEY=
ANTHROPIC_BASE_URL=https://api.anthropic.com

## OAuth token scopes (from claude.ai/settings)
Desktop token: user:file_upload, user:inference, user:profile
CLI token: user:file_upload, user:inference, user:mcp_servers, user:profile, user:sessions:claude_code

## Keychain entries
Claude Safe Storage (account: Claude) — Desktop
Claude Safe Storage (account: Claude Key) — Desktop
Claude Code-credentials (account: giuseppeegitto) — CLI

## App version
Claude Desktop: 1.1.7714
Claude Code engine: 2.1.78
macOS: 13.0 (Ventura)

Steps to Reproduce

  1. Have a Max 20x plan account
  2. Install Claude Desktop app (v1.1.7714 or latest)
  3. Open Claude Desktop → click "Code" tab
  4. Start a new session in any project directory
  5. Type /context and press Enter
  6. Observe: shows Tokens: X / 200k instead of Tokens: X / 1M
  7. Now open macOS Terminal, run claude --model claude-opus-4-6
  8. Type /context in the Terminal CLI session
  9. Observe: shows Tokens: X / 1M — correctly reflecting Max plan entitlement
  10. Both sessions use the same account, same machine, same plan — different context limits

Claude Model

None

Is this a regression?

Yes, this worked in a previous version

Last Working Version

_No response_

Claude Code Version

Claude 1.1.7714 (3bd6f6) 2026-03-19T14:50:53.000Z

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Terminal.app (macOS)

Additional Information

This issue appeared suddenly on March 19, 2026. The same account had 1M context working correctly on the Desktop Code tab earlier that day. The change occurred after connecting Claude Code via Terminal CLI on the same machine — the CLI created a separate OAuth token with full scopes, and after that the Desktop Code tab lost 1M access. Multiple cleanup attempts (token revocation, Keychain wipe, cache clear, reinstall) did not restore 1M. The server consistently returns tengu_hawthorn_window: 200000 for the Desktop client while the CLI gets 1000000.

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗