Lequait/dsh-context-rescue ↗★ 0

dsh-context-rescue

Emergency rescue for DeepSeek Harness sessions that hit the model context window: detect the overflow, fold the oldest history into a durable digest, retry the same step.

패키지
dsh-context-rescue
호환성
미검증
Harness peer 범위
>=0.2.0-rc.1
버전
0.2.4
라이선스
MIT
최근 업데이트
2026. 10. 31.

설치

$npx -p @deepseek-ai/dsh dsh plugin --profile web add github:Lequait/dsh-context-rescue

Configuration

All keys are optional; pass them through the plugin's config block.

KeyDefaultMeaning
enabledtruemount the plugin at all; false leaves the harness untouched
mode"auto"auto runs the full ladder (prune → host engine → mechanical fold → excerpt); fold runs the same ladder without the host compaction engine, so it never asks a model to summarise; diagnose detects and reports but rewrites nothing
zeroModelOnlyfalsenever call the model/compactor; go straight to the mechanical fold
trimOversizedMessagestruewhen one message alone overflows, replace it with its own head and tail
excerptChars3000characters kept from each end when that happens
allowModelCompactiontrueallow T2 (the host engine)
retainRatio0.25share of the current surface kept as the recent tail
retainMinTokens / retainMaxTokens4000 / 40000clamps for the retained tail
targetRatio0.75fold until the surface is at most this share of the window
fitRatio0.9treat the surface as fitting below this share of the window
minFoldTokens4000below this, folding is not worth a transaction
maxAttemptsPerTurn2rescue budget per assistant turn
maxDigestChars12000hard cap on the checkpoint body
pinFirstUserMessagetruekeep the first user message outside every fold, unless that message alone is over the budget
windowFallback196608window used when neither the failure nor the model info provides one
extraPatterns[]regex sources added to overflow detection
laneRefusalPatterns["dsh_compaction_refused", "bili owns compression"]proxy refusals that permanently block T2
registerToolstrueregister the three tools
registerCommandstrueregister /rescue and /rescue-status when the host has a command registry
preflighttruefold on agent/pre-step when the projection is already over the window
repairTransactionstrueclose a compaction bracket a crash left open; a dangling one blocks every later fold
verbosetruelog rescue decisions to the session
debugfalselog one structured line per decision — the detected code and window, both measurements, every tier with the reason it declined, and the folded span — so a session that is not being rescued says why

Configuration mistakes are reported, not swallowed

Options are validated when the plugin mounts. An unknown key (retainRation), a mode the plugin does not know, a ratio outside its usable range, or a targetRatio that sits at or above fitRatio is logged as a config: warning instead of quietly changing the behaviour you expect. A rescue plugin that silently ignores a typo is indistinguishable from one that is not installed.

The options are a real schema, not a wish list

lib/schema.js declares every option below as a Cordis/Schemastery schema, which the host uses in two ways: it validates your patch before the plugin starts, and it documents the options in dsh --dump-config-schema. A value the schema refuses (retainRatio: 5, mode: aggressive, preflight: "yes") stops the boot with the field name and the bound, instead of starting with a silently clamped number:

$.retainRatio expected number <= 0.6 but got 5

Unknown keys are deliberately left alone by the schema so the warning above can name your typo — the two checks cover different failures, and neither hides the other.

Configuration mistakes are reported, not swallowed

Options are validated when the plugin mounts. An unknown key (retainRation), a mode the plugin does not know, a ratio outside its usable range, or a targetRatio that sits at or above fitRatio is logged as a config: warning instead of quietly changing the behaviour you expect. A rescue plugin that silently ignores a typo is indistinguishable from one that is not installed.