Introduction¶
When handling coding tasks, DSH (DeepSeek Harness) often encounters issues such as the AI forgetting previously rejected implementation approaches, repeatedly hitting the same pitfalls, and losing project engineering constraints. The dsh-plugin-memos-code-retrospect plugin replicates mneme’s coding conversation retrospective distillation logic. It addresses the above issues by extracting rejected solutions, pitfall records, and engineering constraints. It does not introduce the mneme binary or create a separate database; instead, it fully reuses the MemOS memory foundation for data persistence.
What Is It¶
This plugin is maintained by ai-fu-cn and is an MIT-licensed open-source plugin. It extracts rejected solutions, pitfall records, and engineering constraints at the end of a conversation (turn/end), tags them with type:rejected_solution, and writes them to MemOS. Before reasoning for a coding task (agent/pre-step), it performs weighted recall of these memories and injects them into the context, enabling the AI to avoid historical traps.
Core Features¶
- turn/end distillation: After a round of interaction ends, the plugin assembles the complete conversation context from
session.events(with a configurable truncation length) and calls an LLM to extract three entity types:rejected_solution(rejected solution),pitfall(pitfall record), andconstraint(engineering constraint). - agent/pre-step weighted recall: Before agent reasoning, the plugin determines the task type and retrieves
type:rejected_solutionmemories only for coding tasks. It boosts their weights (default 2x) and then injects them into the prompt. - v2 robust version: Includes fallback retry for LLM JSON parsing (no more than once), similarity deduplication before writing (threshold 0.82), low-value content filtering, and 14/14 unit tests passing.
Installation and Enablement¶
- Prerequisites: Ensure DSH (web profile) and the MemOS local plugin (
@memtensor/memos-local-plugin) are installed, and that the Node.js version is >= 18. - Install the plugin:
dsh plugin --profile web install https://github.com/<your-github-name>/dsh-plugin-memos-code-retrospect
- Register it in DSH: Append the following configuration to
<profile>/cordis.patch.yml:
- insert:
- id: dsh-plugin-memos-code-retrospect
name: './plugins/dsh-plugin-memos-code-retrospect/dist/index.js'
config:
enabled: true
profileId: default
recallEnabled: true
captureEnabled: true
boostFactor: 2
recallTopK: 6
contextMaxChars: 3000
maxDistillContextChars: 8192
distillMaxTokens: 2048
distillRetries: 1
dedupeEnabled: true
dedupeThreshold: 0.82
valueFilterEnabled: true
sync_to_tencentdb: false
- Restart the service:
Stop-Process -Name dsh -Force
dsh web --port 3080
After startup, the plugin loads successfully if a `[retrospect]` prefix appears in the logs.
Typical Usage¶
- In a coding task, if errors occur or solutions are rejected,
[retrospect] distilled trace=...appears in the logs after turn/end. - Search for
tags: type:rejected_solutionin the MemOS viewer to view the new trace. - Start a related coding task in the next round;
injected rejected_solution recallappears in the pre-step logs, and the model context contains<retrospect_context>.
Notes¶
- Distillation quality: Distillation quality depends on the LLM’s instruction-following capability. It is recommended that
distillMaxTokens >= 2048. - Memory latency: Memory writes occur at turn/end, so memories written in the current round can only be recalled in the next round.
- Task filtering: For non-coding tasks,
type:rejected_solutionmemories are not injected by default to prevent noise pollution (codingKeywordsis configurable). - Extension placeholder:
sync_to_tencentdbis a reserved extension and is not implemented in this release. - MemOS dependency: If MemOS is unavailable, the plugin fails open (it can still load, but memory read/write does not work).
- Data isolation: The plugin only performs logical processing. All persistence operations call MemOS interfaces, and it does not store data internally. Launching mneme child processes is prohibited.