/** * Runtime config planning and retry/fallback selection. * * Ported from PSYCHE src/llm/runtime.py (236 LOC). * * Owns: * - Resolution of ModelConfig (no ConfiguredModelSettings in CLEO — direct ModelConfig) * - Per-attempt planning (AttemptPlan) including primary/fallback selection * - Per-call effective config construction * - Retry attempt tracking via simple mutable ref (simpler than AsyncLocalStorage) * * Langfuse: no-op (telemetry not wired in CLEO). * * @task T1398 (T1386-W12) * @epic T1386 */ import type { ReasoningEffortType } from './types.js'; import type { ModelConfig, ModelTransport } from './types-config.js'; /** * Per-attempt plan produced by planAttempt. * * NOTE (T9370 — D-ph4-01 final close): the `client` field was removed. * It previously held the raw SDK client from `clientForModelConfig`, but no * caller in `api.ts` or `tool-loop.ts` ever accessed `plan.client` — those * callers build their own transport sessions via `_sessionFromConfig`. The * field carried dead weight and forced a dependency on the retired factory. */ export interface AttemptPlan { readonly provider: ModelTransport; readonly model: string; readonly thinkingBudgetTokens: number | null | undefined; readonly reasoningEffort: ReasoningEffortType; readonly selectedConfig: ModelConfig; } /** * Simple mutable attempt counter — simpler than AsyncLocalStorage. * Tenacity wraps the call closure which captures this ref. */ export interface AttemptRef { value: number; } /** Create a new attempt ref starting at 1. */ export declare function makeAttemptRef(): AttemptRef; /** * Pick the effective config for this attempt. * Primary config on all attempts except the last, which swaps to fallback (if any). */ export declare function selectModelConfigForAttempt(modelConfig: ModelConfig, attempt: number, retryAttempts: number): ModelConfig; /** * Build the AttemptPlan for the current attempt. * * NOTE (T9370): no longer calls `clientForModelConfig` — the `client` field * was removed from `AttemptPlan` because no caller ever used it. Transport * construction is the responsibility of the session layer (`_sessionFromConfig` * in `api.ts` / `tool-loop.ts`). */ export declare function planAttempt(params: { runtimeModelConfig: ModelConfig; attempt: number; retryAttempts: number; callThinkingBudgetTokens: number | null | undefined; callReasoningEffort: ReasoningEffortType; }): AttemptPlan; /** * Build the effective ModelConfig passed to the executor / request_builder. * * Per-call kwargs (temperature, stop_seqs, thinking_*) win when set. * maxOutputTokens is forced to null so the per-call maxTokens kwarg is authoritative. */ export declare function effectiveConfigForCall(params: { selectedConfig: ModelConfig | null; provider: ModelTransport; model: string; temperature: number | null | undefined; stopSeqs: string[] | null | undefined; thinkingBudgetTokens: number | null | undefined; reasoningEffort: ReasoningEffortType; }): ModelConfig; /** * Bump temperature from 0.0 → 0.2 on retry attempts for variety. */ export declare function effectiveTemperature(temperature: number | null | undefined, currentAttempt: number): number | null | undefined; //# sourceMappingURL=runtime.d.ts.map