Skip to main content

Crate agentkit_compaction

Crate agentkit_compaction 

Source
Expand description

Transcript compaction primitives for reducing context size while preserving useful state.

This crate provides the building blocks for compacting an agent transcript when it grows too large. The main concepts are:

  • Triggers (CompactionTrigger) decide when compaction should run (e.g. after a certain item count is exceeded).
  • Strategies (CompactionStrategy) decide how the transcript is transformed: dropping reasoning, removing failed tool results, keeping only recent items, or summarising older items via a backend.
  • Pipelines (CompactionPipeline) chain multiple strategies into a single pass.
  • Backends (CompactionBackend) provide provider-backed summarisation for strategies that need it (e.g. SummarizeOlderStrategy).

Combine these pieces through CompactionConfig and hand the config to agentkit-loop (or your own runtime) to keep transcripts under control.

Structs§

CompactionConfig
Top-level configuration that bundles a trigger, strategy, and optional backend into a single value you can hand to agentkit-loop.
CompactionContext
Runtime context passed to each CompactionStrategy during execution.
CompactionPipeline
An ordered sequence of CompactionStrategy steps executed one after another.
CompactionRequest
Input to a CompactionStrategy.
CompactionResult
Output of a CompactionStrategy.
DropFailedToolResultsStrategy
Strategy that removes Part::ToolResult parts where is_error is true.
DropReasoningStrategy
Strategy that removes Part::Reasoning parts from every item.
ItemCountTrigger
A CompactionTrigger that fires when the transcript exceeds a fixed number of items.
KeepRecentStrategy
Strategy that keeps only the N most recent removable items and drops the rest.
SummarizeOlderStrategy
Strategy that replaces older transcript items with a backend-generated summary.
SummaryRequest
Request sent to a CompactionBackend asking it to summarise a set of transcript items.
SummaryResult
Response from a CompactionBackend containing the summarised items.

Enums§

CompactionError
Errors that can occur during compaction.
CompactionReason
The reason a compaction was triggered.

Traits§

CompactionBackend
Provider-backed summarisation service.
CompactionStrategy
A single compaction step that transforms a transcript.
CompactionTrigger
Decides whether compaction should run for a given transcript.