agentfootprint
Version:
The explainable agent framework — backtrack a wrong answer to the exact context that caused it (evidence, not guesses). Built on footprintjs.
49 lines (48 loc) • 2.25 kB
TypeScript
/**
* summarizeOldest — fold the oldest foldable turns into one summary message.
*
* Pattern: WindowStrategy implementation. Its own module, importing nothing
* that registers anything, so a bundle that never mentions it never
* carries it (and never carries the summarizer machinery either).
* Role: core/ layer.
* Emits: N/A — the stage emits, records and costs; this file decides.
*
* This is what `.compaction({...})` configures, and the market's familiar
* move (Claude Code / the Claude Agent SDK call it compaction). What is
* different here is not the fold — it is that the fold is filed as a claim:
* a summary is a claim ABOUT the past, and the past itself stays. In the
* commit log for as long as the process lives, and — since 8.2, under
* `retain: 'conversation'` — on the conversation checkpoint for as long as
* the conversation does, which is the half a standing agent actually needs.
*
* Everything it decides, it explains. Every engaged path returns a record —
* including the paths that change nothing, which are the ones a person
* debugging an over-budget window actually needs.
*/
import type { WindowStrategy } from '../strategy.js';
import type { CompactionOptions } from '../types.js';
/** `WindowRecord.strategy` written by every record this strategy files. */
export declare const SUMMARIZE_OLDEST = "summarize-oldest";
/**
* Fold the oldest contiguous run of foldable turns into one summary message,
* keeping the recent turns and stepping over anything unresolved.
*
* Triggered by COUNTED tokens: the last call's adapter-reported input tokens
* against `thresholdTokens`. A provider that reports no usage gets
* `CompactionUnmeasurableError` rather than an invented number.
*
* @example
* ```ts
* import { Agent, summarizeOldest } from 'agentfootprint';
*
* const agent = Agent.create({ provider: anthropic(), model: 'claude-sonnet-4-5' })
* .window(summarizeOldest({
* thresholdTokens: 120_000,
* summarizer: anthropic(),
* model: 'claude-haiku-4-5',
* }))
* .build();
* // `.compaction({ ... })` is this exact line, spelled shorter.
* ```
*/
export declare function summarizeOldest(options: CompactionOptions): WindowStrategy;