Daily LLM review
What it is
Section titled “What it is”Button → Pages Function → Anthropic API → short text review. Two audiences:
- Teacher. Cohort summary: strengths, weaknesses, ZPD-band microskills, who to watch.
- Student. Personal take: mastered topics, growth zone, where to put more attempts.
/api/daily-review, mis arvutab agregaadid koodis, saadab need Claude'ile ja saab lühikese kokkuvõtte. Arvud, mis mudelisse läksid, on avatavas plokis.Where the LLM boundary sits
Section titled “Where the LLM boundary sits”The project has a hard rule: math facts never go through the LLM (see
web/lib/explain.ts). This feature respects that boundary — the LLM only
receives pre-computed aggregates from src/lib/review-stats.ts. The
prompt explicitly forbids inventing pKnown values, names, or topics. The
collapsible “Raw numbers” panel shows exactly the JSON that went in.
Under the hood
Section titled “Under the hood”[DailyReviewPanel widget] │ POST /api/daily-review { audience, snapshotKey, focusUserId? } ▼[Pages Function functions/api/daily-review.ts] 1. validates payload 2. FileSnapshotLoader → student_skill_state-shaped JSON 3. cohortAggregates / studentAggregates (medians, ZPD bands) 4. system + user → Anthropic Messages API (prompt caching) 5. parses model JSON 6. returns { markdown, actionItems, rawNumbers, usage }The snapshot is currently read from src/data/snapshots/demo-cohort.json
(produced by scripts/seed-demo-snapshot.mjs over data/matx-define). When
the MATx companion exposes the student_skill_state endpoint (PR-1), one
line in the Pages Function swaps to HttpSnapshotLoader — schema matches
(user_id, competency_id, pKnown, attempts, last_updated).
Model and cost
Section titled “Model and cost”Default: claude-haiku-4-5-20251001. Short reviews don’t need extended
thinking. The system block is marked cache_control: ephemeral, so repeated
clicks within 5 min read it from cache. Only the button triggers a call — no
cron, no background calls.
Production setup
Section titled “Production setup”In Cloudflare Pages → Settings → Environment variables, add
ANTHROPIC_API_KEY (Encrypted). Locally: cp study-guide/.dev.vars.example study-guide/.dev.vars, paste a key, and run npx wrangler pages dev dist.