Auto-compaction trigger
A DSH profile bundle that adds a Plugins → Auto-compaction trigger settings page, so you can choose the input-token level at which automatic context compaction starts instead of accepting the shipped default.
Install
In DSH, install this repo as a plugin bundle — full CLI command (desktop app or web app):
dsh plugin --profile desktop add @codemody/dsh-compaction-tunable
dsh plugin --profile web add @codemody/dsh-compaction-tunable
Or paste the package name @codemody/dsh-compaction-tunable into the Plugins
manager's install field. DSH pulls
it via pnpm into the profile's node_modules — no app restart needed.
The plugin card appears under Plugins with its settings page, and each new
session picks the engine up (a session that is already open keeps the preset
revision it started with). Disabling or removing the bundle returns every preset
to its shipped compaction defaults again.
Note: this bundle restates DSH's own agent presets, and its copies are pinned to DSH
0.2.2-rc.3. After a DSH app update, update this bundle too, so the restated preset lists stay in step with the shipped ones — see Scope and removal.
Why the YAML override did not work
The Web app composes agents behind agent presets. dsh-web-app disables the
host-plane rows (- id: compaction-basic, disabled: true) and each preset mounts
its own compaction backend:
- id: compaction
name: cordis:group
isolate: { compaction: true, toolResultPruner: true }
config:
- id: compaction-basic
name: '@deepseek-ai/dsh-compaction-basic'
...
A profile patch that targets id: compaction-basic edits that disabled host row,
not the preset-owned engine. The preset keeps the default policy:
trigger = floor(min(W × 0.8, W − O − 65536))
For W = 204800 with the default O = 32768: min(163840, 106496) = 106496 — the
~100k trigger. But O is the routed model's output reservation (its maxTokens),
not a constant: a profile that raises maxTokens to 65536 starts much earlier —
min(163840, 204800 − 65536 − 65536) = 73728, so compaction fires around 73k.
What this bundle does
Inserts a root row
compaction-policy(this package) whose Config is entirely volatile: the Settings form writes it through the normal profile patch and the running service updates in place.Re-declares every shipped agent preset (
standard,ptc,minimal,cordis) with its exact child list, replacingcompaction-basicwith@codemody/dsh-compaction-tunable/engine. The engine must live inside each preset's owncompactionisolate group: host rows never reach the agent tree, and a patch override replaces the whole row config, so each list is restated.The engine subclasses the shipped
BasicCompactionEngineand builds its policy fromctx.compactionPolicyon every pressure check. An absolute trigger is converted to a headroom per routed model:budget = contextWindow − reservedOutput trigger = clamp(triggerTokens, 1, budget − 1) headroom = budget − trigger # threshold becomes exactly triggerIf
triggerTokensis0or the token mode is off, the window-fraction fields (thresholdRatio,headroomTokens) are used instead.Because
budgetsubtracts the routed model's output reservation, the start point can never sit abovecontextWindow − maxTokens: with a 65536-token reservation the default155648clamps to139263. Lower the model'smaxTokens(e.g. to32768) in your LLM settings if you want the full trigger.
Use
Open Plugins in the sidebar (the bundle appears under Installed plugins), open Auto-compaction trigger, then:
- pick At a token count and set the start point (default
155648); or - pick At a window fraction and set the fraction and headroom;
- optionally set the recent-history budget and the summary output cap;
- Save.
The change is written to $DSH_HOME/profiles/desktop/cordis.patch.yml and
applies to agents started after saving. Existing sessions keep the preset
revision they started with, so open a new session to use the new threshold.
The host log prints the resolved start point once per routed target:
compaction-tunable: strata/Qwen3.8-flash-next starts compaction at ~155648 tokens (context 204800, output reserve 32768)
Scope and removal
- Controls all four shipped presets:
standard,ptc,minimal, andcordis. A preset you author yourself in the Web editor keeps the shipped basic engine until a bundle update restates it too. - To uninstall, use Plugins → Auto-compaction trigger bundle → uninstall (or
plugin_managerremove_bundle). The profile then returns to the shipped preset and the default 65,536-token headroom. - The preset copies are pinned to DSH
0.2.2-rc.3. After a DSH upgrade that changes the preset lists, update the bundle to pick up new preset plugins.preset-cordisadditionally pins itsskill-filesystemskills directory to the installed app'sapp.asarpath (the shipped!!jsexpression resolves relative to the web-app patch layer only).
Compatibility
- DSH:
0.2.2-rc.3— the restated preset copies are pinned to this revision (see Scope and removal). Installs into any profile (desktoporweb): the patch resolves everything through package exports and contains no profile-specific paths. - Runtime: settings are volatile — saving applies in place, no app restart; sessions started afterwards pick the new threshold up.
- License: MIT (LICENSE).
No comments yet. Be the first to write one.