Codumentor logo Codumentor Enterprise

Compaction Plugin

Formerly context_summarization: configs naming codumentor.plugins.context_summarization / ContextSummarizationPlugin still load it, with a deprecation warning. The context_summarization model role (models.roles, subagent_profiles) keeps its name.

When a conversation is about to exceed the model's context window, this plugin
shrinks the prompt so the turn can still run, in two stages:

  1. Clear. Old tool results are replaced by [tool result removed] (plus any sticky tail), oldest first and short-retention_rounds results first, until the prompt is under the compaction target. The tool calls and every message stay; the results inside the last keep_recent_tool_tokens are kept. The cleared ids are stored, so every later prompt rebuild (next turn, resume, restart, subagent) reproduces the same bytes and the prompt cache keeps its prefix. Nothing is cleared below the trigger: tool results no longer age out per turn.
  2. Summarize. Only if clearing was not enough: keep system prompts and the most recent messages, and — by default — ask a model to summarize the middle instead of dropping it silently. If summarization is off or fails, it falls back to truncation.

With forget_tool_result enabled (it advertises owns_tool_result_eviction),
the clearing stage stands aside and compaction goes straight to summarizing.

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.compaction
    class: CompactionPlugin
    args:
      enabled: true
      max_context_tokens: 128000
      safety_margin: 1000
      min_recent_messages: 5
      split_ratio: 0.7
      enable_summarization: true
      clear_tool_results: true
      keep_recent_tool_tokens: 20000

Parameters

args:
  model_context_limits:
    "Qwen3-235B-A22B-Instruct-2507": 262144

Aggressive truncation for small models

plugins:
  - module: codumentor.plugins.compaction
    class: CompactionPlugin
    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 line across the transcript reports
how many messages were condensed, how many were kept, and roughly how many
tokens were saved; opening it shows the summary. A compaction that cleared
tool results says so ("Cleared 140 tool results, 380K → 120K tokens; no
summary needed" when clearing alone was enough) and draws the same line. A pending line appears while
summarization is running. Lines stay visible in focus mode.

Each user can hide those cards in Settings → Extensions →
Compaction (Show Summarization Cards, on by default; a choice saved under
the old name still applies). This is a web-UI
setting; the TUI does not read it yet
(doc/core-dev/improvements/plugin-settings.md).

/compact

Type /compact at the start of the composer (or pick it from the / list)
to create or refresh the compacted context without sending a model turn.
The transcript stays the source of truth; compaction is derived state used by
later prompt assembly.

The command reuses this plugin's summarization, cache, token estimates, and
event card. If the conversation is too short, or summarization is disabled,
it returns a notice and does nothing. Disabled plugins do not advertise the
command.

Notes