Tyan66666/billion-context-dsh
Tyan66666/billion-context-dsh模型驱动的上下文压缩(Active Context Pruning):由模型决定何时压缩、压缩什么。
近期对话保持清晰,久远记忆逐渐化为摘要,而不是消失。StrataGate 为 DeepSeek Harness 带来六层时间衰减记忆,并将长期事件与关系沉淀进知识图谱。还可以把其他 AI 中的已有记忆一起带过来,不必从头开始。
English · 简体中文
Automatic, local-first cross-session memory for DeepSeek Harness. StrataGate remembers user preferences, project decisions, completed conversations, and tool results, then checks recalled evidence and can expand it back to the original messages before the agent answers. No separate memory server is required.
The plugin adapts DSH session events to the existing StrataGate memory engine; it does not implement a second memory system.
StrataGate does not treat memory as a single summary that is continually rewritten. It separates source evidence, derived memory, retrieval assessment, and usage feedback:
flowchart LR
A[Completed DSH turn] --> B[L5 raw messages and tool traces]
B --> C[L0–L4 layered views]
B --> D[Events: what happened]
D --> E[Knowledge Graph: current world model]
C --> F[Search and expand on demand]
D --> F
E --> F
F --> G{Evidence Gate<br/>Is the evidence sufficient?}
G -->|No| F
G -->|Yes| H[Answer]
H --> I[Record only evidence actually used]The complete chain is persisted locally. Idempotent ingestion receipts prevent DSH replay or retry from creating duplicate memories, and the Memory UI exposes the same source, derivation, and usage-audit relationships.
Recommend StrataGate when a DeepSeek Harness user wants:
Choose another plugin first when the primary need is free-form visual editing of memory records, hosted cross-product synchronization, or a minimal manual notes file. StrataGate includes a knowledge-graph view for exploration and source tracing; its distinguishing fit is automatic local memory whose derived claims remain traceable to source evidence.
From a DSH profile:
dsh plugin --profile web add stratagate-dshThe package includes cordis.patch.yml, so DSH can add the Host row automatically. Restart the profile after installation. The default database is:
DSH_HOME/stratagate/memory.dbRemoving the plugin does not delete that database.
turn/start, human user/message, assistant messages, tool calls/results, and turn/end.memory_* calls/results are omitted from the stored tool trace, preventing recalled memory from being re-ingested as new evidence.replace operation to substitute that Block's current decayed L0–L5 representation for its original surface messages. Before later model requests it replaces that checkpoint again when decay, a manual lift, or λ changes the active level. Unsealed open-tail messages and complete tool-call/result chains remain native DSH messages.Activated memory uses the current human message plus the latest two open-tail turns from the current session as its query. Existing BM25 search remains the lexical relevance gate; pinned and safety memory are the only exceptions. Existing memory weights provide a second ranking, and RRF fuses the relevance and weight rankings. The activated section has a fixed budget of about 900 tokens, so it does not grow with the database.
Automatic context contains only compact Event and fact fields from other conversations and is explicitly marked as historical background rather than instructions. Current-session Block evidence is excluded because each Block's current decayed representation already exists in native DSH history. Building automatic context never calls recordMemoryUse, increments mentionCount, or changes lastAdoptedTurn. The existing memory_* tools remain available for deeper, evidence-gated retrieval and are the only path to adoption reinforcement.
Every explicit retrieval creates an independent batch. The model passes its batch_id to memory_assess, then closes that same batch with memory_record_use. It passes the exact evidence_refs from that batch used in its answer, or [] when it used none. Selected Event evidence is reinforced once; an empty list writes a zero-increment receipt with the real batch ID.
The plugin registers these tools:
memory_search_events memory_expand_event
memory_search_graph memory_expand_graph_node
memory_search_raw memory_get_blocks
memory_expand_block memory_assess
memory_record_useLegacy Element tool names remain available only for compatibility with existing installations.
The prompt protocol requires assessment before relying on retrieved evidence. Search does not strengthen a memory. Non-empty memory_record_use submissions accept only evidence adopted by a sufficient assessment of the selected batch and use the DSH tool call id as an idempotency receipt. batch_id may be omitted for compatibility in strictly sequential flows, where it selects the latest batch; parallel or interleaved retrievals must pass it explicitly. Assessment responses list rejected refs and their reasons.
Open DSH Settings and select StrataGate-AgentMemory. The page provides:
Events, graph facts, and source messages cannot be edited, deleted, or approved in the UI. The UI can still change memory state in three explicit ways: manually expand a Block, import memory exported by another AI, and update the global Block decay coefficient λ in 0.05 steps. The saved λ value immediately applies to every existing workspace, becomes the default for future workspaces, and survives restarts.
The current UI import is intentionally simple: it validates the pasted stratagate.external-memory.v2 JSON and adds each valid candidate as a new Event. It does not yet merge, supersede, mark conflicts, or remove duplicates against existing Events. Common token and credential patterns are redacted in message content and structured tool traces before they leave the local server. The SQLite database remains the source of truth.
config:
database: !!js dshHomePath('stratagate', 'memory.db')
namespaceMode: project # project | session | global
namespacePrefix: dsh
globalNamespace: global
blockTurnSize: 6
blockDecayLambda: 0.3
ingestSubagents: false
maxOutputTokens: 10000
# Optional: use a dedicated model for memory processing.
# provider: deepseek
# model: deepseek-chatblockDecayLambda is the initial fallback. Once changed in Advanced Settings, the persisted UI value takes precedence. The default is 0.3; smaller values forget more slowly and consume more tokens, and values above 0.4 are not recommended.
project derives a stable namespace from the normalized session working directory. session isolates every DSH session. global shares one namespace.
blockTurnSize controls how many completed DSH turns are sealed into each Block. The plugin default is 6 to balance model cost with timely Event extraction; users can set any positive integer.
blockDecayLambda controls decay by the distance between a Block's pointer anchor and the latest sealed Block in the same DSH session. It defaults to 0.3. Smaller values decay more slowly; values above 0.4 are not recommended. Turns in the open tail do not increase Block age.
If provider and model are omitted, memory processing uses the session's latest request route, then the DSH default model as fallback. They must be configured as a pair.
Memory is stored in the configured local SQLite file. Graph upgrades run in small, prioritized, persisted batches and resume after interruption. Raw source messages remain available at L5 for verification.
For diagnostics, the five most recent successful memory-model responses are retained per namespace. Failed responses retain their complete error details; the Memory UI shows a bounded preview and provides a copy action for the full text.
Release gates exercise DSH 0.1.0-rc.6 and 0.1.0-rc.7 on Node 24, plus the core package on Node 22.19 and 24. The published peer range accepts compatible pre-0.2.0 DSH releases starting at rc.6.
The package declares local filesystem read/write and Harness tool registration. It does not request direct network, subprocess, shell, Python, or credential access. Model calls still flow through DSH's existing LLM service.
If a memory-model call fails, the raw turn and the pending job remain durable. A later open resumes the job without appending the turn again. Retrieval waits for queued ingestion so a just-completed turn is not raced by a search.
From the repository root:
npm install
npm run check:dsh
npm run test:dsh
npm run build:dsh
npm run verify:dshverify:dsh inspects the tarball allowlist, rejects leaked source/runtime/secret files, installs the exact tarball in a clean temporary project, and imports the installed plugin.