Repository navigation
Description
Summary
Since v2.7.27, ocx claude injects CLAUDE_CODE_PROVIDER_MANAGED_BY_HOST=1 in every Claude Code auth mode. In the default subscription mode, OpenCodex intentionally does not provide ANTHROPIC_AUTH_TOKEN because Claude Code is expected to keep using the user's existing claude.ai OAuth session. On Claude Code 2.1.206, combining that native-OAuth path with the host-managed flag makes the CLI report Not logged in · Please run /login.
The failure is isolated to the flag: the same installed Claude Code and OAuth session work when the variable is absent or set to 0.
Environment
- Windows 11
- OpenCodex 2.7.31
- Claude Code 2.1.206
claudeCode.authMode: unset (default subscription mode)- No OpenCodex admission API keys configured
- Existing claude.ai Max OAuth login
Reproduction
All tests below were run in the same shell environment. Values were changed only for the child process; no persistent environment variables were modified.
$ claude -p "Reply with exactly: OK" --output-format text
OK
exit 0
$ env -u CLAUDE_CODE_PROVIDER_MANAGED_BY_HOST ocx claude -p "Reply with exactly: OK" --output-format text
Not logged in · Please run /login
exit 1
$ CLAUDE_CODE_PROVIDER_MANAGED_BY_HOST=0 ocx claude -p "Reply with exactly: OK" --output-format text
OK
exit 0
$ CLAUDE_CODE_PROVIDER_MANAGED_BY_HOST=1 claude -p "Reply with exactly: OK" --output-format text
Not logged in · Please run /login
exit 1
This also shows that the failure does not require OpenCodex's base URL: setting the flag on plain claude is sufficient in this environment.
Regression source
Commit 5875a0b added the unconditional default in buildClaudeEnv() and the GUI manual environment block. It first shipped in v2.7.27:
setDefault("CLAUDE_CODE_PROVIDER_MANAGED_BY_HOST", "1");The flag has a valid purpose: it protects OpenCodex routing from stale provider variables in ~/.claude/settings.json. The problem is that subscription mode simultaneously promises a native OAuth path and intentionally supplies no host credential:
if (!env.ANTHROPIC_AUTH_TOKEN && config.claudeCode?.authMode === "proxy") {
env.ANTHROPIC_AUTH_TOKEN = "opencodex-proxy";
}The current unit test checks only that the flag is assembled, not whether the resulting Claude Code process still has a usable subscription login.
Expected behavior
Default subscription mode should preserve the existing claude.ai OAuth login while still routing requests through OpenCodex.
Suggested direction
Gate the host-managed flag on whether OpenCodex actually supplies ANTHROPIC_AUTH_TOKEN:
- native subscription mode, no host token: do not inject the flag
- proxy mode or configured admission key: keep the flag and its settings-env routing protection
- preserve an explicit user-provided
0or1
The same condition should be applied to the GUI's copy/paste environment block. This avoids a Claude Code version gate and preserves the original anti-hijack behavior on host-token paths.
Temporary workaround
Use a shell-scoped override rather than a persistent setx value:
$env:CLAUDE_CODE_PROVIDER_MANAGED_BY_HOST = "0"
ocx claudeNotes
I am intentionally reporting only the directly reproduced behavior on Claude Code 2.1.206. I am not assuming an affected version range or a specific internal OAuth implementation beyond the observable login result.
Activity
Ingwannu commentedon Jul 22, 2026
Confirmed as a real regression.
CLAUDE_CODE_PROVIDER_MANAGED_BY_HOST=1is also treated as a host-auth assertion by current Claude Code, so injecting it in subscription mode without a host token made a valid claude.ai login appear unauthenticated.Fixed on
devin 2aa4430c:ANTHROPIC_AUTH_TOKEN: host-managed flag is left unset.CLAUDE_CODE_PROVIDER_MANAGED_BY_HOST=0continues to win.CLI environment and manual-block regression tests, type/i18n checks, and the full 3,394-test isolated suite passed. Closing as completed.
test(claude): prove the settings.json hijack defence per auth resolution
fix(claude): restore fail-closed credential stripping, and pin why
fix(lib,claude,server,vision): fall back to the bind address for loca…
fix(lib,claude,server,vision): fall back to the bind address for loca…
test(claude): prove the settings.json hijack defence per auth resolution
fix(claude): restore fail-closed credential stripping, and pin why
fix(lib,claude,server,vision): fall back to the bind address for loca…