Introduction¶
When handling long-running tasks, DeepSeek Harness (DSH) typically provides only two context states: keeping all content intact, or compressing it into an opaque summary via dsh-compaction-basic. In large-scale tasks, this can cause garbage data (such as 4k-token grep stacks or already-resolved subtasks) to occupy the context window for a long time until a threshold is reached and compaction occurs, which cannot be inspected or undone.
catsenior507/dsh-context-assembler turns context from a simple matter of “length” into “a set of decisions.” It builds an inspectable context tree based on session logs, allowing you to control what the model actually receives through a browser panel while preserving KV cache compatibility for unmodified nodes.
Core Features¶
The plugin builds a context tree on top of the DSH session surface. Its core operation is replacing N consecutive event nodes with a single node, thereby changing what the model receives.
Node Modes
Each node supports three modes, switched using a tri-state toggle:
* full: keeps the content unchanged without replacement.
* key: preserves key information; the content is replaced with a summary.
* off: discards the content and keeps only a very short marker (configurable to 0 tokens).
Main Capabilities
* Context Tree: generated from session logs and viewable hierarchically (turn -> step -> system/user/assistant/tool).
* Browser Panel: provides visual editing, live preview/apply, and statistics (visible/folded/original token counts).
* Agent Tool: registers the context_assembler tool, supporting the four operations: tree, set, preset, and messages.
* KV Cache Compatibility: because only folded nodes are replaced, unmodified nodes retain their positions, allowing providers to reuse KV caches.
Installation and Enablement¶
Add the plugin using the official installation command:
dsh plugin --profile web add https://github.com/catsenior507/dsh-context-assembler
After installing, restart the dsh web process to load the plugin. The dsh-web-watchdog panel usually provides a quick restart button.
Usage¶
Browser Panel Operations¶
- Open the panel: press the keyboard shortcut
Ctrl+Shift+Kin the browser, or click the Assembled Context button in the bottom-right corner of the interface. - Select a session: by default, the most recently active session is shown. Sub-agent sessions are listed separately because they have independent surfaces.
- Edit the tree:
- In the tree view, each row represents a node (turn, step, system, message, etc.).
- Click the tri-state toggle at the beginning of a row to switch between
full/key/off. - The top toolbar provides quick actions, such as “Set tool results to key,” “Turn off all content,” or “Expand all.”
- Apply changes: after making adjustments, click the Apply button at the bottom. Changes are written to the session log only after Apply is clicked; otherwise they exist only in browser memory.
Agent Tool¶
The plugin registers the context_assembler tool for the model, supporting the following actions:
tree: reads the structure of the current context tree, including surfaceSeq, node type, current mode, and estimated token count.set: modifies a node’s mode using surfaceSeq. The digest is written by the model itself, and dryRun can be used to preview the effect.preset: creates rule presets for one-click application by users.messages: views the messages currently actually received by the model and their total token count.
This allows the agent to proactively fold its own operational history into a one-line conclusion after completing a subtask, instead of passively waiting for compaction.
Notes¶
- Live Derivation: each time the panel is opened, the tree is re-derived from the session log and does not rely on persistent plugin state. This means that after restoring a session, switching processes, or an agent folding by itself, the panel display remains consistent with the log.
- Atomicity Requirement: a tool call and its result must remain atomic (as a complete group). The plugin automatically expands the folding scope to cover the entire tool group.
- Folding Restoration Limitations: current surface replacement only supports N→1. Multi-node folding (N>1) cannot be perfectly restored. The plugin explicitly states: single-node folding can be restored exactly as it was, while multi-node folding is restored as a full replay message with delimiters.
- Configuration Details: the configuration file includes a loopback API port setting (such as port: 4799) for communication in environments without a web server.
Summary¶
Assembled Context returns control over DSH’s context to users and agents. Through the browser panel and agent tools, you can precisely manage the token budget, avoid polluting the context window with irrelevant history, and leverage KV caching to optimize performance.