Skip to main content

Interface: StepCompaction

Defined in: packages/core/src/runtime/durable-loop.ts:57

Keep a long run's conversation inside a budget (see ProcessOptions.compaction). Checked at every step boundary, and when a run resumes.

Properties​

keepSteps?​

optional keepSteps?: number

Defined in: packages/core/src/runtime/durable-loop.ts:65

The newest completed steps always kept word for word. Default 2.


maxTokens​

maxTokens: number

Defined in: packages/core/src/runtime/durable-loop.ts:63

Compact once the conversation is larger than this many tokens: the last step's reported prompt plus its output, or an estimate (four characters a token) when the provider reports no usage.


summarize?​

optional summarize?: (input) => Promise<string>

Defined in: packages/core/src/runtime/durable-loop.ts:72

Fold the older steps into a summary (a cheap bot's process, say). The summary replaces them in the conversation as one user message. Without it, the older steps stay but every tool result in them is cleared to a short note — free, and the model can call the tool again.

Parameters​

input​

CompactionInput

Returns​

Promise<string>