defaultCompactionSetup top-level constant
CompactionSetup
const defaultCompactionSetup
Implementation
const CompactionSetup defaultCompactionSetup = (
// Verbatim recent conversation. Paid on every turn, so it buys continuity
// rather than memory: older detail is the summary's job.
recentCharsToKeep: 20000,
// Kept large deliberately. Compaction rewrites the front of the history and
// so voids the prompt cache; a bigger threshold means that happens rarely.
// Request size costs money but not latency -- measured flat from 20k to
// 130k chars -- so there is little to gain by compacting sooner.
minCharsToCompact: 60000,
// A soft steer, not a contract: summarisers cluster at 3k-6k chars for a
// backlog this size whatever they are asked for, and measured fact retention
// was the same at 3k and 10k. Set to match what they actually produce, so
// the length check below stays meaningful instead of firing every time.
// Retention is driven by [_systemPrompt] naming what matters, not by this.
compactionTargetChars: 3000,
// Sized against the api's request ceiling, not against the thresholds above:
// a summary request is the transcript plus a small prompt, and json encoding
// this kind of text costs about 5%. Set high enough that [_dropOldest] is
// genuinely exceptional rather than a routine cost of a busy chat.
maxCharsToSummarize: 150000,
);