Centralized model config (config.ts MODELS) + extraction seam logging

MODELS in config.ts is now THE single tuning table: model id + OpenRouter
reasoning effort for teacher/researcher/demoBuilder/visualMaker/extractor/
auditor. .env.local is secrets-only (LH_* model vars removed; all sub-agents
previously had NO reasoning setting -> provider-default unbounded thinking,
the extraction token burn). One factory (src/agent/models.ts modelFor) wires
all six call sites; test injection unchanged. EXTRACTION.everyNQuizAnswers
moved to a config literal too. Plus the §5 one-line-per-seam logging in the
extraction pipeline: pipeline start, extractor/auditor start + per-step,
audit kept, merged — previously silent until completion, which made live
runs look like they never fired.
This commit is contained in:
Amos
2026-09-01 01:47:47 +03:00
parent 5dab8d12d4
commit 59fc2ef863
11 changed files with 94 additions and 43 deletions
+36 -3
View File
@@ -14,15 +14,48 @@ export const PATHS = {
graph: path.join(ROOT, "data", "graph"),
} as const;
// ─── Models ────────────────────────────────────────────────────────────────
// THE single place every LLM is chosen and tuned. .env stays for secrets
// (API keys) only — model choice and thinking budget are product tuning,
// not deployment environment, and this section is the one place they grow.
// `effort` is OpenRouter's reasoning scale (docs: reasoning-tokens):
// "none" | "minimal" | "low" | "medium" | "high" | "xhigh".
// "none" disables reasoning tokens entirely.
export type ReasoningEffort = "none" | "minimal" | "low" | "medium" | "high" | "xhigh";
export interface ModelSpec {
/** OpenRouter model id (e.g. "z-ai/glm-5.3-flash"). */
model: string;
/** Thinking budget — what the model may spend on reasoning tokens. */
effort: ReasoningEffort;
}
export const MODELS = {
/** The teacher — streaming, lesson-facing: smart, but keep it lively. */
teacher: { model: "z-ai/glm-5.3-flash", effort: "medium" },
/** Background sub-agents: fast and cheap beats deep thought. */
researcher: { model: "z-ai/glm-5.3-flash", effort: "low" },
demoBuilder: { model: "z-ai/glm-5.3-flash", effort: "low" },
/** Must be vision-capable: it looks at rendered SVGs. */
visualMaker: { model: "anthropic/claude-sonnet-4.5", effort: "low" },
/** Extraction is judgment over given evidence — light thinking suffices. */
extractor: { model: "z-ai/glm-5.3-flash", effort: "low" },
/** The auditor verifies evidence exists; keep it cheap. */
auditor: { model: "z-ai/glm-5.3-flash", effort: "low" },
} satisfies Record<string, ModelSpec>;
export type ModelRole = keyof typeof MODELS;
/**
* The extraction pipeline (vision §1 construction): the sole graph writer.
* Triggered per chat once this many NEW quiz answers have landed since the
* chat's last extraction checkpoint (LH_EXTRACT_N). The trigger mechanism is
* a v1 placeholder — deliberately isolated behind one seam
* chat's last extraction checkpoint. The trigger mechanism is a v1
* placeholder — deliberately isolated behind one seam
* (server/turn-service.ts) so it can be swapped without touching the
* pipeline.
*/
export const EXTRACTION = { everyNQuizAnswers: Number(process.env.LH_EXTRACT_N ?? 3) } as const;
export const EXTRACTION = { everyNQuizAnswers: 3 } as const;
/**
* The LIVE graph store (src/store/graph.ts) — owned by the app's extraction