summarizationPayloadBudget function

int summarizationPayloadBudget(
  1. int summarizerWindow,
  2. CompactionSettings settings
)

The outbound-payload budget (in estimated tokens) for a summarizer whose model window is summarizerWindow: the window minus the settings' reserve (which prices the summary prompt and its output), floored at half the window so a summarizer window smaller than the reserve (a tiny smol role under a big main window's settings) still leaves room to summarize into. Every compaction request's estimated payload must stay at or under this — the invariant asserted in tests on the recorded outbound prompts.

Implementation

int summarizationPayloadBudget(
  int summarizerWindow,
  CompactionSettings settings,
) => max(summarizerWindow - settings.reserveTokens, summarizerWindow ~/ 2);