Repository navigation
feat(admin): LLM_PROVIDER=anthropic routes Tier 1/2 crons to Claude Haiku - #200
Merged
Merged
Conversation
…aiku
The MLX Mac mini (mlx.tenki.no) is decommissioned, which silently
stalled every Tier 1/Tier 2 cron across all four pillars and the media
index with it. This adds a provider switch at the mlxChat() layer so all
eight orchestrators run unchanged against the Anthropic Messages API:
- lib/admin/anthropic.ts: anthropicTextChat() — plain-text completion
(no tool forcing; the orchestrators' JSON-in-text prompts + parse-retry
work as-is) with cache_control on the system prompt so the K calls in
one cron tick share a cache read.
- lib/admin/mlx.ts: LLM_PROVIDER env switch ('mlx' default, 'anthropic'
routes mlxChat/mlxPing/mlxModelId to Claude Haiku); AnthropicError
kinds map onto MlxError kinds so orchestrator retry semantics are
identical; mlx_health tracks the active provider.
- scripts/deploy.sh: LLM_PROVIDER placeholder + propagation to
.env.production.
Default model stays claude-haiku-4-5-20251001 (ANTHROPIC_MODEL
overrides). With LLM_PROVIDER unset nothing changes.
Co-Authored-By: Claude <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.
What
Adds an
LLM_PROVIDERenv switch at themlxChat()layer. WithLLM_PROVIDER=anthropic, every Tier 1/Tier 2 cron across all four pillars runs against Claude Haiku 4.5 via the Anthropic Messages API — all eight orchestrators unchanged. With it unset, behavior is byte-identical to today.Why
The MLX Mac mini (
mlx.tenki.no) is decommissioned. Since it went down, everyllm-*/*-llm-tier*cron has been failing, and the media landing card is stuck on the no-signal sentinel becausemedia_snapshot_indexneeds Tier 2-classified articles.How
anthropicTextChat()in [lib/admin/anthropic.ts]: plain-text completion (no tool forcing — the orchestrators' JSON-in-text prompts + parse-and-retry were built for a 4-bit Gemma; Haiku follows them strictly better),cache_controlon the system prompt so the K sequential calls in one tick share a cache read.llmProvider()switch;mlxChat/mlxPing/mlxModelId/mlxConfiguredroute to Anthropic in anthropic mode.AnthropicErrorkinds map ontoMlxErrorkinds (rate_limit/server → retryablehttp), so orchestrator retry/abort semantics are identical.mlx_health+ the /admin/llm badge track the active provider; the 5-min heartbeat pingsGET /v1/models(free, validates the key).LLM_PROVIDERplaceholder in admin.env + propagation to.env.production.Cost
Steady state is small: NAV ~44 AI postings/30d, media ~tens of articles/week, offentlig/brreg similar. Per call ≈ 0.5–2k input + ~200 output tokens on Haiku ($1/$5 per MTok) → expect cents per day; the June–July backlog drain is a one-off well under $5.
ANTHROPIC_MODELcan override the model if we ever want to trade up/down.Rollout
LLM_PROVIDER=anthropicin/opt/kibarometer/env/admin.env(ANTHROPIC_API_KEY is already provisioned for the manual drain buttons)llm-classify+media-llm-tier2ticks, checkmlx_healthand/admin/llmTypecheck clean, 309/309 unit tests pass. The 3 lint errors are pre-existing on main (unescaped apostrophes in startups/companies + an
<a>in about/bot).🤖 Generated with Claude Code