Skip to content
Français

truncateToolResults

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

Create a context strategy that cuts older tool results to maxCharacters, appending a truncation marker, and leaves the keepRecent most recent tool-result messages intact. It returns nothing while no older result exceeds the limit.

Complete example and detailed rules.

  • optionsOptional
    TruncateToolResultsOptions | undefined
    Number of recent tool results kept intact and the length older results are cut to.
  • options.keepRecentOptional
    number | undefined
    Number of most recent tool-result messages kept intact, default 4.
  • options.maxCharactersOptional
    number | undefined
    Length older tool results are cut to, default 2000 characters.

HarnessContextStrategy

export declare function truncateToolResults(
  options?: TruncateToolResultsOptions,
): HarnessContextStrategy;