Skip to content
Français

defineHarnessContextStrategy

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

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.

  • optionsRequired
    HarnessContextStrategyOptions
    Strategy name and compact function.
  • options.nameRequired
    string
    Nonempty 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.

HarnessContextStrategy

export declare function defineHarnessContextStrategy(
  options: HarnessContextStrategyOptions,
): HarnessContextStrategy;