rea
morluto
Reverse engineer anything with agents, from app behavior down to native binaries.
PROJECT TOPICS
INSTALL REFERENCE
dsh plugin --profile web add github:huohua-dev/dsh-compaction-policy
该命令指向仓库当前默认分支;尚无绑定当前 commit 的完整验证结果。
PROJECT README
中文 · Development & host tests · Security
An experimental global compaction policy for DeepSeek Harness. Keep the official Basic summarizer, checkpoint records, tool pairing, token meter, UI event protocol, native /compact, and overflow recovery. Change proactive budgeting, range selection, and no-progress retries—without selecting a special preset.
Experimental v0.2.3. Ported to the DSH 0.2.2-rc.1 host generation. The bundle load-admits the DSH ^0.2.2-rc.1 host line (0.2.x from that build on, including later release candidates) and Cordis 4.0.x / 4.1.x; the policy then activates only when seven Basic method fingerprints match the verified implementation. A host bump that changes only version labels needs no plugin update, and an unrecognized host build leaves the plugin loaded but inert on stock Basic instead of failing startup. Actual-host tests with synthetic sessions and scripted model responses have passed. This is not proof of live GUI behavior or summary quality on a native Windows/real-model session. No lossless-summary or larger-context-window claim is made.
Running DSH 0.2.1-rc.1 – 0.2.1-rc.5? Stay on v0.2.2. The 0.2.2 generation moved pressure logic into
compactPressureand added a model-switch check. Alpha.2/alpha.3 already contain that implementation, but ship unverified Cordis prereleases; this port deliberately starts at the tested 0.2.2-rc.1 host.
The default bundle installs exactly one root plugin:
- id: compaction-policy-global
name: dsh-compaction-policy/global
config: {}
compactPressure, which both automatic checks pass through: the between-step pressure check and (DSH 0.2.2+) the check before switching to another model. Manual /compact and confirmed-overflow recovery never reach it and stay entirely native.Only the fingerprint-verified official Basic implementation is targeted. Custom backends, subclasses, and instances with method overrides are skipped. Presets with no compaction, including minimal compositions without it, are unaffected. “Global” does not mean every DSH process or profile on the machine.
Stock Basic can trigger early when a model permits a large output:
stock threshold = floor(min(W × 0.8, W − requestMaxTokens − 65536))
reservedOutput = min(requestMaxTokens, outputReserveCap)
policy threshold = floor(min(W × thresholdRatio,
W − reservedOutput − headroomTokens))
retentionTarget = floor((W − reservedOutput) × retainRatio)
Defaults are thresholdRatio: 0.9, outputReserveCap: 0, headroomTokens: 0, so the proactive threshold is exactly floor(W × 0.9). The remaining 10% is the margin; it is not deducted a second time. For a 262,144-token window with a 131,072-token output cap, the threshold changes from 65,536 to 235,929 tokens. This is arithmetic, not a performance benchmark.
pruneToolResults: false applies only to the new proactive path (the background check and the model-switch check). That path does not pre-prune tool results; old content is summarized through Basic. It does not disable the native pruner service or change stock-mode, manual, or confirmed-overflow behavior.
An output cap is not guaranteed available space. A 90%-full prompt and a full 128K completion cannot coexist in a 256K window. The adapter/server must enforce remaining capacity; providers that validate
input + max_tokensmay reject earlier. Native overflow recovery still applies. This plugin is not an HTTP output-budget clamp.
Since DSH 0.2.2-rc.1, Basic also checks the history before a request moves to a different provider/model, pricing the proposed envelope against the target route's window and refusing the switch if compaction cannot bring it under the threshold. Left alone, that check would compact at the stock threshold (41% of a 1,000,000-token window for a route that declares a 524,288-token output cap) no matter what this plugin does for ordinary steps. Under the policy:
compactionRetries + 1), judged against the policy threshold. If it cannot end below the threshold, the switch is refused with the host's own error (MODEL_SWITCH_COMPACTION_FAILED), exactly like stock.dryRun observes switches without mutation, including these fallback cases; a mode: stock route always keeps the native check./compaction-policy-global status reports via: "model-switch" for these decisions.Distribution is via GitHub, not npm. Install the v0.2.3 prerelease tag:
github:huohua-dev/dsh-compaction-policy#v0.2.3
Use the Desktop plugin-manager UI to add or update the GitHub source, then fully quit and restart Desktop so the existing host process is replaced. A page refresh or profile reload is not a substitute after an upgrade: an old-process import failure was observed and cleared by a full restart. Desktop-managed plugin changes via CLI are rejected; do not use a --profile desktop CLI workaround.
After loading, use your existing normal preset. No special preset selection is required. Run /compaction-policy-global status in the session to inspect coverage and the effective policy. Installation does not choose a new default provider or preset.
For a web profile not managed by Electron/Desktop:
dsh plugin --profile web add github:huohua-dev/dsh-compaction-policy#v0.2.3
Reload/restart that existing host. This CLI example is not an alternative installation path for Desktop.
Apply a user profile override to compaction-policy-global, with policy fields under config.policy. Row configuration is replaced as a whole, not deep-merged; restate any custom values you need to retain. Reload the profile after changing it.
For example, use stock behavior except on one exact route:
- id: compaction-policy-global
config:
policy:
mode: stock
modelPolicies:
- provider: your-local-provider
model: your-model-id
mode: policy
thresholdRatio: 0.9
outputReserveCap: 0
headroomTokens: 0
pruneToolResults: false
Provider/model matching is exact and case-sensitive. Without this opt-in route example, the default policy applies to all eligible Basic instances.
| Policy field | Default | Meaning |
|---|---|---|
mode |
policy |
policy uses the new proactive strategy; stock delegates to Basic, including its model-switch check. |
thresholdRatio |
0.9 |
Proactive window fraction, subject to the remaining-capacity branch. |
outputReserveCap |
0 |
Proactive output reservation cap, not the API output cap. |
headroomTokens |
0 |
Extra proactive deduction; the default 10% margin is already in the ratio. |
pruneToolResults |
false |
Whether the new proactive path invokes the native tool-result pruner first. |
retainRatio |
0.16 |
Soft recent-tail fraction of W − reservedOutput. |
retainTokens |
unset | Absolute soft target instead of retainRatio; mutually exclusive. |
minFreshTokens |
2048 |
Minimum selected non-checkpoint token weight. |
retryAfterTokens |
4096 |
Candidate change needed for a retry before cooldown expiry. |
retryCooldownMs |
60000 |
Initial failed-summary cooldown. |
maxRetryCooldownMs |
600000 |
Maximum exponential cooldown; at least the initial value. |
modelPolicies |
[] |
Exact { provider, model, ...policyFields } overrides. |
dryRun |
false |
Observe the new proactive path (background and model-switch checks) without pruning/summarizing; stock, manual and overflow paths still operate. |
Policy fields except modelPolicies and dryRun can be overridden per route. Unknown keys and invalid values are rejected. Invalid pressure budgets produce diagnostics, not an invented larger window.
The global entry has no basic field, including under config.policy. Each engine keeps its original Basic configuration: summary provider/model, summary output budget, reasoning behavior, automatic enablement, and stock/manual/overflow settings. Configure those at the engine's existing Basic row, not in the global plugin.
Where upstream defaults are used, the 65,536-token summary cap stays intact. Policy headroom 0 does not set the summary cap to zero. The main request's output cap and thinking settings also remain unchanged. Basic's auto: false retains its native semantics: automatic pressure and overflow listeners are off, while manual /compact remains available.
/compaction-policy-global [status|reset]
/compact
status reports coverage and proactive diagnostics without transcript content; via tells a background check (pressure) from a model-switch check (model-switch). reset clears the current session's proactive retry guard; it does not compact, rewrite history, or change the model. Native /compact remains the manual compaction command. A reduction that remains over threshold is reported as compacted-still-above-threshold, not as “back under budget”. Failure state is in memory per live session, not persisted across restarts.
After a host upgrade, status is also the compatibility answer: enabled: true means the verified fingerprints still match. If a future host really changes a verified method, the plugin stays loaded, logs a warning, and reports enabled: false with reason unsupported-host while stock Basic keeps working untouched; update the plugin when a reviewed build is available. Maintainers can run npm run compat:host against the new host for the full fingerprint report (see CONTRIBUTING).
On disposal, the global policy becomes inactive first, then drains in-flight work before safe restoration. Foreign wrappers are not overwritten: if another plugin has wrapped a patched method, this plugin's wrapper stays inert until safe restoration or restart. Disabling does not forcibly rebind running agents.
0.2.3 needs DSH 0.2.2-rc.1 or later; an older host rejects the bundle at admission (engines.dsh), so keep v0.2.2 there. There are no configuration changes: the config.policy fields, the status command and the install steps are the same. What changes is where the policy attaches (compactPressure instead of compactIfNeeded, which is no longer patched) and that model switches are now covered. After updating through the Desktop plugin manager UI, fully quit and restart Desktop, then run /compaction-policy-global status: enabled: true confirms the verified fingerprints matched.
If dsh-compaction-policy is no longer enabled in your profile after a host update, re-enable it after updating; an orphaned compaction-policy-global entry in your own patch file only logs entry not found until then.
The old test preset compaction-policy is no longer registered. There is no old-session restoration compatibility; previous test sessions are not a supported upgrade target. The package does not delete or rewrite session logs.
compaction-policy-legacy and compaction-policy-preset, plus custom references to those removed entries. Package installation does not silently edit your profile./compaction-policy-global status.The root dsh-compaction-policy backend and dsh-compaction-policy/global entry remain available; the /preset and /legacy exports are removed. The default bundle loads only the global entry. Custom compositions must use only one backend inside their isolated compaction group; the global plugin is not a replacement backend. Headless use of the global entry requires the host's commands and agentPresets services; a composition without them cannot load it unchanged.
compaction-policy-global; alternatively set config.policy.mode: stock and remove any route overrides that still enable policy mode.dsh plugin --profile web remove dsh-compaction-policy, then restart that host.Uninstalling does not delete or rewrite session logs, migrate test-preset identities, or restore all pre-compaction history into active context.
Summary quality and provider capacity remain model/upstream concerns. Meter values are host estimates; the plugin does not falsify token counts, lower main-request reasoning, add a compression service, wrap global fetch, patch ASAR, or ship another DSH kernel. Host plugins run with host privileges; model tool approvals do not sandbox them.
Compatibility has two separate layers. The declared DSH range only decides whether the bundle may load, so release-candidate and patch bumps inside the 0.2.x host line no longer need a plugin re-pin. The seven-method fingerprints (the patched compactPressure, the dispatcher compactIfNeeded, the listener wiring _registerAutomaticCompaction, and four transaction-related methods, including the native manual entry checked for compatibility but not intercepted globally) decide whether the policy may activate: they are a deliberate safety gate, not a promise that changed upstream internals are supported. If a fingerprint ever differs, the policy fails safe to stock behavior and the new seam must be re-read and re-tested before the fingerprint is refreshed—never merely widened or re-recorded blind. Actual-host synthetic tests do not establish live UI or native Windows summary quality.
npm test
npm run check
npm run pack:check
See development and host-test instructions for the synthetic real-host suite. These checks do not constitute a live-model acceptance test.
MIT © 2026 huohua-dev. See NOTICE for upstream contracts and related work. No third-party plugin implementation or DSH kernel is vendored.
CLASSIFICATION EVIDENCE
系统优先读取 GitHub Topics,再与站内分类词典和词根规则比对。当前命中: deepseek。