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§
- Compaction
Config - Top-level configuration that bundles a trigger, strategy, and optional
backend into a single value you can hand to
agentkit-loop. - Compaction
Context - Runtime context passed to each
CompactionStrategyduring execution. - Compaction
Pipeline - An ordered sequence of
CompactionStrategysteps executed one after another. - Compaction
Request - Input to a
CompactionStrategy. - Compaction
Result - Output of a
CompactionStrategy. - Drop
Failed Tool Results Strategy - Strategy that removes
Part::ToolResultparts whereis_erroristrue. - Drop
Reasoning Strategy - Strategy that removes
Part::Reasoningparts from every item. - Item
Count Trigger - A
CompactionTriggerthat fires when the transcript exceeds a fixed number of items. - Keep
Recent Strategy - Strategy that keeps only the
Nmost recent removable items and drops the rest. - Summarize
Older Strategy - Strategy that replaces older transcript items with a backend-generated summary.
- Summary
Request - Request sent to a
CompactionBackendasking it to summarise a set of transcript items. - Summary
Result - Response from a
CompactionBackendcontaining the summarised items.
Enums§
- Compaction
Error - Errors that can occur during compaction.
- Compaction
Reason - The reason a compaction was triggered.
Traits§
- Compaction
Backend - Provider-backed summarisation service.
- Compaction
Strategy - A single compaction step that transforms a transcript.
- Compaction
Trigger - Decides whether compaction should run for a given transcript.