/** * Plan-step compaction policy (port of NVlabs/SoL-Pi commit 4101906, as * re-implemented in bench/baseline/32-plan-step-compaction.mjs arm B). * * Checked at turn end after a plan step is newly completed. Compacting turns a * big cached prefix into a small summary: every later request re-reads less * (saving), but the new prefix must be re-written to cache once at r× the read * price. Compact iff that write cost is repaid within the expected number of * remaining requests (horizon). Pure — the session owns the bookkeeping. */ /** SoL-Pi default cache write/read price ratio. GPT-6.1 Sol's real ratio is 25. */ export declare const DEFAULT_CACHE_WRITE_READ_RATIO = 12.5; /** Recent tail kept verbatim by compaction (SoL-Pi keep budget). */ export declare const PLAN_STEP_KEEP_TOKENS = 20000; /** Approximate size of the summary that replaces the archive. */ export declare const PLAN_STEP_SUMMARY_TOKENS = 1000; /** Within this many tokens of the window, leave it to the size trigger. */ export declare const PLAN_STEP_WINDOW_GUARD = 16384; export interface PlanStepCompactionInput { /** Current context size in tokens. */ contextTokens: number; /** Tokens of the recent tail compaction keeps verbatim. */ keptTailTokens: number; contextWindow: number; /** Cache write price / cache read price. */ cacheWriteReadRatio: number; stepsCompleted: number; stepsRemaining: number; /** Requests spent inside completed steps (for mean requests-per-step). */ requestsInCompletedSteps: number; /** All requests so far (for mean context growth per request). */ requests: number; /** Context tokens grown across `requests`. */ grownTokens: number; /** Successful compactions so far this session. */ priorCompactions: number; /** Unpaid cache-write cost (cache-read token units) from earlier compactions. */ writeCostBalance: number; /** Requests since the last compaction (undefined when none yet). */ requestsSinceLastCompaction?: number; } export interface PlanStepCompactionDecision { compact: boolean; reason: string; } export declare function decidePlanStepCompaction(input: PlanStepCompactionInput): PlanStepCompactionDecision;