Context Summarization Plugin
When a conversation is about to exceed the model's context window, this plugin
shrinks the prompt so the turn can still run. It keeps system prompts and the
most recent messages, and — by default — asks a model to summarize the middle
instead of dropping it silently. If summarization is off or fails, it falls
back to truncation.
It also retries after a context-window error from the model, using the same
shrink-and-retry path so a long conversation is more likely to continue than
to fail outright.
Configuration
plugins:
- module: codumentor.plugins.context_summarization
class: ContextSummarizationPlugin
args:
enabled: true
max_context_tokens: 128000
safety_margin: 1000
min_recent_messages: 5
split_ratio: 0.7
enable_summarization: true
Parameters
- enabled (optional): Whether the plugin is active (default:
true) - max_context_tokens (optional): Context limit used when the model has no entry in
model_context_limits(default:128000) - safety_margin (optional): Tokens reserved for the model's reply (default:
1000) - min_recent_messages (optional): Minimum number of recent conversation messages to keep uncompressed (default:
5) - split_ratio (optional): Fraction of the older conversation eligible for summarization / removal, from
0.0to1.0(default:0.7) - enable_summarization (optional): Summarize the dropped middle with an LLM instead of only deleting it (default:
true) - summarization_prompt_template (optional): Prompt template used for that summary (default:
"context_summarization.jinja2") - min_messages_for_summary (optional): Do not bother summarizing unless at least this many messages would be condensed (default:
3) - model_context_limits (optional): Per-model context limits. Omitted by default (empty). Example:
args:
model_context_limits:
"Qwen3-235B-A22B-Instruct-2507": 262144
Aggressive truncation for small models
plugins:
- module: codumentor.plugins.context_summarization
class: ContextSummarizationPlugin
args:
enabled: true
max_context_tokens: 16385
safety_margin: 500
min_recent_messages: 3
split_ratio: 0.8
What you see
When a turn is summarized or truncated, a transcript card reports how many
messages were condensed, how many were kept, and roughly how many tokens were
saved. A pending card appears while summarization is running.
Each user can hide those cards in Settings (Show Summarization Cards,
on by default).
Notes
- System messages are always kept. Recent messages are kept up to
min_recent_messages; older content is summarized (or removed). - Summaries from earlier turns are reused when the older history has not changed, so you are not charged a fresh summarization call every turn.
- For a proactive, every-turn compression scheme with topic-shift detection, see Context Management.