fix(llm): take model ids from ai-kit, and try more than one - #137
Merged
Conversation
Both ids in `API_CONFIG` have been retired by their vendors: `llama-3.1-8b-instant` at Groq and `openai/gpt-oss-20b:free` at OpenRouter. With a valid key, this app's chatbot was answering 404. Nothing was neglected here. The constant carried the correct instruction — "free catalogues rot; when it does, replace it with another `:free` id" — and that is precisely the maintenance that did not happen, because nothing tells a constant when it has stopped being true. So the ids leave this repo. `ai-kit` holds one list for the fleet, re-probes it against the live catalogues, and dotfiles' daily audit asks both vendors whether those ids still exist. One id was also not enough on its own. `generateWithBestProvider` picks ONE provider and calls it exactly once, so a retirement had nothing between it and a dead chatbot. Each vendor's call now walks that vendor's list: a 404 (retired) or a 429 (busy or spent) steps to the next model instead of surfacing. This is model-level fallback, not vendor-level — provider selection is untouched. That is the smaller half of the protection, since a spent daily budget is org-wide and kills every model at a vendor together. It is also the half that covers rot, which is what actually happened here, twice. An explicit caller override is still honoured as-is and alone. If someone names a model, quietly answering from a different one is worse than failing. The cost rule that lived in the deleted comment survives, and got stronger. `free-fallback.test.ts` used to regex ONE constant; it now runs `modelCost` over every OpenRouter id this app could send, using the same function the rest of the fleet prices models with. OpenRouter is only reached when Groq's free tier is spent — when nobody is watching — so a paid id there turns an outage into a bill. The old tests deserve a note, because they passed throughout the outage: they mocked `llama-3.1-8b-instant` and asserted it back, agreeing with production about an id production was refusing. Worse, the OpenRouter test asserted `anthropic/claude-sonnet-5` — a paid model on the free-tier fallback path, the exact thing the fleet rule forbids, green the whole time. They now assert against the chain, plus two new cases: a retired first model falls through to a different one, and exhausting the list names the whole list. `jest.config.js` transforms `ai-kit`, which is ESM-only. The comment there says what does NOT belong in that list, since a transitive entry would mean a package leaking a dependency through a re-export — a bug to fix at the source. verify: format, lint, typecheck, 232 tests, build. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
github-actions Bot
pushed a commit
that referenced
this pull request
Aug 28, 2026
#154) 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. Claude-Session: https://claude.ai/code/session_01HVwg8DKHQktxJuHeLM3xpG Co-authored-by: Mao Nakamoto <41178744+maonakamoto@users.noreply.github.com> Co-authored-by: Claude Opus 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.
fix(llm): take model ids from ai-kit, and try more than one
Both ids in
API_CONFIGhave been retired by their vendors:llama-3.1-8b-instantat Groq andopenai/gpt-oss-20b:freeat OpenRouter. Witha valid key, this app's chatbot was answering 404.
Nothing was neglected here. The constant carried the correct instruction —
"free catalogues rot; when it does, replace it with another
:freeid" — andthat is precisely the maintenance that did not happen, because nothing tells a
constant when it has stopped being true. So the ids leave this repo.
ai-kitholds one list for the fleet, re-probes it against the live catalogues, and
dotfiles' daily audit asks both vendors whether those ids still exist.
One id was also not enough on its own.
generateWithBestProviderpicks ONEprovider and calls it exactly once, so a retirement had nothing between it and
a dead chatbot. Each vendor's call now walks that vendor's list: a 404 (retired)
or a 429 (busy or spent) steps to the next model instead of surfacing.
This is model-level fallback, not vendor-level — provider selection is untouched.
That is the smaller half of the protection, since a spent daily budget is
org-wide and kills every model at a vendor together. It is also the half that
covers rot, which is what actually happened here, twice.
An explicit caller override is still honoured as-is and alone. If someone names
a model, quietly answering from a different one is worse than failing.
The cost rule that lived in the deleted comment survives, and got stronger.
free-fallback.test.tsused to regex ONE constant; it now runsmodelCostoverevery OpenRouter id this app could send, using the same function the rest of the
fleet prices models with. OpenRouter is only reached when Groq's free tier is
spent — when nobody is watching — so a paid id there turns an outage into a bill.
The old tests deserve a note, because they passed throughout the outage: they
mocked
llama-3.1-8b-instantand asserted it back, agreeing with productionabout an id production was refusing. Worse, the OpenRouter test asserted
anthropic/claude-sonnet-5— a paid model on the free-tier fallback path, theexact thing the fleet rule forbids, green the whole time. They now assert
against the chain, plus two new cases: a retired first model falls through to a
different one, and exhausting the list names the whole list.
jest.config.jstransformsai-kit, which is ESM-only. The comment there sayswhat does NOT belong in that list, since a transitive entry would mean a package
leaking a dependency through a re-export — a bug to fix at the source.
verify: format, lint, typecheck, 232 tests, build.
🤖 Generated with Claude Code