/** * agents/orchestrator-runner-context-window.ts * * How a single agent turn is kept inside the active model's context window, * and how the model backing that window is identified in the first place. * * Split out of orchestrator-runner.ts, which had reached its grandfathered * ceiling. The runner keeps the turn loop; this module owns the two questions * the loop asks once per turn and nothing else: * * - WHICH model definition is actually in play. A route can name its model * provider-qualified (`provider:key`) or bare, and the requested id and the * resolved id can differ after a fallback, so the registry is searched by * exact provider+registryKey first and only then by bare model id, a bare * match on the wrong provider would report someone else's context window. * - WHETHER this turn still fits, and what to drop when it does not. The * estimate covers messages, system prompt and tool schemas together, because * a turn is refused for their SUM; compaction takes the conversation first * and only trims the system prompt when the messages alone did not free * enough room. * * The compaction threshold is read from config per call rather than captured, * so `agents.contextCompactThreshold` is a live setting rather than a * restart-only one. */ import type { ProviderRegistry } from '../providers/registry.js'; import type { ModelDefinition } from '../providers/registry-types.js'; import { ConversationManager } from '../core/conversation.js'; import type { AgentRecord } from '../tools/agent/index.js'; import type { LLMProvider } from '../providers/interface.js'; import type { AgentOrchestratorRunContext } from './orchestrator-runner.js'; /** * Fraction of the context window at which compaction is triggered, from config * (agents.contextCompactThreshold) when a config source is present, else the * module default (identical value, so behaviour is unchanged by default). */ export declare function resolveContextCompactThreshold(context: AgentOrchestratorRunContext): number; export type ActiveProviderRoute = { readonly provider: Pick; readonly modelId: string; readonly requestedModelId: string; }; export declare function providerQualifiedRouteLabel(activeRoute: ActiveProviderRoute): string; export declare function resolveContextWindowModelDefinition(providerRegistry: Pick, activeRoute: ActiveProviderRoute): ModelDefinition; export declare function applyContextWindowAwareness(context: AgentOrchestratorRunContext, record: AgentRecord, modelId: string, modelWindow: number, conversation: ConversationManager, systemPrompt: string, toolTokens: number, turn: number): string; //# sourceMappingURL=orchestrator-runner-context-window.d.ts.map