defineHarnessContextStrategy
Purpose and behavior
Section titled “Purpose and behavior”Define how a built-in harness rewrites its history before each model request. compact receives the messages and a summarize() helper and returns a new list or nothing; the harness validates the list, removes replayed reasoning and records a compaction in the transcript.
Complete example and detailed rules.
Parameters and properties
Section titled “Parameters and properties”optionsRequiredHarnessContextStrategyOptionsStrategy name and compact function.options.nameRequiredstringNonempty name reported in compaction events.options.compactRequired(input: HarnessContextInput) => HarnessContextResult | Promise<HarnessContextResult>Called before every model request; returns a rewritten message list, or nothing to keep the history. The list must start and end with a user message and pair each tool call with its result, or the turn fails with code configuration.