/** * Context-fit gate — SP-093, overflow fallback — SP-095. * * Filters fleet models whose context window cannot accommodate the estimated * input token count (with a configurable safety margin). */ import type { CandidateScore, ModelProfile, RoutingRequest } from '../types/index.js'; export declare const CONTEXT_FIT_EXCEEDED: "context_fit_exceeded"; export declare const CONTEXT_OVERFLOW_SAME_PROVIDER_FALLBACK: "context_overflow_same_provider_fallback"; export declare const CONTEXT_OVERFLOW_FRONTIER_FALLBACK: "context_overflow_frontier_fallback"; export declare const CONTEXT_OVERFLOW_NO_FIT: "context_overflow_no_fit"; export declare const DEFAULT_CONTEXT_FIT_SAFETY_MARGIN = 0.9; export declare const CONTEXT_FIT_SAFETY_MARGIN_ENV = "CONTEXT_FIT_SAFETY_MARGIN"; export interface ContextFitConfig { /** Fraction of max_input_tokens treated as usable (default 0.90). */ readonly safetyMargin?: number; } export interface ContextFitFilterResult { readonly effectiveFleet: readonly ModelProfile[]; readonly rejected: readonly CandidateScore[]; } export interface ContextOverflowFallbackResult { readonly kind: 'selected' | 'no_fit'; readonly model?: ModelProfile; readonly reasonCode: typeof CONTEXT_OVERFLOW_SAME_PROVIDER_FALLBACK | typeof CONTEXT_OVERFLOW_FRONTIER_FALLBACK | typeof CONTEXT_OVERFLOW_NO_FIT; } export declare function resolveSafetyMargin(config?: ContextFitConfig): number; export declare function modelFitsContext(profile: ModelProfile, estimatedInputTokens: number, safetyMargin: number): boolean; /** * Select the model with the largest declared context window. * Models without declared limits sort last (treated as unknown / unbounded). */ export declare function selectLargestWindowModel(candidates: readonly ModelProfile[]): ModelProfile | undefined; /** * SP-095: escalate when economical/pinned models cannot fit context. * * 1. Same-provider largest-fit model * 2. Cheapest frontier model that fits * 3. Structured no-fit (never dispatch undersized) */ export declare function resolveContextOverflowFallback(fleet: readonly ModelProfile[], request: RoutingRequest, preferredProvider: string | null, config?: ContextFitConfig): ContextOverflowFallbackResult; /** * True when economical models were rejected for context fit and none remain * in the post-filter fleet. */ export declare function needsContextOverflowFallback(activeFleet: readonly ModelProfile[], rejected: readonly CandidateScore[], fullFleet: readonly ModelProfile[]): boolean; /** * Remove fleet entries whose max_input_tokens cannot fit estimated_input_tokens * at the given safety margin. Honors `force_model_id` by leaving fleet unchanged. * Models without declared limits are retained (unknown window). */ export declare function filterFleetByContextFit(fleet: readonly ModelProfile[], request: RoutingRequest, config?: ContextFitConfig): ContextFitFilterResult; //# sourceMappingURL=context-fit.d.ts.map