@sema-agent/core
Version:
Stateless, task-oriented AI agent core
38 lines (37 loc) • 2.38 kB
TypeScript
/**
* The derived-leg route pre-flight shared by the run's derived seats: the auto-mode classifier model, the advisor model and
* the prompt-suggestion model (a compaction summary has no seat of its own: it runs on the main model). One guarded seat, reached DOWN for by each phase instead of spelled
* again; the judgment's reading and the announcements live in the brain's route adjudicator.
*/
import type { Model } from "../../internal/llm.js";
import { type RouteJudgmentCause } from "../../brain/route-adjudicator.js";
import type { RunnerDeps, TaskSpec } from "../types.js";
/** What the pre-flight decided: keep the seat's model (same route as the primary, the route goes ahead, or the deployment declined
* a fallback — the seat is kept and its calls refused), swap it for the primary, or take the seat off this run. A move carries
* the refusal's code when the judgment stated one (`route.judgment_failed` for a judgment that threw or answered no verdict). */
export type DerivedSeatOutcome = {
readonly action: "keep";
} | {
readonly action: "fall_back" | "detach";
readonly cause?: RouteJudgmentCause;
};
/**
* Judge the derived model where its route differs from the primary's and dispose of a refusal as THIS seat does
* (`onBrokenPairing`) — a judgment that throws or answers no verdict is a refusal like any other (the model lane would refuse every
* call on it). A throw of the seat's own (a garbage catalog value in the route identity) keeps the seat: preparation never fails here.
*/
export declare function derivedRouteFallsBack(args: {
seat: string;
derived: Model;
primary: Model;
brain: RunnerDeps["brain"];
getApiKeyAndHeaders: TaskSpec["getApiKeyAndHeaders"];
onNotice: RunnerDeps["onNotice"];
/** The session / INVOCATION this resolution belongs to: correlation keys on the notice (the audience stays operator). */
sessionId?: string;
runId?: string;
/** Absent / `"fall_back"`: swap and announce `route.fallback_to_primary`. `"refuse"`: keep the seat and announce
* `route.classifier_unroutable` (the deployment declined a fallback — never granted quietly). `"detach"`: take the seat
* off the run and announce `route.seat_detached` (a seat the primary model cannot stand in for). */
onBrokenPairing?: "fall_back" | "refuse" | "detach";
}): Promise<DerivedSeatOutcome>;