fix(ai): a revoked key on the first provider took the whole chain down - #154
Merged
Conversation
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
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.
generateWithBestProviderpicked 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
kivvisurvives 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()generateWithBestProvider()generateLLMResponsealready 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.Every working LLM key on the box belongs to a client:
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