- Início
- Plugins
- Sessões e mensagens
- billion-compact
billion-compact
fanfan-2011/billion-compact
Compacts older conversation history into a model-written summary: automatic triggering at a configurable share of the context window (90% by default), a /compact command, a header button, a settings page that can point summarization at another provider/model, and deletion of individual turns. Its HTTP routes have no DSH access check, so a web page open in your browser could call them.
Instalar
dsh plugin --profile web add github:fanfan-2011/billion-compactREADME
billion-compact
Fast, configurable context compaction for DeepSeek Harness (DSH).
billion-compact keeps long sessions inside the model's context window while using
far fewer tokens. It replaces older history with a compact model-written summary, and
gives you three ways to trigger that:
- Automatic — when the context reaches 90% of the active model's detected context window (configurable 50–95%).
- Command — type
/compactin the composer. - One click — the compact icon at the top-right of the conversation header.
- Oversized-request rescue — if a request body is already larger than the model window (for example the first message of a long imported chat), the failed send is compacted and retried automatically instead of surfacing an error.
- Delete a turn — a small trash button sits in the message action row (next to the
copy icon and the time) and removes that turn (its user, assistant and tool messages)
from the context, so dead turns stop costing tokens. Turns that failed before any
assistant message (the
处理失败rows) have no action row, so their trash button is rendered below the error row instead.
Every compaction pops a toast in the bottom-right corner with how much history was replaced and how many tokens were saved. The toast stays for 10 seconds, pauses while you hover it, and can be closed with its own × button.
Install
Requires DeepSeek Harness >= 0.2.0-rc.1 (Node ^22.19.0 || >=24).
Install this folder as a local plugin/bundle, either from the DSH UI:
Settings → Plugins → Install plugin / bundle → choose the folder that contains package.json
or by pointing the plugin manager at a clone of this repository:
git clone git@github.com:fanfan-2011/billion-compact.git
Then enable billion-compact in Settings → Plugins and restart the profile once so
the plugin's compaction rows replace the preset ones. The npm package is not published
yet.
Settings
Settings → 上下文压缩 / Compaction (also available on the plugin's detail page):
| Setting | Default | Meaning |
|---|---|---|
| 自动压缩 / Auto compaction | on | Compact before a request when pressure exceeds the threshold. |
| 触发阈值 / Trigger threshold | 90% | Share of the model's context window that triggers auto-compaction. |
| 压缩模型 / Summary model | main model | Provider/model used to write the summary. Leave empty to follow the current main model. |
The compaction engine itself is the shipped @deepseek-ai/dsh-compaction-basic
(MIT), vendored and configured so that the pressure threshold tracks the model
context window instead of a fixed headroom.
Commands and endpoints
/compact— manual compaction, no arguments.GET /billion-compact/state?sessionId=…— effective config and live pressure.GET /billion-compact/models— provider/model catalog for the settings UI.POST /billion-compact/config— persist settings.POST /billion-compact/compact— one-click/manual compaction.GET /billion-compact/deleted-turns?sessionId=…— turn numbers hidden in this session.POST /billion-compact/turn/delete—{ sessionId, turn }: delete one turn.GET /billion-compact/events— SSE stream of compaction results, auto errors and deleted turns.
Notes
- Summaries are written with
ctx.llm.stream, so they can use any configured provider, including a cheaper model than the conversation model. - The plugin owns the
compactionservice. It is compatible with the shipped/compactcommand shape, so its results appear as normal compaction rows in chat. - So that the configured threshold (default 90%) is the only trigger, the plugin
disables the compaction rows that the stock agent presets compose themselves
(
@deepseek-ai/dsh-compaction-basic,@deepseek-ai/dsh-command-compact) while it is active. The same gate is used by other bundle plugins in this ecosystem; withbillion-contextinstalled, its gate already covers the presets. - Compaction is refused while the session has an open turn or another compaction is running; the UI reports “busy” instead of corrupting the transcript.
- Oversized-request rescue. Some gateways (including the local egress fuse used by
billion-context) reject an outbound body that is bigger than the effective model window withINVALID_REQUESTinstead of the core context-overflow code. The plugin listens for that failure, compacts the session once, and retries the same step. It also caps the summarization call itself: when the region being compacted is too large for one request, the transcript is sanitized (text only, per-message head/tail clipping) and summarized in bounded chunks, then the partial checkpoints are merged. This keeps the rescue working even when the imported history alone is larger than the window. The rescue is retried at most twice per turn and follows the “Auto compaction” switch. - billion-context coexistence.
billion-contextrefuses every DSH-side compaction request on a session it guards (“bili owns compression on this lane”). It detects two shapes: the stock summarization instruction in the last user message, and thepurpose: "compaction"declaration that DSH attaches to summarization calls. This plugin therefore summarizes with its own bounded-chunk instruction and does not declare that purpose, so native checkpoints land normally;billion-contextthen rebases its own state on the next request instead of refusing. If a refusal still reaches the UI, the plugin shows a short hint with the two ways out (disable billion-context's DSH-compaction guard, or stop billion-context). - Deleting a turn. The trash button replaces that turn's whole surface span with an
empty system message, so its messages leave the model context durably (tokens stop
counting, and the stale-turn rows disappear). A
处理失败row is derived fromturn/end, not from the surface, so the client hides every row of a deleted turn by turn number; the list of deleted turns per session is kept in<profile>/billion-compact/deleted-turns.jsonand pushed to all open windows over SSE. Deletion is refused while the session is running.
License
MIT. The vendored engine is MIT, copyright the DeepSeek Harness authors.
Plugins relacionados
billion-context
ranxianglei/billion-context
dsh-web-ui (dsh-chat-recovery)
zhu1090093659/dsh-web-ui
dsh-synapse
liangmianya/dsh-synapse
EduWork (dsh-side-chat)
ecnu/eduwork