Repository navigation
Replies: 9 comments 1 reply
|
This is certainly an important feature to supportπ |
|
I checked the compaction reasoning path on current master ( No core patch is required to give compaction a different reasoning policy. Two For a private llama.cpp OpenAI-compatible endpoint, the compatibility settings must match that server:
With The fragment below matches the dual-route adapter test on the fork branch ( - name: '@deepseek-ai/dsh-llm-pi-ai'
config:
providers:
qwen-main:
apiKeyEnv: LLAMA_CPP_API_KEY
api: openai-completions
baseURL: http://127.0.0.1:8080/v1
reasoning: max
compat:
thinkingFormat: qwen-chat-template
supportsDeveloperRole: false
maxTokensField: max_tokens
models:
- id: Qwen3.8-27B
name: Qwen3.8-27B
contextWindow: 262144
maxTokens: 32768
reasoningEfforts:
off:
low: low
high: high
max: max
qwen-summary:
apiKeyEnv: LLAMA_CPP_API_KEY
api: openai-completions
baseURL: http://127.0.0.1:8080/v1
reasoning: off
compat:
thinkingFormat: qwen-chat-template
supportsDeveloperRole: false
maxTokensField: max_tokens
models:
- id: Qwen3.8-27B
name: Qwen3.8-27B
contextWindow: 262144
maxTokens: 32768
reasoningEfforts:
off:
low: low
high: high
max: max
- name: '@deepseek-ai/dsh-compaction-basic'
config:
summarizationProvider: qwen-summary
summarizationModel: Qwen3.8-27BI did not open an upstream PR. Related tokenUsage accounting work (compaction and retry bills) is on the same branch: https://github.com/vpimshin/deepseek-harness/tree/fix/token-usage-compaction-and-retry |
|
I can confirm this patch worked. |
|
The But, I was still getting compaction-basic:
maxTokens: 16384Turns out the standard agent preset has another In maxTokens: config.maxTokens ?? 8192,to: maxTokens: config.maxTokens ?? 16384,Rebuilt DSH, and then the new maxTokens was applied to /compact the way i intended. The actual vLLM request changed from: and So it looks like there are actually two separate things going on with Qwen:
|
Yea, theres a gap instead of a misconfiguration: the top-level Your two-part analysis is correct: (1) the reasoning side is handled by |
|
Both of these failure modes live on the summarization side β which is exactly the part dsh-dcp removes. It is a drop-in compaction backend that replaces only the summary step with deterministic code extraction (zero LLM calls): trigger thresholds, retention tail, transaction locks, and tool-pairing boundaries are all inherited from the official compaction host. There is no summarization call to truncate at a token cap, and no model round that can fail to complete β same input always produces the same checkpoint. Measured on a real dsh session: ~80K tokens of history compacts to ~700 tokens with 0 model calls; checkpoint format stays compatible with the official one (mergeable both ways). dsh plugin add @aiwayds/dsh-dcpYour compaction-basic fixes remain valuable for anyone staying on the LLM path β the trade-off between the two backends is semantic summarization vs verbatim hard facts (paths/commands/errors/todos/user quotes), and for local models the deterministic one tends to be the only reliable option. |
|
@Yunado I wonder how your quite intrusive patch compares to the dsh-llamacpp plugin? I have tried your patch in previous checkouts of dsh, and it seemed to work for me, however I am not very keen on running a too patched version of dsh. If vanilla dsh has bad support for llama.cpp router in general, then a trusted plugin would be a cleaner solution, I think. |
|
Status update β the patch has been rebased to current master. The cross-fork diff linked above was cut against
Both were verified against a clean The cross-fork link above ( |
|
Update β if you're on a stock DSH web (no core patches, no pi-ai patchfile), there is now a plugin route for everything in this thread: dsh-qwen38-local-qol. dsh plugin --profile web add github:Yunado/dsh-qwen38-local-qol
# one-time: generate the compaction user preset
node_modules/dsh-qwen38-local-qol/src/setup.js --src <path to the installed @deepseek-ai/dsh-agent-presets presets/standard/agent.cordis.yml>Then select the What you get:
The diff / patchfile routes above remain valid for core-tree builds, and are the only route for headless profiles (the plugin's preset seam is web-surface only). |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Running DSH against a local thinking model via llama.cpp (Qwen3.8-27B, ~150K-token sessions), I ran into two compaction failures in long sessions: manual
/compactβ "summarization truncated at the token cap (incomplete checkpoint)", and auto-compaction never completing. After digging intopackages/compaction/compaction-basic, I traced both to distinct root causes in the package itself. The fixes are small and let me compact 150K-token sessions reliably β sharing in case they help.Update (2026-09): the fixes in this post now ship as a public plugin β dsh-qwen38-local-qol. Stock DSH web users can install it directly (route in the Result section below, plus a comment in the thread); the diff / patchfile routes remain for core-tree and headless builds.
Root cause 1: summarization inherits the conversation's reasoning effort
Why the token cap is where it breaks (maxTokens vs. context length): the summarization call is a plain completion β its input is the region to summarize (scales with session length), while its output is capped by a fixed
maxTokens(default8192) sized only to hold the structured checkpoint, independently of the model's context window. On a non-thinking client the checkpoint is short and fits with room to spare. On a thinking model, the output budget is shared between reasoning and checkpoint β and the longer the session, the more the model plans before writing β so past a certain session size the thinking exhaustsmaxTokensand the checkpoint is truncated mid-structure, no matter how much context headroom remains. Bigger context windows do not fix this; the fix is to stop thinking on this one call (optionally withmaxTokensraised to ~16384 for extra headroom).summarizeWithLlm()insrc/summarizer.tsbuilds its completion request from the conversation's current reasoning settings. With a thinking model at a non-off effort, the model spends the fixed output budget (maxTokens, default8192) thinking before it ever emits the structured checkpoint β so the response hits the token cap mid-thought and the run ends with "summarization truncated at the token cap (incomplete checkpoint)".This also explains why auto-compaction "never engages" in practice: when the threshold finally fires, the same truncated summary fails, so compaction can never complete.
Fix: the summarization request should not think. Add
reasoningEffort: ReasoningEffortId("off")to the request insummarizeWithLlm. (For llama.cpp with--reasoning-budget, this also stops the server-side budget from being spent on the summary call.)Root cause 2: the replayed region is not reduced before summarization
The region sent for summarization still contains the model's own reasoning, images, and multi-hundred-KB tool results. On a slow local model, that large input idles out under the stream watchdog before the summary can start streaming, which fails the whole compaction.
Fix: add
prepareMessagesForSummary, which runs on a copy of the region and applies three new config options (sane defaults, per-model policy supported, validated viazod):summarizeReasoningKeepTurns5summarizeImages"strip"summarizeToolResultMaxChars2000Gotcha found while writing this: when stripping reasoning from a model-produced turn, you must also drop that turn's stored replay projection (the
sourcefield) β otherwise replay validation fails withINVALID_REPLAY_STATE. The projection exists to make the model's own reasoning replayable; it is inert once the reasoning text is gone, and leaving it in place is what trips validation.Result
With both changes, compaction works reliably on the local model across the session sizes I've tested β 128K, ~150K, and 256K tokens (all well past the trigger threshold). Both manual
/compactand auto-compaction complete: the summary fits inside the token cap, there is no watchdog idle-out, and the session continues normally afterwards.Update (2026-09): these changes now ship as a public plugin β dsh-qwen38-local-qol. On a stock DSH web:
dsh plugin add github:Yunado/dsh-qwen38-local-qolplus a one-timesetup.jsstep for the compaction preset β no core patch, no pi-ai patchfile, no rebuild. The diff routes below remain for core-tree and headless builds, where the plugin's preset seam does not reach.Full diff (8 files in
packages/compaction/compaction-basic, +501/β15, including tests):fix/compaction-local-modelon my fork: https://github.com/Yunado/deepseek-harness/tree/fix/compaction-local-model β diff vs upstream:47f9438...Yunado:fix/compaction-local-modelfix/llm-local-linesbranch (8b00e4e) on my fork (full local-LLM line).git apply compaction-fix.difffrom the repo rootApplies cleanly on current master (0.1.0-rc.8, commit 141eb6f) and on 0.1.0-rc.5 (commit 47f9438).
Not an upstream contributor β happy to rework the shape (single boolean instead of three options, different defaults, etc.) if maintainers prefer. The
INVALID_REPLAY_STATEinteraction in particular might warrant a doc note even if the option design changes.All reactions