mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-14 22:50:51 +00:00
Unit tests for the turn budget and the no-progress brake, the budgeted loop (every stop reason, the round-by-round ledger, repeated calls, questions, comparisons, reasoning and provider state), the trail recorder and its screen, clarifications through the tool and the brake, the comparison table and chart, the trail column and its owner-only read, the reply frames, and the turn's frames end to end through the route. An integration test proves the trail against a real database. Eval scenarios cover a multi-round why question, a period comparison with its chart, a question asked through the tool, and keep the charts the existing table scenarios already showed. Take the effective reasoning level from the route rather than resolving it in the turn; the turn only caps it when the operator pays.
38 lines
1.2 KiB
TypeScript
38 lines
1.2 KiB
TypeScript
/**
|
|
* v1.41 — the reasoning a Coach turn asks its provider for.
|
|
*
|
|
* The effective level (the person's choice after the operator's switch and
|
|
* highest level) is resolved once, outside the turn, and handed in on the
|
|
* turn's input (`TurnInput.reasoningLevel`). The turn adds the one cap that
|
|
* depends on the chain it runs on: a turn the operator pays for thinks at
|
|
* most at `medium`, whatever the person chose.
|
|
*
|
|
* Pure: no database, no provider.
|
|
*/
|
|
import {
|
|
capReasoningLevel,
|
|
type ReasoningLevel,
|
|
type ReasoningMaxEffort,
|
|
} from "@/lib/ai/reasoning/levels";
|
|
import type { BudgetCostOwner } from "@/lib/ai/coach/budget";
|
|
|
|
/** A turn the operator pays for thinks at most this hard. */
|
|
export const OPERATOR_REASONING_CAP: ReasoningMaxEffort = "medium";
|
|
|
|
export interface TurnReasoning {
|
|
effort: ReasoningLevel;
|
|
summaries: boolean;
|
|
}
|
|
|
|
/** The turn's reasoning from the effective level and who pays. */
|
|
export function reasoningForTurn(
|
|
level: ReasoningLevel,
|
|
payer: BudgetCostOwner,
|
|
): TurnReasoning {
|
|
const effort =
|
|
payer === "operator"
|
|
? capReasoningLevel(level, OPERATOR_REASONING_CAP)
|
|
: level;
|
|
return { effort, summaries: effort !== "off" };
|
|
}
|