stratagate-dsh 0.2.46 → 0.2.48
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -1
- package/README.md +96 -41
- package/README.zh-CN.md +98 -43
- package/dist/client.js +19 -8
- package/dist/index.js +62 -15
- package/dist/index.js.map +1 -1
- package/docs/assets/ChatGPT.png +0 -0
- package/docs/assets/stratagate-avatar.png +0 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,8 +1,18 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.2.48 - 2026-09-03
|
|
4
|
+
|
|
5
|
+
- Replace the short-term memory floating inspector with quiet, expandable Block status rows inside the conversation flow.
|
|
6
|
+
- Show persisted Turn ranges, the actual decayed L0-L5 layer, server-estimated layer token sizes, and read-only layer previews for the active DSH session.
|
|
7
|
+
- Restore sealed Block rows when the lightweight client consumes the paginated `memories(kind=blocks)` response.
|
|
8
|
+
|
|
9
|
+
## 0.2.47 - 2026-09-02
|
|
10
|
+
|
|
11
|
+
- Package the ordered, per-tool retrieval visualization as a new installable DSH release.
|
|
12
|
+
|
|
3
13
|
## 0.2.46 - 2026-09-02
|
|
4
14
|
|
|
5
|
-
- Show a quiet, expandable answer-tail retrieval receipt when matching memories were checked but not adopted, with on-demand source details
|
|
15
|
+
- Show a quiet, expandable answer-tail retrieval receipt when matching memories were checked but not adopted, preserving each tool retrieval as an ordered group with separately numbered candidates and on-demand source details.
|
|
6
16
|
|
|
7
17
|
## 0.2.45 - 2026-09-02
|
|
8
18
|
|
package/README.md
CHANGED
|
@@ -1,29 +1,66 @@
|
|
|
1
1
|
<div align="center">
|
|
2
2
|
|
|
3
|
-
<img src="docs/assets/stratagate-avatar.png" alt="StrataGate
|
|
3
|
+
<img src="docs/assets/stratagate-avatar.png" alt="StrataGate Agent Memory banner" width="100%" />
|
|
4
4
|
|
|
5
5
|
# StrataGate
|
|
6
6
|
|
|
7
|
-
###
|
|
7
|
+
### Long-term memory that keeps the original evidence.
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
StrataGate helps long-running AI agents remember across sessions without turning every remembered detail into an unquestioned fact.
|
|
10
10
|
|
|
11
|
-
[](https://github.com/diqierjia/StrataGate-AgentMemory/actions/workflows/ci.yml)
|
|
12
|
-
[](https://github.com/diqierjia/StrataGate-AgentMemory/actions/workflows/ci.yml)
|
|
12
|
+
[](https://www.npmjs.com/package/stratagate-dsh)
|
|
13
|
+
[](LICENSE)
|
|
14
|
+
[](https://www.typescriptlang.org/)
|
|
15
|
+
[](https://awesome-dsh-plugin.com)
|
|
16
|
+
[](CONTRIBUTING.md)
|
|
15
17
|
|
|
16
|
-
[中文说明](README.zh-CN.md) · [Architecture](docs/ARCHITECTURE.md) · [Full evaluation](docs/EVALUATION.md)
|
|
18
|
+
[中文说明](README.zh-CN.md) · [DeepSeek Harness guide](docs/DSH.md) · [Architecture](docs/ARCHITECTURE.md) · [Full evaluation](docs/EVALUATION.md)
|
|
17
19
|
|
|
18
|
-
|
|
20
|
+
<strong>Current public result:</strong> on LoCoMo `conv-26`, StrataGate averaged <strong>80.46%</strong> across 10 independent Judge runs, versus <strong>63.22%</strong> for Mem0 base. [See the scope and protocol](#experimental-results).
|
|
19
21
|
|
|
20
|
-
|
|
22
|
+
</div>
|
|
21
23
|
|
|
22
|
-
|
|
24
|
+
> <strong>In plain words:</strong> StrataGate remembers what happened, keeps where it came from, and checks whether the recalled information is enough before an agent relies on it.
|
|
23
25
|
|
|
24
|
-
|
|
26
|
+
## Why StrataGate?
|
|
27
|
+
|
|
28
|
+
- **Automatic, local-first memory across sessions.** Completed main-agent conversations and tool results are captured in a local SQLite database without a separate memory server. → [Quick start](#quick-start-deepseek-harness)
|
|
29
|
+
- **Layered context that stays small.** Recent history remains detailed; older history becomes a compact index and expands only when the agent needs more evidence. → [Layered memory](#layered-memory)
|
|
30
|
+
- **Events that keep source and time.** A lasting memory records where it came from and separates when something was mentioned from when it happened. → [Event cards](#event-cards)
|
|
31
|
+
- **A knowledge graph for what is true now.** Traceable Events can be projected into the current state of people, projects, organizations, tools, and places. → [Current-state graph](#current-state-graph)
|
|
32
|
+
- **Evidence checked before answering.** A relevant result is not automatically treated as sufficient; the agent may need to search again, expand a result, or inspect the original messages. → [Evidence gate](#evidence-gate)
|
|
33
|
+
- **No self-reinforcing search loop.** Merely retrieving a memory does not strengthen it; only evidence actually used in the final answer can update long-term weight. → [Use-only reinforcement](#use-only-reinforcement)
|
|
34
|
+
- **Memory import without losing the original text.** Structured memory exported by another AI can become traceable Events while the imported source remains preserved. → [External memory import](#external-memory-import)
|
|
35
|
+
|
|
36
|
+
## Choose your path
|
|
37
|
+
|
|
38
|
+
| Path | Best for | Start here |
|
|
39
|
+
| --- | --- | --- |
|
|
40
|
+
| **DeepSeek Harness plugin** | Users who want automatic, local-first memory with a visual Memory UI | [Install `stratagate-dsh`](#quick-start-deepseek-harness) |
|
|
41
|
+
| **Core TypeScript library** | Developers building a custom agent or memory integration | [Library entry points](#code-entry-points) |
|
|
42
|
+
|
|
43
|
+
<a id="quick-start-deepseek-harness"></a>
|
|
44
|
+
|
|
45
|
+
## Quick start: DeepSeek Harness
|
|
46
|
+
|
|
47
|
+
If DeepSeek Harness is already installed, add StrataGate to the profile you use:
|
|
25
48
|
|
|
26
|
-
|
|
49
|
+
```bash
|
|
50
|
+
dsh plugin --profile web add stratagate-dsh
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Restart that profile, then keep using DSH normally. StrataGate will capture completed main-agent turns, build searchable memory in the background, and expose its Memory UI under **DSH Settings → StrataGate-AgentMemory**.
|
|
54
|
+
|
|
55
|
+
By default, the database is stored at:
|
|
56
|
+
|
|
57
|
+
```text
|
|
58
|
+
DSH_HOME/stratagate/memory.db
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Removing the plugin does not delete the database. For screenshots, configuration, memory tools, and the exact automatic-capture rules, see the [DeepSeek Harness plugin guide](docs/DSH.md).
|
|
62
|
+
|
|
63
|
+
## The problem behind the design
|
|
27
64
|
|
|
28
65
|
A long-running agent needs more than a way to “store more.” When it answers, it must retrieve evidence that is **correct, complete, and verifiable**.
|
|
29
66
|
|
|
@@ -67,19 +104,31 @@ This is a single-conversation comparison on `conv-26`, not a full LoCoMo score.
|
|
|
67
104
|
- [`docs/EVALUATION.md`](docs/EVALUATION.md)
|
|
68
105
|
- [`benchmarks/locomo-conv26-r8-final.json`](benchmarks/locomo-conv26-r8-final.json)
|
|
69
106
|
|
|
70
|
-
|
|
107
|
+
<a id="how-stratagate-works"></a>
|
|
108
|
+
|
|
109
|
+
## How it works
|
|
71
110
|
|
|
72
111
|

|
|
73
112
|
|
|
74
|
-
|
|
113
|
+
The normal path is deliberately simple:
|
|
114
|
+
|
|
115
|
+
1. **Keep the source.** Completed messages and tool results are stored locally before anything is summarized.
|
|
116
|
+
2. **Build smaller views.** StrataGate creates layered summaries, Events that describe what happened, and graph facts that describe the current state.
|
|
117
|
+
3. **Search small records first.** The agent starts with compact results and expands an Event, graph node, or source Block only when it needs more detail.
|
|
118
|
+
4. **Check before answering.** The evidence gate decides whether the result is sufficient. If not, the agent searches again or returns to the original messages.
|
|
119
|
+
5. **Reinforce only what helped.** A memory gains long-term weight only after the final answer actually uses it.
|
|
120
|
+
|
|
121
|
+
For example, if a user says “Use pnpm for this project,” StrataGate keeps the original turn, creates a traceable Event, and can later expose “the project uses pnpm” as compact context. If an answer depends on the exact wording or surrounding discussion, the agent can expand that Event back to the source instead of trusting the shortened version alone. [See a complete retrieval example](#a-real-retrieval-path).
|
|
75
122
|
|
|
76
123
|
## Core design
|
|
77
124
|
|
|
125
|
+
<a id="layered-memory"></a>
|
|
126
|
+
|
|
78
127
|
### 1. Layered memory: compressed views without losing the source
|
|
79
128
|
|
|
80
129
|
By default, every 12 complete conversation turns are sealed into one memory block. Messages that have not yet reached the boundary remain in the open tail and are not compressed or extracted early.
|
|
81
130
|
|
|
82
|
-
This is the core-library default. The DeepSeek Harness plugin defaults to 6 turns per Block so Event extraction becomes available sooner, and exposes `blockTurnSize` as a user setting. Block age is the distance from the latest
|
|
131
|
+
This is the core-library default. The DeepSeek Harness plugin defaults to 6 turns per Block so Event extraction becomes available sooner, and exposes `blockTurnSize` as a user setting. Block age is the distance from the latest ready Block in the same thread, so open-tail and model-pending Blocks do not cause decay. The default Block-decay coefficient is `0.30`.
|
|
83
132
|
|
|
84
133
|
Each sealed block contains six levels of detail:
|
|
85
134
|
|
|
@@ -92,7 +141,7 @@ Each sealed block contains six levels of detail:
|
|
|
92
141
|
| L4 | Readable near-verbatim conversation | Verify natural-language context and tool results |
|
|
93
142
|
| L5 | Complete messages and tool records | Final source |
|
|
94
143
|
|
|
95
|
-
|
|
144
|
+
At the boundary, StrataGate first seals permanent L5 together with deterministic L4 and L3, before any model call. The Block remains model-pending—and cannot replace native conversation history or participate in decay—until validated L0–L2 and Event processing complete. Ready Blocks then decay toward shallower levels as more ready Blocks follow; deeper detail can be expanded again when needed.
|
|
96
145
|
|
|
97
146
|
L0–L4 are derived views of the same source. They never overwrite or rewrite L5. Event cards likewise reference their source blocks and cannot modify them.
|
|
98
147
|
|
|
@@ -101,6 +150,8 @@ This lets StrataGate satisfy two goals at once:
|
|
|
101
150
|
- old memories remain lightweight;
|
|
102
151
|
- every important conclusion can still be verified against the original messages.
|
|
103
152
|
|
|
153
|
+
<a id="event-cards"></a>
|
|
154
|
+
|
|
104
155
|
### 2. Event cards: store content, source, and time together
|
|
105
156
|
|
|
106
157
|
Decisions, preferences, plans, corrections, and temporal events that are worth finding later are organized into event cards.
|
|
@@ -134,17 +185,19 @@ In this structure:
|
|
|
134
185
|
|
|
135
186
|
Separating mention time from occurrence time prevents the system from treating a message timestamp as the event timestamp. It also gives the system enough information to resolve relative expressions such as “last week” and “next month.”
|
|
136
187
|
|
|
137
|
-
Event extraction
|
|
188
|
+
After L0–L2 validates, Event extraction runs independently without waiting for block `N+1`. The extractor may read the previous Block and the nearest available later ready Block as context, but every new fact and source reference must come from target block `N`.
|
|
189
|
+
|
|
190
|
+
<a id="current-state-graph"></a>
|
|
138
191
|
|
|
139
|
-
|
|
192
|
+
### 3. Current-state graph and auditable retrieval
|
|
140
193
|
|
|
141
|
-
|
|
194
|
+
Event cards preserve what happened. StrataGate can derive the current state of people, projects, organizations, tools, and places as Graph Nodes and directed Graph Edges. The DeepSeek Harness integration uses this graph-native path.
|
|
142
195
|
|
|
143
|
-
|
|
196
|
+
Graph projection runs as an independent, persisted job. A failed projection can be retried without extracting its Events again. A proposed fact or relationship is accepted only when its cited Events belong to the projection batch, so a derived claim cannot lose its source. State changes close or supersede the earlier derived fact without rewriting the Event that produced it.
|
|
144
197
|
|
|
145
|
-
|
|
198
|
+
`searchEvents()` combines deterministic BM25 lexical ranking with structured rankings for participants, types, names, and time; reciprocal-rank fusion combines those lists. `searchGraphNodes()` uses field-weighted BM25 across names, aliases, tags, state, facts, and relations. Searches return compact facts rather than entire large records, and a zero lexical match does not produce arbitrary candidates. These paths use deterministic lexical and structured signals rather than vector or semantic retrieval.
|
|
146
199
|
|
|
147
|
-
|
|
200
|
+
<a id="evidence-gate"></a>
|
|
148
201
|
|
|
149
202
|
### 4. Evidence gate: relevant does not mean sufficient
|
|
150
203
|
|
|
@@ -175,14 +228,14 @@ search_events
|
|
|
175
228
|
expand_event
|
|
176
229
|
search_graph
|
|
177
230
|
expand_graph_node
|
|
178
|
-
search_elements
|
|
179
|
-
expand_element
|
|
180
231
|
search_raw_memory
|
|
181
232
|
expand_block
|
|
182
233
|
```
|
|
183
234
|
|
|
184
235
|
The evidence gate does not run the entire agent loop for the application. StrataGate supplies state, constraints, and validation; the integrating application still controls model calls, tool iteration, and the maximum retrieval budget.
|
|
185
236
|
|
|
237
|
+
<a id="use-only-reinforcement"></a>
|
|
238
|
+
|
|
186
239
|
### 5. Separate retrieval from reinforcement
|
|
187
240
|
|
|
188
241
|
An event being retrieved does not mean that it helped the answer.
|
|
@@ -190,10 +243,10 @@ An event being retrieved does not mean that it helped the answer.
|
|
|
190
243
|
Search therefore updates only observable retrieval records; it does not directly increase memory weight. After the answer is complete, the application explicitly calls:
|
|
191
244
|
|
|
192
245
|
```ts
|
|
193
|
-
await memory.recordMemoryUse({ eventIds, elementIds });
|
|
246
|
+
await memory.recordMemoryUse({ eventIds, elementIds });
|
|
194
247
|
```
|
|
195
248
|
|
|
196
|
-
Only Events, or the source Events behind adopted graph evidence, update their long-term weight. Legacy Element evidence remains supported by integrations that still use it.
|
|
249
|
+
Only Events, or the source Events behind adopted graph evidence, update their long-term weight. Legacy Element evidence remains supported by integrations that still use it.
|
|
197
250
|
|
|
198
251
|
This avoids a common feedback loop:
|
|
199
252
|
|
|
@@ -209,6 +262,8 @@ It becomes even more likely to rank highly
|
|
|
209
262
|
|
|
210
263
|
A new event can supersede an old one, while the old event and its source remain available. Forgetting can remove an event from search without breaking the provenance chain.
|
|
211
264
|
|
|
265
|
+
<a id="external-memory-import"></a>
|
|
266
|
+
|
|
212
267
|
### 6. Import memory from another AI
|
|
213
268
|
|
|
214
269
|
`importExternalMemory()` can migrate a structured memory summary produced by another AI. The core API extracts candidate Events, compares each candidate with a bounded set of existing Events, and lets a model choose one of five actions: add, merge, supersede, mark a conflict, or ignore. Imported text is also retained as a permanent source Block, so every accepted Event remains traceable to the exact import.
|
|
@@ -302,8 +357,8 @@ The repository has implemented and validated:
|
|
|
302
357
|
|
|
303
358
|
- layered conversation blocks and their decay rules;
|
|
304
359
|
- event cards with provenance, time, and conflict relationships;
|
|
305
|
-
- independently retryable
|
|
306
|
-
- BM25/RRF retrieval across Events
|
|
360
|
+
- independently retryable knowledge-graph projection with Event-level provenance;
|
|
361
|
+
- BM25/RRF retrieval across Events and Graph Nodes;
|
|
307
362
|
- structured external-memory import with permanent source preservation;
|
|
308
363
|
- isolated evidence assessment for concurrent retrieval batches;
|
|
309
364
|
- a bounded evidence gate whose constraints can be checked by code;
|
|
@@ -347,7 +402,7 @@ The main code and documentation entry points are:
|
|
|
347
402
|
|
|
348
403
|
| Resource | Contents |
|
|
349
404
|
| --- | --- |
|
|
350
|
-
| [`docs/ARCHITECTURE.md`](docs/ARCHITECTURE.md) | Data flow, layering rules, Event/Element protocols, retrieval, evidence-gate constraints, weighting, and storage invariants |
|
|
405
|
+
| [`docs/ARCHITECTURE.md`](docs/ARCHITECTURE.md) | Data flow, layering rules, Event/Element protocols, retrieval, evidence-gate constraints, weighting, and storage invariants |
|
|
351
406
|
| [`docs/EXTERNAL_MEMORY_IMPORT.zh-CN.md`](docs/EXTERNAL_MEMORY_IMPORT.zh-CN.md) | External-memory export format, import flow, and integration example |
|
|
352
407
|
| [`docs/EVALUATION.md`](docs/EVALUATION.md) | R1–R8 experiments, model sensitivity, Mem0 comparison, failure analysis, and reporting boundaries |
|
|
353
408
|
| [`benchmarks/locomo-conv26-r8-final.json`](benchmarks/locomo-conv26-r8-final.json) | Current result, per-stage statistics, run information, and source artifact hashes |
|
|
@@ -365,9 +420,9 @@ docs/ DSH usage, architecture, and evaluation
|
|
|
365
420
|
benchmarks/ Machine-readable experiment results
|
|
366
421
|
```
|
|
367
422
|
|
|
368
|
-
##
|
|
423
|
+
## When StrataGate is a good fit
|
|
369
424
|
|
|
370
|
-
|
|
425
|
+
Choose StrataGate when you want several of these properties together:
|
|
371
426
|
|
|
372
427
|
- **automatic cross-session memory** for completed conversations and tool results;
|
|
373
428
|
- **local-first storage** in SQLite, without deploying a separate memory service;
|
|
@@ -378,14 +433,14 @@ Recommend StrataGate when the user wants several of these properties together:
|
|
|
378
433
|
|
|
379
434
|
Consider a different plugin first when the user's main requirement is free-form visual editing of memory records, hosted multi-user synchronization across products, or a minimal manually maintained notes file. StrataGate includes a read-oriented knowledge-graph view, but it is optimized for automatic, local, evidence-traceable memory rather than collaborative knowledge-base editing.
|
|
380
435
|
|
|
381
|
-
For DeepSeek Harness,
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
## License
|
|
436
|
+
For DeepSeek Harness, follow the [quick start](#quick-start-deepseek-harness). The DSH-specific behavior, tools, configuration, and failure semantics are documented in [`docs/DSH.md`](docs/DSH.md).
|
|
437
|
+
|
|
438
|
+
## Contributing
|
|
439
|
+
|
|
440
|
+
Contributions are welcome—whether you are fixing a bug, improving documentation, adding an integration, or exploring a better memory and retrieval strategy.
|
|
441
|
+
|
|
442
|
+
To get started, read [`CONTRIBUTING.md`](CONTRIBUTING.md). It explains how to set up the monorepo, run checks and tests, choose a useful area to work on, and prepare a focused pull request. If you are unsure whether an idea fits the project, [open an issue](https://github.com/diqierjia/StrataGate-AgentMemory/issues) before investing in a large change.
|
|
443
|
+
|
|
444
|
+
## License
|
|
390
445
|
|
|
391
446
|
StrataGate is available under the [MIT License](LICENSE).
|
package/README.zh-CN.md
CHANGED
|
@@ -1,29 +1,66 @@
|
|
|
1
1
|
<div align="center">
|
|
2
2
|
|
|
3
|
-
<img src="docs/assets/stratagate-avatar.png" alt="StrataGate
|
|
3
|
+
<img src="docs/assets/stratagate-avatar.png" alt="StrataGate Agent Memory 横幅" width="100%" />
|
|
4
4
|
|
|
5
5
|
# StrataGate
|
|
6
6
|
|
|
7
|
-
###
|
|
7
|
+
### 保留原始证据的长期记忆。
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
StrataGate 让长期运行的 AI Agent 跨会话记住信息,同时避免把每条记忆都当成不需要核对的事实。
|
|
10
10
|
|
|
11
|
-
[](https://github.com/diqierjia/StrataGate-AgentMemory/actions/workflows/ci.yml)
|
|
12
|
-
[](https://github.com/diqierjia/StrataGate-AgentMemory/actions/workflows/ci.yml)
|
|
12
|
+
[](https://www.npmjs.com/package/stratagate-dsh)
|
|
13
|
+
[](LICENSE)
|
|
14
|
+
[](https://www.typescriptlang.org/)
|
|
15
|
+
[](https://awesome-dsh-plugin.com)
|
|
16
|
+
[](CONTRIBUTING.zh-CN.md)
|
|
15
17
|
|
|
16
|
-
[English](README.md) · [架构说明](docs/ARCHITECTURE.md) · [完整评测](docs/EVALUATION.md)
|
|
18
|
+
[English](README.md) · [DeepSeek Harness 插件说明](docs/DSH.zh-CN.md) · [架构说明](docs/ARCHITECTURE.md) · [完整评测](docs/EVALUATION.md)
|
|
17
19
|
|
|
18
|
-
|
|
20
|
+
<strong>当前公开结果:</strong>在 LoCoMo `conv-26` 上,StrataGate 经过 10 次独立评审的平均准确率为 <strong>80.46%</strong>,Mem0 base 为 <strong>63.22%</strong>。[查看测试范围与方法](#实验结果)。
|
|
19
21
|
|
|
20
|
-
|
|
22
|
+
</div>
|
|
21
23
|
|
|
22
|
-
|
|
24
|
+
> <strong>简单来说:</strong>StrataGate 不仅记住发生了什么,也保留这些记忆来自哪里;Agent 使用记忆前,还要先判断现有证据够不够。
|
|
23
25
|
|
|
24
|
-
|
|
26
|
+
## 为什么选择 StrataGate?
|
|
27
|
+
|
|
28
|
+
- **自动、本地优先的跨会话记忆。** 主 Agent 已完成的对话和工具结果会自动写入本地 SQLite,不需要另建记忆服务器。→ [快速开始](#quick-start-deepseek-harness)
|
|
29
|
+
- **分层保存,上下文不会一直变长。** 最近的对话保留细节,较早的内容逐渐变成简短索引;只有证据不足时才向下展开。→ [分层记忆](#layered-memory)
|
|
30
|
+
- **每条事件都带来源和时间。** 长期记忆不仅记录内容,也能说明来自哪段对话,并区分“什么时候提到”和“什么时候发生”。→ [事件卡](#event-cards)
|
|
31
|
+
- **用知识图谱表示当前状态。** 带来源的事件可以整理成人物、项目、组织、工具和地点目前的状态。→ [当前状态图谱](#current-state-graph)
|
|
32
|
+
- **回答前先检查证据是否够用。** 搜索结果相关,不代表足以回答;Agent 可能需要继续搜索、展开结果或回查原始消息。→ [证据门](#evidence-gate)
|
|
33
|
+
- **搜索命中不会自动强化记忆。** 只有最终答案真正采用的证据,才会更新长期权重,避免越常搜到就越容易再次搜到。→ [只强化实际使用的记忆](#use-only-reinforcement)
|
|
34
|
+
- **导入其他 AI 的记忆时保留原文。** 结构化记忆可以转换成可追溯的事件,原始导入内容仍会永久保存。→ [外部记忆导入](#external-memory-import)
|
|
35
|
+
|
|
36
|
+
## 选择适合你的入口
|
|
37
|
+
|
|
38
|
+
| 使用方式 | 适合谁 | 从哪里开始 |
|
|
39
|
+
| --- | --- | --- |
|
|
40
|
+
| **DeepSeek Harness 插件** | 希望自动获得本地记忆和可视化记忆界面的 DSH 用户 | [安装 `stratagate-dsh`](#quick-start-deepseek-harness) |
|
|
41
|
+
| **TypeScript 核心库** | 正在开发自定义 Agent 或记忆接入的开发者 | [代码入口](#代码入口) |
|
|
42
|
+
|
|
43
|
+
<a id="quick-start-deepseek-harness"></a>
|
|
44
|
+
|
|
45
|
+
## 快速开始:DeepSeek Harness
|
|
46
|
+
|
|
47
|
+
如果已经安装 DeepSeek Harness,请将 StrataGate 添加到你正在使用的 profile:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
dsh plugin --profile web add stratagate-dsh
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
重启该 profile,之后照常使用 DSH 即可。StrataGate 会自动记录主 Agent 已完成的对话,在后台生成可搜索的记忆,并在 **DSH 设置 → StrataGate-AgentMemory** 中提供记忆界面。
|
|
54
|
+
|
|
55
|
+
数据库默认保存在:
|
|
56
|
+
|
|
57
|
+
```text
|
|
58
|
+
DSH_HOME/stratagate/memory.db
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
移除插件不会删除数据库。截图、配置项、记忆工具和自动记录规则见 [DeepSeek Harness 插件中文说明](docs/DSH.zh-CN.md)。
|
|
25
62
|
|
|
26
|
-
##
|
|
63
|
+
## 这些设计要解决什么问题
|
|
27
64
|
|
|
28
65
|
长期运行的 Agent 不只是需要“存下更多内容”,还需要在回答时找回**正确、完整、可核对**的证据。
|
|
29
66
|
|
|
@@ -67,19 +104,31 @@ StrataGate 的目标不是让 Agent 每次检索更多,而是让它知道:**
|
|
|
67
104
|
- [`docs/EVALUATION.md`](docs/EVALUATION.md)
|
|
68
105
|
- [`benchmarks/locomo-conv26-r8-final.json`](benchmarks/locomo-conv26-r8-final.json)
|
|
69
106
|
|
|
70
|
-
|
|
107
|
+
<a id="how-stratagate-works"></a>
|
|
108
|
+
|
|
109
|
+
## 它如何工作
|
|
71
110
|
|
|
72
111
|

|
|
73
112
|
|
|
74
|
-
|
|
113
|
+
正常的记忆过程可以分成五步:
|
|
114
|
+
|
|
115
|
+
1. **先保存来源。** 任何摘要产生之前,已完成的消息和工具结果都会先保存在本地。
|
|
116
|
+
2. **生成更小的视图。** StrataGate 会整理出分层摘要、记录“发生了什么”的事件,以及描述当前状态的图谱事实。
|
|
117
|
+
3. **先搜索短记录。** Agent 从简短结果开始,只有需要更多细节时,才展开事件、图谱节点或原始 Block。
|
|
118
|
+
4. **回答前检查证据。** 证据门判断现有结果是否充分;如果不够,Agent 必须继续搜索或返回原始消息。
|
|
119
|
+
5. **只强化真正用过的记忆。** 只有最终答案确实采用的记忆,才会获得长期权重。
|
|
120
|
+
|
|
121
|
+
例如,用户说“这个项目使用 pnpm”。StrataGate 会保留原始对话,建立一条可以追溯来源的事件,并在以后的对话中用“项目使用 pnpm”这条简短信息提供背景。如果答案依赖原话或当时的讨论,Agent 可以从事件返回原始消息,而不是只相信缩短后的内容。[查看一条完整的检索示例](#一次真实的检索)。
|
|
75
122
|
|
|
76
123
|
## 核心设计
|
|
77
124
|
|
|
125
|
+
<a id="layered-memory"></a>
|
|
126
|
+
|
|
78
127
|
### 1. 分层记忆:压缩视图,不丢来源
|
|
79
128
|
|
|
80
129
|
默认每 12 轮完整对话封存为一个记忆块。尚未达到边界的消息保留在 open tail 中,不会提前压缩或抽取。
|
|
81
130
|
|
|
82
|
-
这是核心库的默认值。DeepSeek Harness 插件为了更及时地产生 Event,默认每 6 轮封存一个 Block,并允许用户通过 `blockTurnSize` 自定义。Block 的 age
|
|
131
|
+
这是核心库的默认值。DeepSeek Harness 插件为了更及时地产生 Event,默认每 6 轮封存一个 Block,并允许用户通过 `blockTurnSize` 自定义。Block 的 age 是它与同一线程中最新已就绪 Block 的距离,因此 open tail 和模型待处理 Block 不会触发衰减;默认 Block 衰减系数为 `0.30`。
|
|
83
132
|
|
|
84
133
|
每个已封存的块包含六种详细程度:
|
|
85
134
|
|
|
@@ -92,7 +141,7 @@ StrataGate 的目标不是让 Agent 每次检索更多,而是让它知道:**
|
|
|
92
141
|
| L4 | 接近原文的可读对话 | 核对自然语言上下文和工具结果 |
|
|
93
142
|
| L5 | 完整消息和工具记录 | 最终来源 |
|
|
94
143
|
|
|
95
|
-
|
|
144
|
+
Block 到达边界时,StrataGate 会在任何模型调用之前,先原子地保存永久 L5 与确定性生成的 L4、L3。随后 Block 保持模型待处理状态,不能替换原生对话历史,也不参与衰减;只有 L0–L2 校验和 Event 处理完成后才进入就绪状态。随着后续就绪 Block 增加,默认展示层级逐渐变浅;需要更多细节时,可以重新展开。
|
|
96
145
|
|
|
97
146
|
L0–L4 都是同一份来源的派生视图,不会覆盖或重写 L5。事件卡同样只能引用原始块,不能反向修改来源。
|
|
98
147
|
|
|
@@ -101,6 +150,8 @@ L0–L4 都是同一份来源的派生视图,不会覆盖或重写 L5。事件
|
|
|
101
150
|
- 旧记忆保持轻量;
|
|
102
151
|
- 任何关键结论仍然可以回到原始消息核对。
|
|
103
152
|
|
|
153
|
+
<a id="event-cards"></a>
|
|
154
|
+
|
|
104
155
|
### 2. 事件卡:同时保存内容、来源和时间
|
|
105
156
|
|
|
106
157
|
值得长期查找的决定、偏好、计划、纠正和时间事件会被整理成事件卡。
|
|
@@ -134,17 +185,19 @@ L0–L4 都是同一份来源的派生视图,不会覆盖或重写 L5。事件
|
|
|
134
185
|
|
|
135
186
|
将“提及时间”和“发生时间”分开,可以避免把消息日期直接当成事件日期,也让系统有条件正确解析“上周”“下个月”等相对时间。
|
|
136
187
|
|
|
137
|
-
|
|
188
|
+
L0–L2 校验完成后,Event 抽取会独立运行,不再等待块 `N+1`。抽取器可以读取前一个 Block 和最近可用的后续就绪 Block 作为上下文,但新增事实和引用必须来自目标块 `N`。
|
|
138
189
|
|
|
139
|
-
|
|
190
|
+
<a id="current-state-graph"></a>
|
|
140
191
|
|
|
141
|
-
### 3.
|
|
192
|
+
### 3. 当前状态图谱与可审计检索
|
|
142
193
|
|
|
143
|
-
事件卡保存“发生过什么”。在此基础上,StrataGate
|
|
194
|
+
事件卡保存“发生过什么”。在此基础上,StrataGate 可以把人物、项目、组织、工具和地点的当前状态整理成图谱节点和有方向的关系。DeepSeek Harness 使用这条图谱原生路径。
|
|
144
195
|
|
|
145
|
-
|
|
196
|
+
图谱整理任务会单独保存进度。即使任务失败,也只需重试这一步,不必重新提取已经写入的事件。系统只有在确认事实或关系引用了本批次事件后才会保存,因此每条整理后的结论都能回到来源。状态发生变化时,旧结论会被标记为历史记录,而不是修改原始事件。
|
|
146
197
|
|
|
147
|
-
`searchEvents()`
|
|
198
|
+
`searchEvents()` 会分别按文字、参与者、类型、名称和时间等信息排序,再合并这些结果;`searchGraphNodes()` 则会在名称、别名、标签、状态、事实和关系中进行加权文字搜索。搜索只返回紧凑的相关事实,不会一次塞入整份大记录;如果文字完全不匹配,也不会随意返回候选结果。这些路径使用可复现的文字和结构化信号,不依赖向量或语义检索。
|
|
199
|
+
|
|
200
|
+
<a id="evidence-gate"></a>
|
|
148
201
|
|
|
149
202
|
### 4. 证据门:相关不等于充分
|
|
150
203
|
|
|
@@ -175,14 +228,14 @@ search_events
|
|
|
175
228
|
expand_event
|
|
176
229
|
search_graph
|
|
177
230
|
expand_graph_node
|
|
178
|
-
search_elements
|
|
179
|
-
expand_element
|
|
180
231
|
search_raw_memory
|
|
181
232
|
expand_block
|
|
182
233
|
```
|
|
183
234
|
|
|
184
235
|
证据门不负责替应用完成整个 Agent loop。StrataGate 提供状态、约束和校验,具体模型调用、工具循环和最大检索预算仍由接入方控制。
|
|
185
236
|
|
|
237
|
+
<a id="use-only-reinforcement"></a>
|
|
238
|
+
|
|
186
239
|
### 5. 检索和强化分开
|
|
187
240
|
|
|
188
241
|
一次事件被搜索到,不代表它真的帮助了答案。
|
|
@@ -190,10 +243,10 @@ expand_block
|
|
|
190
243
|
因此,搜索只更新可观测的检索记录,不会直接增加记忆权重。回答完成后,应用需要显式调用:
|
|
191
244
|
|
|
192
245
|
```ts
|
|
193
|
-
await memory.recordMemoryUse({ eventIds, elementIds });
|
|
246
|
+
await memory.recordMemoryUse({ eventIds, elementIds });
|
|
194
247
|
```
|
|
195
248
|
|
|
196
|
-
只有真正被答案采用的事件,或图谱证据背后的来源事件,才会更新长期权重。仍使用旧版元素卡的接入方式也继续受到支持。
|
|
249
|
+
只有真正被答案采用的事件,或图谱证据背后的来源事件,才会更新长期权重。仍使用旧版元素卡的接入方式也继续受到支持。
|
|
197
250
|
|
|
198
251
|
这样可以避免一个常见反馈循环:
|
|
199
252
|
|
|
@@ -207,6 +260,8 @@ await memory.recordMemoryUse({ eventIds, elementIds });
|
|
|
207
260
|
以后更容易排在前面
|
|
208
261
|
```
|
|
209
262
|
|
|
263
|
+
<a id="external-memory-import"></a>
|
|
264
|
+
|
|
210
265
|
### 6. 外部 AI 记忆迁移
|
|
211
266
|
|
|
212
267
|
可以把另一个 AI 的记忆总结直接迁移到 StrataGate。`importExternalMemory()` 将导入拆成固定的五步:
|
|
@@ -311,8 +366,8 @@ StrataGate 目前是用于验证长期 Agent 记忆设计的研究型原型。
|
|
|
311
366
|
|
|
312
367
|
- 分层对话块及其衰减规则;
|
|
313
368
|
- 带来源、时间和冲突关系的事件卡;
|
|
314
|
-
-
|
|
315
|
-
-
|
|
369
|
+
- 独立可重试、保留事件来源的知识图谱整理任务;
|
|
370
|
+
- 面向事件和图谱节点的 BM25/RRF 检索;
|
|
316
371
|
- 保留原始导入内容的外部 AI 记忆迁移;
|
|
317
372
|
- 相互隔离的并发检索批次与证据判断;
|
|
318
373
|
- 长度有界、可由代码校验的证据门;
|
|
@@ -356,7 +411,7 @@ npm run build
|
|
|
356
411
|
|
|
357
412
|
| 资源 | 内容 |
|
|
358
413
|
| --- | --- |
|
|
359
|
-
| [`docs/ARCHITECTURE.md`](docs/ARCHITECTURE.md) | 数据流、分层规则、事件/元素协议、检索、证据门约束、权重和存储不变量 |
|
|
414
|
+
| [`docs/ARCHITECTURE.md`](docs/ARCHITECTURE.md) | 数据流、分层规则、事件/元素协议、检索、证据门约束、权重和存储不变量 |
|
|
360
415
|
| [`docs/EXTERNAL_MEMORY_IMPORT.zh-CN.md`](docs/EXTERNAL_MEMORY_IMPORT.zh-CN.md) | 外部记忆导出格式、导入流程和接入示例 |
|
|
361
416
|
| [`docs/EVALUATION.md`](docs/EVALUATION.md) | R1–R8 实验、模型敏感性、Mem0 对比、失败分析和报告边界 |
|
|
362
417
|
| [`benchmarks/locomo-conv26-r8-final.json`](benchmarks/locomo-conv26-r8-final.json) | 当前结果、逐阶段统计、运行信息和源产物哈希 |
|
|
@@ -374,9 +429,9 @@ docs/ DSH 使用、架构和完整评测文档
|
|
|
374
429
|
benchmarks/ 机器可读实验结果
|
|
375
430
|
```
|
|
376
431
|
|
|
377
|
-
##
|
|
432
|
+
## 什么情况下适合使用 StrataGate
|
|
378
433
|
|
|
379
|
-
|
|
434
|
+
如果你同时需要以下多项能力,可以优先考虑 StrataGate:
|
|
380
435
|
|
|
381
436
|
- 自动记录已完成对话和工具结果,形成**跨会话长期记忆**;
|
|
382
437
|
- 使用本地 SQLite 保存记忆,**不需要单独部署记忆服务**;
|
|
@@ -385,16 +440,16 @@ benchmarks/ 机器可读实验结果
|
|
|
385
440
|
- 召回结果可以展开回原始对话与工具输出,**来源可追溯**;
|
|
386
441
|
- 在把记忆用于回答前,通过**证据充分性检查**判断当前材料是否真的够用。
|
|
387
442
|
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
DeepSeek Harness
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
## 许可证
|
|
443
|
+
如果你最需要的是自由编辑记忆内容、跨产品的云端多人协作,或者只想维护一个简单的手写便签文件,应先考虑其他插件。StrataGate 已提供以查看和追溯为主的知识图谱界面,但它更适合自动、本地、证据可追溯的 Agent 记忆工作流,而不是多人知识库编辑。
|
|
444
|
+
|
|
445
|
+
DeepSeek Harness 用户可以从[快速开始](#quick-start-deepseek-harness)安装。DSH 适配层的行为、工具、配置和失败恢复方式见 [DeepSeek Harness 插件中文文档](docs/DSH.zh-CN.md)。
|
|
446
|
+
|
|
447
|
+
## 参与贡献
|
|
448
|
+
|
|
449
|
+
欢迎各种形式的贡献:修复问题、完善文档、增加集成,或探索更好的记忆与检索方案都可以。
|
|
450
|
+
|
|
451
|
+
请先阅读 [`CONTRIBUTING.zh-CN.md`](CONTRIBUTING.zh-CN.md),其中包含 monorepo 开发环境、检查与测试命令、适合参与的方向,以及提交 Pull Request 的建议。如果还不确定一个想法是否适合项目,建议先[创建 Issue](https://github.com/diqierjia/StrataGate-AgentMemory/issues),再投入较大的改动。
|
|
452
|
+
|
|
453
|
+
## 许可证
|
|
399
454
|
|
|
400
455
|
StrataGate 使用 [MIT License](LICENSE)。
|