Skip to content

feat: adopt ai-kit's tryChain + createHealthTracker; add /api/health - #26

Merged
github-actions[bot] merged 1 commit into
mainfrom
feat/ai-kit-chain-health
Aug 29, 2026
Merged

feat: adopt ai-kit's tryChain + createHealthTracker; add /api/health#26
github-actions[bot] merged 1 commit into
mainfrom
feat/ai-kit-chain-health

Conversation

@catomean

Copy link
Copy Markdown
Collaborator

Summary

  • scripts/lib/groq-client.ts: callGroq now walks ai-kit's fallback chain for Groq (tryChain) when no explicit model is given, instead of calling one pinned id once. GROQ_MODELS' alias table is now derived from that chain rather than hardcoding the same ids a second time.
  • src/app/api/ai/gesuch-section/route.ts: deleted its own separate hand-rolled Groq fetch (a second copy of exactly what groq-client.ts already did — its own docstring says it was "extracted from" this route, but the route was never switched over) and now calls callGroq directly.
  • New: src/lib/llm-health.ts (wraps ai-kit's createHealthTracker) + src/app/api/health/route.ts — hirnli had no health endpoint at all. /api/health for liveness, /api/health?strict=1 for readiness (503 only when the LLM chain is actually down).
  • ai-kit bumped to v0.5.0.

This closes the same gap this session already fixed in botsmann: hirnli was flagged by a fleet-wide AI-tooling audit as having zero shared-package adoption with no stated reason to skip, and the smallest hand-rolled surface in the fleet.

Test plan

  • Full verify green locally: lint, lint:umlauts, typecheck, 889 tests (17 new — fallback-chain demotion, chain-exhaustion, explicit-model-stays-single-shot, health state machine), production build
  • CI green on this PR

hirnli has already been silently taken down once by a single retired
Groq model id -- every route and script here called ONE pinned model,
once, with nothing between that and total failure. This closes that
gap the same way botsmann's did this session.

- scripts/lib/groq-client.ts: callGroq now walks ai-kit's fallback
  chain for Groq via tryChain when the caller leaves the model
  unspecified, instead of calling one hardcoded id. GROQ_MODELS' alias
  table is now derived FROM that chain rather than hardcoding the same
  ids a second time. An explicit model/alias is still honoured as-is
  and alone, unchanged.
- src/app/api/ai/gesuch-section/route.ts: this route hand-rolled its
  OWN separate Groq fetch, with its own hardcoded model id -- a second
  copy of exactly what groq-client.ts already did, despite that
  file's own docstring saying it was "extracted from" this route. Now
  calls callGroq directly; ~50 lines of duplicated fetch/error-handling
  code deleted.
- src/lib/llm-health.ts + src/app/api/health/route.ts (both new):
  hirnli had no health endpoint at all. Records success/failure around
  the gesuch-section route via ai-kit's createHealthTracker, exposed
  at /api/health (liveness) and /api/health?strict=1 (readiness --
  503 only when the LLM chain itself is down, never on a restart-proof
  problem).

ai-kit bumped to v0.5.0. Full verify green: lint, lint:umlauts,
typecheck, 889 tests (17 new), production build.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@github-actions
github-actions Bot merged commit 927ea5a into main Aug 29, 2026
1 check passed
@github-actions
github-actions Bot deleted the feat/ai-kit-chain-health branch August 29, 2026 09:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant