What happens#
The Xiaomi models poll fails outright on about 4% of runs. The cause is a docs page returning 404 for a moment:
fetch failed: https://mimo.mi.com/static/docs/api/chat/openai-api.md → 404 Not Found (job models-poll)
PostHog ingest_failed events for Xiaomi: 3 on 2026-11-11, 4 on 2026-11-12, 4 on 2026-11-13. The latest two were consecutive polls, at 19:07 and 19:20 UTC. The URL returns 200 when checked by hand, so the 404 is an upstream glitch. The code makes it worse: it turns one docs glitch into a failure of the whole provider poll.
Why#
src/server/providers/adapters/xiaomi.ts, listModels, loads four pages with one Promise.all and none of them in tryDocs:
XIAOMI_MODELS: the listing.
XIAOMI_PRICING
XIAOMI_THINKING
- the chat docs (
openai-api.md), which is used only for modalities.
CLAUDE.md says to wrap a docs load in tryDocs (model-facts.ts). Its throw then marks the affected rows unavailable(...) and is reported as docsFailures, and the provider's poll carries on. The listing itself is never wrapped.
Fix#
- Leave
XIAOMI_MODELS (the listing) unwrapped.
- Load the pricing, thinking and chat docs pages through
tryDocs.
- When a docs page fails, the facts it supplies go
unavailable, so their stored values are kept:
- pricing page:
pricing
- thinking page:
reasoning
- chat docs:
modalities
- Never null or guess a fact because its page failed. When the pricing page fails, don't clear free-tier prices either. Follow the
FactAbsence rules in providers/types.ts.
- Add a test: when the chat docs page returns 404, the listing still returns every model, modalities are marked
unavailable, and a docsFailures entry names the URL.