/** * Loop escalation — FR-014, FR-008 rule #3 / #4. * * Detects bounded repeated identical tool failures and signals * session pin escalation to a frontier-capable tier. * * Escalation fires once per session; no tier oscillation (FR-008). * Threshold defaults to 3 identical tool failures (operator configurable). * * Zero-tier observational pin-break (SP-178 / #99): * SAAR pins preserve prefix-cache value, but a zero-tier pin that faces * unsupported/unknown tools or sustained tool-loop churn is a capability * mismatch — the same class of observational signal as identical tool * failures (FR-014). Escalation reuses the `loop_escalation` pin reason * (allowed FR-008 break) rather than inventing a cache-economics bypass. * Voluntary cross-provider switches still go through breakeven; this path * only fires on observational evidence that the pinned zero-tier model * cannot complete the tool loop. * * Design: pure evaluation function — caller (pipeline stage) is * responsible for applying pin state updates via SessionPinner. */ import type { ModelProfile, RoutingRequest, SessionPin } from '../types/index.js'; export interface LoopEscalationConfig { readonly threshold: number; /** * Tool-result turns while pinned to zero-tier before observational escalate. * Defaults to `threshold` when omitted (same operator knob, no schema change). */ readonly zero_tier_tool_call_threshold?: number; } export interface LoopEscalationResult { readonly shouldEscalate: boolean; readonly updatedPin: SessionPin | null; readonly escalationTarget: ModelProfile | null; readonly reason: string; } /** Stable signature for zero-tier tool-call churn counting (SP-178). */ export declare const ZERO_TIER_TOOL_CHURN_SIGNATURE: "zt:tool_churn"; /** * Extract a tool-failure signature from the request's messages. * Returns null when the request does not carry a tool failure. * * Only inspects tool_result turns — other turn types cannot * carry observational failure signals (FR-014: no post-generation judging). */ export declare function extractToolFailureSignature(request: RoutingRequest): string | null; /** * True when the latest tool result reports an unsupported/unknown tool * (capability mismatch — escalate immediately on zero-tier pins). */ export declare function isUnsupportedOrUnknownToolResult(request: RoutingRequest): boolean; /** * Evaluate whether the session should escalate to a higher tier. * * Pure function — does not mutate pin state. Returns `updatedPin` * when the caller should persist new failure-tracking state. * * Caller applies updates via `SessionPinner.loadPin()`, and on * escalation via `breakPin()` + `recordPin()`. */ export declare function evaluateLoopEscalation(pin: SessionPin | null, request: RoutingRequest, fleet: readonly ModelProfile[], config: LoopEscalationConfig): LoopEscalationResult; //# sourceMappingURL=loop-escalation.d.ts.map