Zum Hauptinhalt springen
F

dsh-context-squeeze

fukewang/dsh-context-squeeze

Compresses aged conversation turns into structured summaries and lets the agent expand any summary back to the original log on demand.

Installation

dsh plugin --profile web add github:fukewang/dsh-context-squeeze

README

Context squeeze

Keeps long conversations inside a small context window: each aged turn is replaced by one structured summary, the newest turns stay verbatim, and the agent can expand any summary back to the original log on demand. The full transcript stays in the session log and in the UI.

Cost

In the author's own tests, the average session cost was about 40% lower. That figure comes from the author's own long sessions, not a controlled benchmark; the gain depends on conversation length and how much tool output the session produces.

How it works

After a turn ends and the agent is idle:

  1. The oldest surface span outside the retained window is selected (the newest 2 completed turns stay verbatim by default).
  2. The cut is aligned to tool-call / tool-result pairs so a tool call is never split.
  3. The plugin's own summarization prompt turns the span into a structured checkpoint (goals, decisions, facts, files, errors, next steps, expandable clues).
  4. The span is replaced through the Harness surface replacement primitive, with a compaction/summary record that carries the shadowed token count and the summarizer usage.

The expand_context tool

expand_context({ id?: "squeeze-…", query?: "keyword", maxChars?: 8000 })
  • Without id: list the squeezed spans of this session.
  • With id: return the original messages, truncated to maxChars.
  • With query: only messages mentioning the keyword.

Configuration

Configure the context-squeeze row in cordis.patch.yml:

FieldDefaultMeaning
enabledtrueMaster switch.
retainTurns2Newest completed turns kept verbatim.
maxRegionChars60000Input cap for one squeeze.
minRegionChars1200Skip smaller spans.
maxSummaryTokens1200Summary output cap.
messageChars4000Per-message cap while rendering the span.
expandChars8000Default expansion budget.
expandMaxChars24000Hard expansion cap.
timeoutMs180000Summarizer timeout.

Install

dsh plugin --profile web add dsh-context-squeeze

Host-only plugin; no browser UI. Requires DSH 0.2.2-rc.5 or later.

Limits

  • Fixed overhead (system prompt, tool schemas, runtime context) is not compressed.
  • The newest retainTurns turns and the current turn stay verbatim.
  • When a summary would be at least 90% of the original size, the original is kept.
  • Subagent sessions are skipped.
  • Coexists with the built-in /compact; both write standard compaction/* records.

License

MIT. See LICENSE.

Ähnliche Plugins