claude sessions write autoMode:true into profile settings; CCR syncs it into the config store and rewrites it into settings.json on every launch, which makes Claude Code ignore apiKeyHelper ("Not logged in")
claude sessions write autoMode: true into profile settings; CCR syncs it into config and rewrites it into settings.json on every launch → Claude Code ignores apiKeyHelper and reports "Not logged in"
Environment
- Claude Code Router Desktop v3.1.0 (Windows, port 3456 gateway)
- Windows 10 19045 x64
- Claude Code CLI 2.1.270
- Auth mode: profile-managed
apiKeyHelperpointing atbin/ccr-claude-code-api-key-<profile>.cmd(gateway token),ANTHROPIC_BASE_URL=http://127.0.0.1:3456
Summary
Claude Code (CLI ≥ the autoMode builds) persists autoMode: true into <CLAUDE_CONFIG_DIR>/settings.json when the user enables automatic mode in a session. For the CCR-managed profile (CLAUDE_CONFIG_DIR=%APPDATA%\claude-code-router\profiles\default-claude-code\claude), this triggers a feedback loop that fully breaks gateway auth:
- Claude Code writes
autoMode: true(plusautoMemoryEnabled,autoCompactEnabled) into the profilesettings.jsonduring a session. - CCR picks those up as
claudeSettingsin its config store (visible inprofile.profiles[].claudeSettings). - On every
ccr-app "<Profile>"launch, CCR PREPARE regeneratessettings.jsonfrom the config store — soautoModeis now persistent and cannot be removed by editingsettings.json. - With
autoMode: truepresent, Claude Code ignoresapiKeyHelperand demands the interactive login flow: every session printsNot logged in · Please run /loginand requests fail until/loginis run.
So a single session where the user toggles auto mode permanently disables gateway auth for that profile — with no error in CCR, and nothing in the UI indicating that claudeSettings.autoMode now controls auth.
Root-cause isolation (bisection evidence)
I bisected the profile settings file (everything else verbatim, one key removed per run, apiKeyHelper always present and valid):
| settings.json state | Result |
|---|---|
Full profile settings (incl. autoMode) |
Not logged in · Please run /login |
Full profile minus autoMode |
auth via apiKeyHelper works, requests succeed |
Full profile minus autoMemoryEnabled only |
still Not logged in |
Full profile minus autoCompactEnabled only |
still Not logged in |
(model, modelSettings, env block contents, and the discovery flag were all individually ruled out as well.)
Recovery: stop CCR Desktop → remove claudeSettings.autoMode from the config store (e.g. delete the key from the profile's claudeSettings) → start CCR → auth via apiKeyHelper works again.
Why this hurts
- The failure is silent in CCR: the gateway is healthy, the token helper is valid, but every session says "Not logged in".
- The user-facing action that causes it (toggling auto mode in a Claude session) has no warning, and the fix requires editing the CCR config store by hand with CCR stopped.
apiKeyHelperis the auth mechanism CCR itself sets up for gateway profiles, so this makes CCR-managed profiles unstable against Claude Code's own settings writes.
Suggested directions
Any of these would prevent the loop:
- Don't sync
autoModeintoclaudeSettings(treat it like other auth-adjacent state CCR owns), or - Don't write
autoModeback intosettings.jsonwhen regenerating (leave Claude-managed keys alone in the managed file), or - At minimum: when
apiKeyHelperis configured andautoMode: trueis present, surface a warning in the UI ("this combination disables gateway auth") — and consider a one-click "fix" that removesautoModefrom the store.
Related existing reports about CCR unconditionally taking over profile settings: #1575, #1602 (same "regenerated on every launch" surface, different keys).
Reproduction outline
- Fresh CCR-managed Claude Code profile (apiKeyHelper + gateway base URL).
- In a Claude Code session, enable auto mode → Claude writes
autoMode: trueinto the profilesettings.json. - Restart the profile (
ccr-app "<Profile>"or UI launch):settings.jsonstill containsautoMode(now also in the CCR store). - Any prompt →
Not logged in · Please run /login; title-generation requests log[claude-code:unrecognized_model]-style noise or auth errors. - Remove
autoModefrom the store with CCR stopped → launch → auth works.
Happy to attach the full bisection transcript or test a candidate fix.
Source: musistudio/claude-code-router