Repository navigation
Fall back to the API key when the claude CLI loses its login - #18
Merged
Merged
Conversation
The host's CLI OAuth session expired on 2026-11-12 and every fold failed for six days: the fallback key only covered usage limits. A failed authentication (expired/revoked OAuth, 401, "Please run /login", invalid key) now switches the run to LORE_FALLBACK_ANTHROPIC_API_KEY too, and the once-per-episode email says the login was lost, that it will not recover by itself, and how to restore it with `claude setup-token`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
The
claudeCLI on lore-host lost its OAuth session around 2026-11-12 ("Failed to authenticate: OAuth session expired and could not be refreshed"). Every fold on every client failed for six days, and nothing said so: the fallback key only covered usage limits.What
authFailureReason/cliFailureReasoninsrc/llm-fallback.ts: a failed authentication (expired/revoked OAuth, HTTP 401, "Please run /login", invalid key or token) now switches the run toLORE_FALLBACK_ANTHROPIC_API_KEY, like a usage limit. Each new run still tries the subscription first, so it switches back once the login works.LORE_LLM_FALLBACK_NOTIFYdistinguishes the two: "Lore lost its Claude login and switched to the API key", saying it will not fix itself and how to restore it (claude setup-token→ 1Password →CLAUDE_CODE_OAUTH_TOKENin/etc/lore/env). Never includes the key. The limit email is unchanged.Testing
New tests use the exact host error from Nov 12; typecheck and the full suite pass (470).
The host itself now uses a long-lived
CLAUDE_CODE_OAUTH_TOKENfromclaude setup-token, so this is the safety net for when that expires (~1 year).🤖 Generated with Claude Code