description: "The on-demand /compact command for interactive compositions: what it does, what you see, and how to mount it."
English | 中文
dsh-command-compact adds a /compact command to chat UIs: type it and the conversation condenses on demand — the older history is replaced by one summary even before automatic pressure triggers. The command works with any condensation backend and does not consume a model turn; after it finishes you see how many history items were condensed and the estimated tokens saved. While the agent is mid-turn or condensation is already running, it tells you condensation is unavailable. Prompts you send while it runs stay queued and start after it finishes.
Type /compact in a chat UI when the conversation has grown long and you want to condense it immediately. The shipped dsh base mounts the command next to the default backend, so it is usually already available.
| Input | Result |
|---|---|
/compact |
Condense one useful balanced older span even below automatic pressure, then report the replaced history-item count and estimated tokens. |
/compact with no compactable history |
No compactable history yet. — nothing changes. |
/compact <anything> |
Usage: /compact (no arguments) — the command takes no arguments. |
The command turns each expected failure into a stable message you can show directly; the situation on the left is what produced the message on the right.
| Situation | Message you see |
|---|---|
| Compaction already running, or the agent is mid-turn | Compaction is unavailable because this process has an active compaction, or the agent is not idle. |
| The history changed while condensing | The history selected for compaction changed before it could be replaced. The conversation is unchanged; the attempt is recorded in the session log. |
| No useful summary could be produced | Compaction could not produce a useful summary. The conversation is unchanged; the attempt is recorded in the session log. |
| Condensation did not finish cleanly | Compaction did not finish cleanly; some session history may have changed. Inspect the current session state before retrying. |
| The conversation could not be saved | Compaction finished, but the session could not be saved. |
Cancelling the command stops the wait: the backend finishes its required cleanup, and the command settles as Compaction cancelled. while the UI stops waiting. Failures other than these expected cases surface as errors rather than being silently converted.
Mount the command registry, one condensation backend, and this plugin:
- id: commands
name: '@deepseek-ai/dsh-commands'
- id: compaction-basic
name: '@deepseek-ai/dsh-compaction-basic'
- id: command-compact
name: '@deepseek-ai/dsh-command-compact'
The shipped dsh base mounts it beside the default backend, and the Web client provides the command adapter. Automation surfaces that compose no command adapter keep automatic condensation only.
When the command succeeds, the selected older span is replaced by one summary and the recent history is untouched; the command reports the number of condensed items and estimated tokens. Prompts you submit while condensation runs are accepted and start only after it finishes — they are not lost or reordered. The command lifecycle is recorded in the session log but never enters model history.
Read these pages when the package-level contract is not enough; they move from the command to the seam, the shipped backend, and the design decisions.
/compact controlThe slash input and direct result never enter a model request. An accepted compaction separately replaces an older span with the backend's user-role checkpoint inside a standalone compaction/* { turn: null } bracket.
The command lifecycle adds no model tokens. A successful compaction reduces later requests by replacing the selected span with one framed summary; summarization itself is one auxiliary request.
Discovery and command bookkeeping do not affect the cache. The accepted surface replacement invalidates reuse from the first shadowed history token.
These limits define when the command is a poor fit; they are the current package constraints.
/compact reports that condensation is unavailable when a turn or already accepted waking prompt has right of way; the command itself is not queued.compactRegion() path.ctx.commands cannot invoke it and rely on automatic pressure compaction.