truncateToolResults
Purpose and behavior
Section titled “Purpose and behavior”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.
Parameters and properties
Section titled “Parameters and properties”optionsOptionalTruncateToolResultsOptions | undefinedNumber of recent tool results kept intact and the length older results are cut to.options.keepRecentOptionalnumber | undefinedNumber of most recent tool-result messages kept intact, default 4.options.maxCharactersOptionalnumber | undefinedLength older tool results are cut to, default 2000 characters.
Instructions added by Outpost
Section titled “Instructions added by Outpost”Templates below preserve the English text sent to the model. ${…} marks runtime substitutions, not brief template syntax.
When an older tool result exceeds maxCharacters, its content is replaced with:
retainedContent is the first maxCharacters JavaScript string code units; originalLength is the original string’s length. This is a marker in the tool result, not a separate model request. Its wording is fixed. Change maxCharacters or keepRecent to control truncation, or supply a custom context strategy to use another transformation.
Implementation: context.ts.

