[BUG] Opening session sidebar wipes API key auth for current session

Open 💬 0 comments Opened Jul 4, 2026 by noelpuig

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?

I press left arrow and my session credentials break.
"Login required - Run /login · Invalid API key · Fix external API key"

By comparing /status, I realized that my "Anthropic base URL" property disappears.

<img width="938" height="456" alt="Image" src="https://github.com/user-attachments/assets/d4373457-d1e5-4b99-a122-5e8fe12f5e1a" />

If I have any other session running on my computer it is unaffected, as well as new sessions created after.

What Should Happen?

All credentials remain

Error Messages/Logs

## Session log (session 5030a1e7)

Both messages are in the same bg session. First succeeds, second fails after opening the sidebar.


[2026-07-04T09:55:26.691Z] sessionKind=bg entrypoint=cli role=user
  this is a test before sidebar. say "hello"

[2026-07-04T09:55:29.134Z] sessionKind=bg entrypoint=cli role=assistant
  Hello

[2026-07-04T09:55:53.891Z] sessionKind=bg entrypoint=cli role=user
  I just pressed left arrow + enter. Say "hello" again

[2026-07-04T09:55:54.263Z] sessionKind=bg entrypoint=cli role=assistant error=authentication_failed apiErrorStatus=401
  Invalid API key · Fix external API key


## Daemon log (~/.claude/daemon.log)

Daemon has ANTHROPIC_API_KEY in its /proc/PID/environ, but reports no token found:


[2026-07-04T09:34:03.638Z] [supervisor] ─── daemon start ─── version=2.1.201 pid=114674 origin=transient
[2026-07-04T09:34:03.648Z] [supervisor] auth: no token found, will re-check keychain every 30s
[2026-07-04T09:34:03.650Z] [supervisor] workers=0
[2026-07-04T09:34:03.656Z] [bg] bg: control socket bound at /tmp/cc-daemon-1000/6bce5a5f/control.sock
[2026-07-04T09:34:03.727Z] [bg] bg spawned fed205ea (slash)
[2026-07-04T09:34:03.727Z] [bg] bg spawned 59f57d99 (spare)

Steps to Reproduce

Steps to reproduce

  1. Start Claude Code with ANTHROPIC_API_KEY and ANTHROPIC_BASE_URL set via env vars
  2. Send a message — works fine
  3. Open the session sidebar (left arrow → Enter)
  4. Return to the session, send another message
  5. Immediate 401: "Invalid API key · Fix external API key"

I can reproduce this in my other machine where I have the same setup.

Claude Model

Opus

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

2.1.201 (Claude Code)

Platform

Anthropic API

Operating System

Ubuntu/Debian Linux

Terminal/Shell

WSL (Windows Subsystem for Linux)

Additional Information

_No response_

View original on GitHub ↗