# Five-session Evolution [中文](README.md) · MIT · DeepSeek Harness plugin **Turn recurring project experience into lasting context: review every five distinct ended sessions, retain sourced lessons and workflow drafts, and bring project memory into later conversations.** Built for long-lived coding, debugging, documentation and other repeated project work. State is isolated by working directory and stored in DSH. Reviews follow the current DSH default model unless a provider and model are explicitly configured. No separate memory-service account is required. ## How it works ```text 5 distinct ended sessions in a workspace → durable queue → independent review Agent with no executable tools → structured-output and source-ID validation → project lessons + workflow drafts + review history → project lessons available in later root sessions ``` The default batch size is five, configurable from two to twenty. A session ID counts once per workspace, including across restarts and repeated closes. Child Agents, review runners and sessions marked as automation, subagent or goal are excluded. Each lesson and workflow draft must cite at least two different session IDs from the current batch. Validation checks structure and source membership; factual accuracy still requires checking project evidence. New lessons replace matching topics, and new drafts replace matching names. Defaults retain thirty lessons, twenty drafts and one hundred review summaries. Queued batches survive restarts. Failures retry after sixty and one hundred twenty seconds; the third failed attempt pauses the workspace's oldest batch until a manual retry. A Host runs one review at a time. Applying the result and removing its batch happen in one durable record write. A crash can cause a model review to run again, but an applied result is not applied twice. This improves context and reusable workflow knowledge. Model weights stay unchanged. Workflow candidates are stored as drafts; they require a separate evaluation and installation step. The plugin writes only its own storage domain. ## Installation and compatibility Version 0.1.0 targets **DSH 0.2.1-rc.5 and Node.js 22+**. It uses DSH Agent, preset, model, tools and storageDomain services. The package includes a composition patch mounting one Host plugin. Use the package/URL installation action in DSH plugin management with the v0.1.0 archive: ```text https://github.com/liuhuishang/dsh-five-session-evolution/releases/download/v0.1.0/dsh-five-session-evolution-0.1.0.tgz ``` [GitHub repository](https://github.com/liuhuishang/dsh-five-session-evolution) · [Release downloads](https://github.com/liuhuishang/dsh-five-session-evolution/releases/tag/v0.1.0) For clients supporting custom Discover sources, add this index under plugin management → Discover → Add index source: ```text https://raw.githubusercontent.com/liuhuishang/dsh-five-session-evolution/main/market-index.json ``` Refresh and search **Five-session Evolution**. The index pins its Git package source to a full 40-character commit. Adding this source enables discovery; acceptance into the public community catalog is a separate process. Use an installation source supported by your client. After installation, enable the `five-session-evolution` row and check its status tool. See [PUBLISHING.md](PUBLISHING.md) for maintenance and community listing steps. ## What counts as an ended session? The trigger is a root Agent's `agent/disposed` lifecycle event. Whether closing, switching or clearing a conversation triggers it depends on the client actually disposing that Agent. A completed answer, completed turn or idle UI does not count by itself. An eligible session contains nonempty user text and at least one `turn/end`. Failed or interrupted sessions can contribute lessons. Empty sessions are skipped. Collection starts with lifecycle events observed after activation; existing archives are not scanned retroactively. Deduplication uses workspace path and session ID. Moving a project or opening it through another symbolic-link path can produce a different partition. Hard process termination can lose an event that was not yet committed; normal shutdown is preferable. ## Configuration Edit the installed plugin row's `config`: ```yaml batchSize: 5 injectMemory: true timeoutMs: 300000 maxSessionChars: 12000 maxMemories: 30 maxCandidates: 20 maxAttempts: 3 provider: '' model: '' ``` | Option | Default | Behavior | | --- | --- | --- | | `batchSize` | 5 | Sessions per batch, 2–20; change after pending work completes | | `injectMemory` | true | Supply workspace lessons to root sessions; about 10,000 JSON characters | | `timeoutMs` | 300000 | Review deadline including creation, initialization and the model turn, ten seconds to thirty minutes | | `maxSessionChars` | 12000 | Tail of conversational text retained per session, 1,000–40,000 characters | | `maxMemories` | 30 | Maximum lessons, 1–100 | | `maxCandidates` | 20 | Maximum workflow drafts, 1–100 | | `maxAttempts` | 3 | Automatic attempts, 1–10 | | `provider` / `model` | empty | Both empty follow the DSH default; configure both to pin a route | Already queued batches keep their membership after configuration changes. Admission stops with a warning at one hundred thousand counted session hashes or one hundred queued batches per workspace, rather than discarding deduplication history. ## Status and retry Ask DSH to call: - `evolution_status`: counts, pending sessions, queue, sourced lessons, workflow drafts, summaries and the latest error. Retained transcript bodies are omitted. - `evolution_retry`: reset attempts on the oldest batch and schedule another review. Model token costs apply. Lessons are supplied through a dynamic system-prompt section as fallible reference data with source IDs. Draft workflows remain available through the status tool for evaluation and installation using the project's normal skill process. ## Data and model calls State lives in the `five_session_evolution` storageDomain, table `workspaces`. The Host controls its physical location and backup policy. Pending batches retain text excerpts, session IDs, timestamps and preset names. Tool output, hidden reasoning and images are omitted. Personal information in conversational text may remain. Common token formats, Authorization values, password-like fields and private-key blocks receive best-effort redaction; this does not guarantee removal of every secret. A review sends the batch excerpts and existing memory to the selected DSH model provider and incurs model costs. A normal review is one model turn; provider retries and failed-review retries may add requests. After a successful commit, this plugin removes the batch excerpts from its record. Original DSH logs, review-Agent logs and backups follow Host retention settings. The review Agent hides tool schemas and blocks tool execution. The plugin validates JSON before persisting its own records. One writing Host per storage backend is supported; concurrent processes writing the same backend have not been validated. Unloading stops work and closes the domain handle; durable data remains Host-managed. ## Development Install dependencies matching the target DSH release, then run: ```sh npm run check npm test npm pack --dry-run ``` Tests cover batching, deduplication, isolation, queue recovery, failed-review retention, evidence IDs, tool isolation and real Cordis load/unload. Model responses use fixtures. Live model and desktop lifecycle acceptance should be performed after installation. See [PUBLISHING.md](PUBLISHING.md) for release instructions.