Preface¶
In DeepSeek Harness (DSH) development, context hallucinations typically stem from “history pollution”: outdated conclusions, irrelevant fragments, or old conversations mistakenly treated as facts getting mixed into the current reasoning. The attention-scheduler plugin provides a reusable set of specifications for attention, context, and memory usage, distributed as a DSH skill. It manages through explicit rules “whether to retrieve, how much to recall, what to keep, what to discard, and what to write back”, giving the model consistent and auditable behavioral foundations for memory management. This plugin is suitable for scenarios with long sessions where history crowds out context, or where teams want to unify retrieval/memory usage discipline.
Core Features¶
The plugin contains the following main modules:
- Four-tier retrieval triggers: Define mandatory/forbidden/strong/weak/suppressed trigger rules, including conflict priority.
- Cross-session retrieval constraints: Restrict query scope and project namespaces via session tags and privacy sessions.
- Attention budget: Set retention turns, retention priority, six elements of compressed summaries, fixed overhead formulas, and compression trigger thresholds.
- L0/L1 cost attribution: Distinguish between skeleton residency (counted as fixed overhead) and dynamic recall (counted as injection budget), clarifying cost attribution.
- Memory injection: Manage recall counts and injection counts, set injection budgets (20%–25% of working memory), and over-limit eviction rules.
- Conflicts and write-back: Define conflict priority, write-back whitelist/blacklist, and write-back format and version chains.
- Measurement script: Provides
scripts/measure-overhead.cjsto separate three types of costs from session logs: fixed overhead, L0 skeleton, and L1 dynamic recall. - Configuration mapping table:
references/config-map.mdclarifies which clauses need mandatory configuration, and the “injection form comparison table”.
Installation and Activation¶
This plugin is available in two forms: as a standard DSH plugin and as a file skill.
Install as a plugin (Recommended)¶
Install using DSH’s plugin management command; after installation, the profile must be restarted to take effect.
dsh plugin --profile web add github:Kfytm/attention-scheduler
For local development, you can use the link method for immediate effect after modifications:
dsh plugin --profile web add link:D:\path\to\attention-scheduler
The plugin rank is set to 250, lower than local file skills (400) and official built-in skills (600), so user local skills with the same name will override this plugin.
Uninstall command:
dsh plugin --profile web remove dsh-attention-scheduler
Install as a file skill¶
Clone the repository and run the installation script.
Windows:
powershell -ExecutionPolicy Bypass -File scripts\install.ps1
macOS / Linux:
bash scripts/install.sh
The default installation location is ~/.dsh/skills/attention-scheduler/. The skill name must match the regex ^[a-z0-9]+(?:-[a-z0-9]+)*$ (kebab-case). No restart is needed after installation; DSH will hot-discover it.
Usage¶
- Load on demand: In DSH, directly say “apply attention scheduling rules”, or call the skill tool to load
attention-scheduler. - Global effect: Write the condensed rules from the skill into
~/.dsh/AGENTS.md, which will be automatically injected as workspace instructions each round. - Re-measure overhead: Run the measurement script to compare cost structures under different configurations.
node scripts/measure-overhead.cjs --session "~/.dsh/sessions/<ws>/<session-id>/session.v4.jsonl.zstd"
Dependencies and Limitations¶
- Memory plugin dependency: A memory plugin (such as MemOS or dsh-plugin-memory) is required for L1 dynamic recall, retrieval triggers, and other features to fully function. Without a memory plugin, only attention budget, retention priority, six elements of compression, and write-back whitelist will actually take effect; retrieval triggers, recall/injection counts, and other clauses will remain idle.
- Permissions and restart: After installing via the plugin method, the profile must be restarted to take effect.
Summary¶
attention-scheduler controls the flow of context and memory through rule-based means, suitable for developers who want to reduce hallucinations and optimize costs. Its core value lies in transforming vague “memory management” into a configurable and auditable process.
Plugin directory: https://www.skillhub.cn/plugins/Kfytm/attention-scheduler
GitHub repository: https://github.com/Kfytm/attention-scheduler