compaction failed: context summary errors and recovery
Compaction fails in two ways: no useful summary, or a summary that hits the output limit. Both signal context pressure, but one calls for threshold tuning and the other for a larger-output model.
Two compaction errors
Two messages, two dimensions: quality and length.
| Error | Meaning | Check first |
|---|---|---|
| compaction could not produce a useful summary | Summary unusable | History size and model capability |
| compaction summary reached the output token limit | Summary hit the limit | Output limit and summary length |
The first is "cannot compress usefully." Long, scattered history or a weak model produces a poor summary that the system rejects.
The second is "compressed but too long." The summary itself hits the output limit, usually with very large history or high detail requirements (source).
Both may come with continuation failures. Seeing a still-truncated message means repeated attempts also failed; do not keep retrying.
Why compaction fails
Four factors dominate.
- History too large. Too much content at once, summary either does not fit or loses quality.
- Output limit too small. The model cannot finish the summary; it is cut midway.
- Topics too scattered. Mixed tasks make trade-offs impossible.
- Model capability insufficient. A small model loses the thread and is judged unusable.
All four are input-output mismatches. Too much input and too little output guarantee failure; tuning only delays it.
Check history size before output limit. Reversing the order leads to model swapping when the issue is history.
Automatic or manual
Automatic and manual compaction fail differently.
- Automatic: triggered at a threshold; failures may repeat every turn.
- Manual: triggered by you; retry with a different model or scope.
- Diagnosis: check whether the error appears at fixed turns or after your action.
- Automatic failure: stop at a stable point and recover manually.
- Manual failure: change model or narrow scope.
Automatic failure is easily missed. It retries silently until the session stalls; fixed-turn errors suggest it.
Manual compression is controllable. Save key conclusions first; a failure does not break ongoing work.
Recovery order: light to heavy
Preserve data first.
- Save key conclusions. Write decisions, paths, and todos into a new message or external note.
- Open a new session. Start with the summary or key conclusions, bypassing oversized history.
- Adjust the threshold. Trigger compaction earlier; too low increases calls.
- Switch to a larger-output model. When summaries need more room, a model change beats parameter tuning.
- Split history. Divide by task to reduce per-compaction pressure.
- Remove irrelevant content. Delete long logs, duplicate attachments, and dead dialogue.
A new session is the most reliable stopgap. It does not depend on compaction success and restores work immediately; the cost is lost context.
Threshold and model must be considered together. Threshold alone leaves summaries cut; model alone leaves frequency unchanged.
After two failures
Two consecutive failures mean the current path is wrong.
- Stop automatic retries to avoid repeated failure records.
- Start a new session with key conclusions.
- Keep only necessary background, not the whole history.
- Retrieve old details with search or logs instead of recompressing.
- Record history size, model, and threshold for the next adjustment.
Two failures are a signal, not bad luck. Same input and model will likely produce the same result.
New sessions also need size control. Moving the entire history copies the problem; carry only conclusions and references.
Prevention: keep history bounded
Compaction failure is preventable by controlling history size.
- Close stages. At the end of a task, write conclusions and open a new session.
- Avoid pasting large blocks. Use paths or summaries for long logs and files.
- Clean periodically. Remove irrelevant attachments and duplicate dialogue.
- Watch threshold warnings. Start converging when compaction appears, not after failure.
- Choose an adequate model. Long sessions need stronger output capacity.
Prevention costs less than recovery. Two lines of conclusions per task beats rebuilding context afterward.
Next steps
Read the error, then recover by cost. For the mechanism, read What context compaction is. For window overflow, read Context window overflow. For output limits, read Output token limit and truncated replies.
Sources: DeepSeek Harness docs, dsh CLI README, deepseek-harness repository
FAQ
compaction could not produce a useful summary means compression failed to produce a usable summary; the session is not necessarily broken. History usually remains, so retry with another model or threshold.
compaction summary reached the output token limit is related to truncated output but different. The summary itself hit the output limit, while ordinary truncation affects a normal answer.
Continuing after compaction fails may fail every turn and block the session. Stop at the failure, recover once, then continue.
Raising the compaction threshold reduces frequency but not the root problem of a large history. If the model output limit is too small, the summary will always be cut; change models or split history.
Related Terms
- compaction
- Compaction is the DeepSeek Harness process of compressing history into a summary to free context window space.— DeepSeek Harness docs
- summary
- A summary is the compressed replacement for earlier history, keeping the main thread and key conclusions while losing detail.— DeepSeek Harness docs
- context window
- The context window is the total tokens a model can hold in one request; exceeding it requires compaction or truncation.— DeepSeek Harness docs
- output limit
- The output limit is the maximum generation length per request, and compaction summaries are also constrained by it.— DeepSeek Harness docs
Sources
- DeepSeek Harness docs· deepseek-harness
- dsh CLI README· deepseek-ai
- deepseek-harness repository· deepseek-ai