CodeIssuesPull RequestsActionsSecurityInsights
✨ AI
More
Settings

feat(admin): show whether the AI key actually works, not just what it spent #5596

MergedXSccantynz wants to mergefeat/admin-ai-provider-healthmainopened 1d ago
ccantynzcommented 1d ago

This platform's Anthropic key has been returning 400 credit balance is too low since 2026-08-04. Every AI feature has deferred quietly for four weeks. The only way anyone learned it was an agent SSHing into the box and curling the API by hand, then reporting back.

Meanwhile /admin/ai-costs rendered a tidy $1.75 month. A page about AI that could not tell you the AI was dead.

What the panel shows

Three facts, kept separate on purpose:

Can we reach it right now An on-demand probe — one Haiku call at max_tokens 1, ~five millionths of a dollar. POST, not GET, so no prefetcher or link checker bills us on its own schedule; the result returns as redirect params so a refresh doesn't re-bill.
What the provider said Verbatim. credit balance is too low and invalid x-api-key are the same colour of red and demand opposite actions — the humanised "AI unavailable" the rest of the platform shows users is the wrong text for the one person who can fix it.
When a billed call last succeeded From the cost ledger. This is the one that matters: a probe nobody clicked reports nothing, and a page showing nothing looks exactly like a page showing health.

Advice is deliberately narrow

Only errors whose remedy is unambiguous get any. An unrecognised error gets the provider's own words and no guess — a confident wrong instruction costs more than none, because the reader follows it.

The out-of-credit advice names the trap this account actually hit: funds added under a different organisation than the key belongs to.

Safety

The probe never throws. It renders inside an admin page, and a health check that can crash the page it reports on turns a provider outage into what looks like a platform bug.

14 tests, mostly about wording — unusual for a test file and the point: "AI unavailable" and "your key's account is out of credit" are the same fact and different products.

ccantynzAI Reviewcommented 1d ago

AI Triage

(no summary)

Priority: medium Risk area: mixed

Suggested labels: (no label suggestions) Suggested reviewers: (no reviewer suggestions)

Suggestions only — nothing has been applied. The PR author stays in control.

gluecron[bot]🤖 botAI Reviewcommented 1d ago

AI review unavailable

The platform's AI balance is exhausted, so AI generation is temporarily unavailable. Nothing was lost. You can queue this as a repair for the internal agent from the repository's Health page, or try again once the balance is restored. The PR is otherwise unchanged.

Cross-repo impact

See what breaks downstream if this PR merges.

Analyze →
⮌ Merged

This pull request was merged into main.

c comment · e edit title · m merge · a approve · r request changes · ? shortcuts