/** * Reliability experiments from the architecture audit (E1–E6). * * Defaults are capability-preserving: they reduce unnecessary context / fragile * free-tier overload without hard-truncating critical evidence or blocking free * users. Every knob is config-backed and can be disabled independently. */ import type { ProviderId } from "../types.js"; /** Hard auto-compact ceiling — never raise soft past this. */ export declare const HARD_COMPACT_TOKEN_BUDGET = 180000; /** * Auto-compaction trigger default, in total estimated request tokens. Owned by * request-budget.ts so behaviour, UI and policy cannot diverge. */ export declare const DEFAULT_SOFT_COMPACT_TOKEN_BUDGET = 180000; /** E2 default fs passthrough (was 400k). Full body always on disk when truncated. */ export declare const DEFAULT_FS_PASSTHROUGH_CAP_CHARS = 64000; /** E4: warn when free-cloud context is this large. */ export declare const DEFAULT_FREE_TIER_WARN_TOKENS = 40000; /** E4: stronger notice after this many consecutive free-tier stream failures. */ export declare const DEFAULT_FREE_TIER_FAIL_THRESHOLD = 2; /** E3 floors — large enough for fs.write / salvage, lower than prior 32k default. */ export declare const ADAPTIVE_MAX_TOKENS_TOOL_STEP = 24576; export declare const ADAPTIVE_MAX_TOKENS_LIGHT = 12288; export declare const ADAPTIVE_MAX_TOKENS_FLOOR = 8192; export declare const LEGACY_MAX_TOKENS = 32768; export interface ReliabilityPolicy { readonly softEarlyCompact: boolean; readonly softCompactTokenBudget: number; readonly hardCompactTokenBudget: number; readonly fsPassthroughCapChars: number; readonly adaptiveMaxTokens: boolean; readonly freeTierContextGuard: boolean; readonly freeTierWarnTokens: number; readonly freeTierFailThreshold: number; readonly toolResultDedup: boolean; readonly slimNativePrompt: boolean; } /** Resolve effective policy from config + optional env overrides. */ export declare function getReliabilityPolicy(): ReliabilityPolicy; /** * E1: token threshold that triggers auto-compact. * Soft path fires earlier; hard budget is the ceiling used when soft is off. * Defaults are provider/model-neutral; a session model-window override uses * 70% of its explicit limit. */ export declare function autoCompactTriggerTokens(policy?: ReliabilityPolicy, target?: { provider?: ProviderId | undefined; model?: string | undefined; contextLimitTokens?: number | undefined; }): number; /** * E3: max completion tokens for a model step. * Tool-heavy steps keep room for large writes; light steps use a lower cap. * Never goes below {@link ADAPTIVE_MAX_TOKENS_FLOOR}. */ export declare function resolveStepMaxTokens(input: { nativeToolsActive: boolean; toolsAttached: boolean; recoveryNudge?: boolean | undefined; truncationDepth?: number | undefined; thinkingEnabled?: boolean | undefined; policy?: ReliabilityPolicy | undefined; }): number; export declare function isFreeCloudProvider(provider: ProviderId): boolean; /** * E4: advisory notices for free-tier + large context / repeated failures. * Never blocks the request. */ export declare function freeTierGuardNotices(input: { provider: ProviderId; estimatedInputTokens: number; consecutiveFailures: number; policy?: ReliabilityPolicy | undefined; }): string[]; /** Stable hash for E5 tool-result dedup (content only). */ export declare function hashToolResultContent(content: string): string; /** * E5: if identical tool output already appeared this turn, replace with a * pointer so history does not grow with duplicate dumps. Full text remains * available via artifact path when present. */ export declare function dedupeToolContextOutput(input: { content: string; toolName: string; artifactPath?: string | undefined; seenHashes: Map; policy?: ReliabilityPolicy | undefined; }): { content: string; deduped: boolean; hash: string; };