Skip to content

fix(ai): a revoked key on the first provider took the whole chain down - #154

Merged
github-actions[bot] merged 1 commit into
mainfrom
fix/llm-provider-failover
Aug 28, 2026
Merged

fix(ai): a revoked key on the first provider took the whole chain down#154
github-actions[bot] merged 1 commit into
mainfrom
fix/llm-provider-failover

Conversation

@catomean

Copy link
Copy Markdown
Collaborator

generateWithBestProvider picked one provider and called it once. Being configured counted as being available, so a present-but-revoked key was indistinguishable from a working one: botsmann's Groq key started returning 401 and the entire AI layer went down, with no attempt at anything else.

Why this matters concretely

kivvi survives the same dead-Groq situation on this box because it has an OpenRouter key and reaches it. botsmann would not have — even after adding one. Groq is chosen first for merely existing, and its 401 was terminal.

The fix

getProviderChain() every configured provider in preference order (Ollama → Groq → OpenRouter), not just the first
generateWithBestProvider() walks that chain, demoting on failure, and only throws once every provider has been tried

generateLLMResponse already walks the model list within a provider (#137), so this is the layer above: models, then providers. The error now names each provider that failed and why.

⚠️ This does not restore botsmann's AI

Every working LLM key on the box belongs to a client:

App Owner Kind Groq OpenRouter
aoz-wohnen / aoz-demo AOZ client-app
revamp-info RevampIT client-site
kivvi RevampIT client-app ❌ 401
botsmann bitbaum product ❌ 401

botsmann is a bitbaum product, so pointing it at one of those would bill a client for our usage. It needs its own key. What this PR does is make sure that once a second key exists, one dead key can never take the product down again.

Verify

format:check, lint, typecheck, 272 tests, build — all green.

🤖 Generated with Claude Code

https://claude.ai/code/session_01HVwg8DKHQktxJuHeLM3xpG

generateWithBestProvider picked ONE provider and called it once. Being
configured counted as being available, so a present-but-revoked key was
indistinguishable from a working one: botsmann's Groq key started returning
401 and the entire AI layer went down, with no attempt at anything else.

kivvi survives the same dead-Groq situation on this box because it has an
OpenRouter key and reaches it. botsmann would not have, even after adding
one -- Groq is chosen first for merely existing, and its 401 was terminal.

  getProviderChain()          every configured provider, in preference order
                              (Ollama, Groq, OpenRouter) rather than the first
  generateWithBestProvider()  walks that chain, demoting on failure, and only
                              throws once every provider has been tried

generateLLMResponse already walks the model list within a provider (#137), so
this is the layer above: models, then providers. The error now names each
provider that failed and why, instead of surfacing whichever one happened to
be first.

This does NOT restore botsmann's AI. Every working LLM key on the box belongs
to a client -- AOZ's and RevampIT's -- and botsmann is a bitbaum product, so
pointing it at one would bill a client for our usage. It needs its own key.
What this does is make sure that once a second key exists, one dead key can
never take the product down again.

verify: format, lint, typecheck, 272 tests, build -- all green.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HVwg8DKHQktxJuHeLM3xpG
@github-actions
github-actions Bot merged commit 5f83b30 into main Aug 28, 2026
1 check passed
@github-actions
github-actions Bot deleted the fix/llm-provider-failover branch August 28, 2026 16:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant