Skip to content
Français

summarizeHistory

import { summarizeHistory } from "@elie-laloum/outpost";

Create a context strategy that, once the serialized history exceeds triggerCharacters, replaces the older messages with a model-written summary and keeps the first prompt and the recent messages. Each summary is one extra model request counted in usage and budgets; an empty or cut-off summary fails the turn with code response.

Complete example and detailed rules.

  • optionsOptional
    SummarizeHistoryOptions | undefined
    History size that triggers a summary and number of recent messages kept.
  • options.triggerCharactersOptional
    number | undefined
    Length of the JSON-serialized history above which a summary is made, default 400000 characters.
  • options.keepRecentMessagesOptional
    number | undefined
    Minimum number of recent messages kept after the summary, default 6; the cut moves back to the previous assistant message.

HarnessContextStrategy

export declare function summarizeHistory(
  options?: SummarizeHistoryOptions,
): HarnessContextStrategy;