DeepSeek Harness Compaction: When Does It Trigger?
Compaction does not happen “when context is full”; it happens around request assembly, when a condition is met. DeepSeek Harness checks pressure and compacts automatically, and also offers a manual entry (source). Understanding the trigger order explains “why this request suddenly got shorter” and “why the detail disappeared.”
DeepSeek Harness: Where compaction sits in a turn
Compaction happens during request assembly, not at an arbitrary background moment. A request first freezes model history and assembles prompt and tool schemas; compaction changes the history segment. (source)
Two consequences:
- Only later requests are affected — a request already sent does not change.
- The session log is not rewritten — the log keeps original events; compaction changes the visible projection.
So “the context shrank” and “the history was deleted” are different. DeepSeek Harness does the first, not the second.
Compaction is also not truncation. Truncation drops the overflow; compaction replaces older content with a summary, with a different information loss pattern.
DeepSeek Harness: Automatic triggers
Automatic compaction is threshold-driven, tied to the model window and configured caps. The docs describe context pressure reaching a condition, not a fixed “every N turns” rule (source).
Three factors:
- Model window — smaller windows trigger earlier.
- History size — tool results, attachments, and long messages raise pressure.
- Configured cap — deployments can set a conservative threshold.
The check usually runs during request assembly, so you see a long history become a summary before a particular request. It was not lost; compaction applied there.
Frequent compaction means something is inflating context: tool results, images, long logs, repeated references. Raising the threshold does not fix the cause.
DeepSeek Harness: What manual compaction does
Manual compaction frees space before the automatic threshold; it is not a debugging substitute. It makes the next request lighter but does not change the log. (source)
Three uses:
- Before a long task — compact early to avoid a mid-task trigger.
- A large useless result — summarize earlier context.
- Test compaction — trigger once and observe what survives.
Manual compaction cannot restore summarized detail, change sent requests, or replace session cleanup. To recover detail, read the session log, not compact again.
Frequent manual compaction loses detail. Each pass can drop nuance the model needs for earlier decisions.
DeepSeek Harness: What survives and what becomes a summary
Compaction keeps structure and key points; it loses original detail. The exact split depends on strategy and implementation (source).
Usually kept:
- Recent user and assistant messages.
- Key decisions and open work.
- Tool result summaries or locators.
Usually summarized:
- Older back-and-forth.
- Completed intermediate steps.
- Large tool output.
Usually outside compaction:
- System prompt and hard constraints.
- The current turn's input.
- Still-referenced tool results, possibly via locators.
This explains “why the model forgot a detail after compaction.” The detail became a summary.
If a detail must survive, write it into explicit context before compaction, such as a summary message or a file. Do not rely on history.
DeepSeek Harness: Cost and failure
Compaction costs detail and one extra model request; failure may fall back or report overflow. Three cases (source):
- Success — the next request is smaller, detail becomes a summary.
- Failure with fallback — the original context continues, possibly near the limit.
- Failure without fallback — the request reports context overflow and needs manual action.
The second is easy to miss: nothing seems to happen, but compaction failed and the next request may overflow.
The third usually has an explicit error. Check the message and current context size, then choose manual compaction, session cleanup, or a larger-window model.
Failure causes include a summary request that itself exceeds a limit, an unavailable model, or tool output that cannot be summarized. Check the compaction request before the main request.
DeepSeek Harness: Verify compaction behavior
Use four observations. Four steps (source):
- Trigger — build a session near the threshold; confirm compaction before the next request.
- Retention — recent messages and key constraints remain.
- Summary — older history becomes a summary; the log still has originals.
- Failure — simulate a summary failure; fallback or error is explainable.
All four mean trigger, retention, summary, and failure agree. Passing only the first often hides unpredictable detail loss; passing the first three often hides a missing fallback.
The existing dsh-compaction-explained covers the mechanism, develop-compaction-results covers results, and fix-compaction-and-context-window covers failures; this article covers trigger order and cost. Look at what creates pressure before tuning compaction.
FAQ
DeepSeek Harness compacts automatically when context pressure reaches a condition and also offers a manual entry. Automatic checks usually run before request assembly, not as an arbitrary background job.
DeepSeek Harness automatic compaction is threshold-driven; manual compaction is user-initiated. Both change the next request context, but the timing and control differ.
DeepSeek Harness does not work that way. DeepSeek Harness compaction changes the model-visible context; the session log still records what happened, so replay can rebuild it.
In DeepSeek Harness, not always. DeepSeek Harness may continue with the original context, report a context overflow, or take a fallback path; check the error and the next request size.
Related Terms
- compaction
- Compaction is DeepSeek Harness replacing older history with a summary to reduce the next request input; it does not delete the original session log.— DeepSeek Harness reference - Compaction
- pressure threshold
- A pressure threshold is the DeepSeek Harness context-size condition that triggers compaction, often near the model window or a configured cap.— DeepSeek Harness reference - Compaction
- summary
- A summary replaces older history after compaction in DeepSeek Harness, keeping key points while losing original detail.— DeepSeek Harness reference - Compaction
- manual compaction
- Manual compaction is a user-invoked DeepSeek Harness action that frees context before the automatic threshold is reached.— DeepSeek Harness reference - Compaction
Sources
- DeepSeek Harness reference - Compaction· deepseek-harness
- DeepSeek Harness reference - Session· deepseek-harness