stratagate-dsh 0.3.7 → 0.3.8
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 +583 -576
- package/LICENSE +21 -21
- package/README.md +504 -504
- package/README.zh-CN.md +508 -508
- package/cordis.patch.yml +16 -16
- package/dist/client.d.ts +1 -1
- package/dist/client.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/plugin.js +3080 -2476
- package/dist/plugin.js.map +1 -1
- package/dist/repair-profile.js +0 -0
- package/dist/repair-profile.js.map +1 -1
- package/docs/ARCHITECTURE.md +276 -276
- package/docs/DSH.md +256 -256
- package/docs/DSH.zh-CN.md +233 -233
- package/docs/EVALUATION.md +189 -189
- package/docs/EXTERNAL_MEMORY_IMPORT.zh-CN.md +99 -99
- package/docs/MEMORY_TOPICS.zh-CN.md +51 -51
- package/docs/benchmarks/issue-128-windows-review.json +104 -0
- package/docs/benchmarks/issue-128-windows.json +103 -0
- package/docs/event-extractor.md +32 -32
- package/docs/issue-128-lease-cache-review-followup.md +55 -0
- package/docs/issue-128-review-followup.md +58 -0
- package/docs/validation/issue119-after.json +30 -30
- package/docs/validation/issue119-before.json +94 -94
- package/docs/validation/issue119.md +41 -41
- package/package.json +246 -246
- package/screenshots.json +8 -8
package/docs/EVALUATION.md
CHANGED
|
@@ -1,189 +1,189 @@
|
|
|
1
|
-
# Evaluation record and reporting rules
|
|
2
|
-
|
|
3
|
-
This document separates completed development experiments from benchmark claims. Every public score should state the dataset scope, question categories, extraction model, answer model, Judge model, prompt, repetitions, and whether the memory state was created inside the same run.
|
|
4
|
-
|
|
5
|
-
## Final round-eight `conv-26` result
|
|
6
|
-
|
|
7
|
-
The latest completed run covers one LoCoMo conversation, `conv-26`: 419 messages, 35 sessions, and 152 category 1–4 questions. StrataGate completed all 152 answers and all 1,520 Judge decisions with no unrecovered question failure.
|
|
8
|
-
|
|
9
|
-
> [!IMPORTANT]
|
|
10
|
-
> This is a single-conversation directional comparison, not a full LoCoMo score or a cross-project leaderboard. StrataGate and Mem0 used the same questions, answer model, Judge, prompt, parser, and repetitions, but different memory-construction, retrieval, embedding, and answer-context pipelines. The comparison does not isolate memory architecture as one causal variable.
|
|
11
|
-
|
|
12
|
-
### Overall result
|
|
13
|
-
|
|
14
|
-
| Metric | StrataGate final R8 | Mem0 base | StrataGate - Mem0 |
|
|
15
|
-
| --- | ---: | ---: | ---: |
|
|
16
|
-
| Ten-Judge mean accuracy | **80.4606%** | 63.2237% | **+17.2369 pp** |
|
|
17
|
-
| Standard deviation across Judge runs | 0.5138 pp | 0.9045 pp | -0.3907 pp |
|
|
18
|
-
| Judge-run range | 79.6053%–81.5789% | 61.8421%–65.1316% | — |
|
|
19
|
-
| Majority-correct questions | **121 / 152** | 96 / 152 | **+25** |
|
|
20
|
-
| Majority accuracy | **79.61%** | 63.1579% | **+16.45 pp** |
|
|
21
|
-
|
|
22
|
-
The ± values describe repeated Judge variation on one fixed answer set. They are not confidence intervals across LoCoMo conversations.
|
|
23
|
-
|
|
24
|
-
### Mean accuracy by category
|
|
25
|
-
|
|
26
|
-
| Category | Questions | StrataGate final R8 | Mem0 base | StrataGate - Mem0 |
|
|
27
|
-
| --- | ---: | ---: | ---: | ---: |
|
|
28
|
-
| Multi-hop | 32 | **66.5625%** | 61.5625% | +5.0000 pp |
|
|
29
|
-
| Temporal | 37 | **74.8649%** | 34.5946% | **+40.2703 pp** |
|
|
30
|
-
| Open-domain | 13 | 83.0769% | **84.6154%** | -1.5385 pp |
|
|
31
|
-
| Single-hop | 70 | **89.2857%** | 75.1429% | **+14.1428 pp** |
|
|
32
|
-
|
|
33
|
-
The largest observed difference is temporal. Mem0's local base run often anchored relative dates from the 2023 conversation to the 2026 experiment date. StrataGate retained source timestamps and could fall back to the original messages. This mechanism is consistent with the gap, but the paired result is not an ablation and does not prove that timestamps or raw fallback caused the full difference.
|
|
34
|
-
|
|
35
|
-
### Paired majority outcomes
|
|
36
|
-
|
|
37
|
-
| Outcome | Questions |
|
|
38
|
-
| --- | ---: |
|
|
39
|
-
| Both correct | 80 |
|
|
40
|
-
| StrataGate correct, Mem0 wrong | 41 |
|
|
41
|
-
| StrataGate wrong, Mem0 correct | 16 |
|
|
42
|
-
| Both wrong | 15 |
|
|
43
|
-
|
|
44
|
-
### Protocol matrix
|
|
45
|
-
|
|
46
|
-
| Field | StrataGate final R8 | Mem0 base |
|
|
47
|
-
| --- | --- | --- |
|
|
48
|
-
| Dataset scope | `conv-26`, categories 1–4, 152 questions | Same IDs, order, text, gold answers, and categories |
|
|
49
|
-
| Memory construction | Fresh build from 419 timestamped messages with `gpt-5.6-sol`; 17 blocks, 97 events, 4 elements | Fresh build with `gpt-5.6-sol`; 173 final memories |
|
|
50
|
-
| Retrieval and assessment | BM25/RRF event and fact-level element tools, raw-message fallback, four-round budget, five-field evidence gate | Two speaker searches, top-30 each; no graph |
|
|
51
|
-
| Answer model | `gpt-5.6-sol`, `reasoning_effort=low` | Same |
|
|
52
|
-
| Judge | `gpt-5.6-sol`, ten repeats, concurrency 1 | Same model, prompt, parser, and repeats |
|
|
53
|
-
| Judge prompt SHA-256 | `44fb3d8f7a1f37b2430772cf90518a32172e4056b7a0dec085402763fd179b9f` | Same |
|
|
54
|
-
| Answer context and prompt | StrataGate-specific | Mem0-specific |
|
|
55
|
-
| Embedding | No vector retrieval in the evaluated event/element search | `text-embedding-3-small`, 1536 dimensions |
|
|
56
|
-
|
|
57
|
-
Mem0 used the local base SDK version 0.1.97 pinned to commit `2b58775c17eb1c1b7532242b7154af6744102280`, with Graph, Cloud, and Platform v3 disabled. It processed 419 source messages through two speaker views and completed all 428 write units.
|
|
58
|
-
|
|
59
|
-
The StrataGate run recorded 2,065 successful model responses and 14 bodyless socket failures during extraction. All 14 failures were recovered from checkpoints, no completed question was replayed, and every successful response reported `gpt-5.6-sol`. The Mem0 run retained 187 historical failed-attempt traces, all recovered; its generated summary reports `passed=false` because it treats those bodyless attempts as missing `response.model`, even though successful responses returned the expected model. Completion and clean-transport acceptance are reported separately.
|
|
60
|
-
|
|
61
|
-
The public aggregates are:
|
|
62
|
-
|
|
63
|
-
- [`benchmarks/locomo-conv26-r8-final.json`](../benchmarks/locomo-conv26-r8-final.json) for final R8, its prior-round comparisons, and remaining-error stages;
|
|
64
|
-
- [`benchmarks/locomo-conv26-sol-mem0-paired.json`](../benchmarks/locomo-conv26-sol-mem0-paired.json) for the earlier round-seven/Mem0 pairing retained as historical evidence;
|
|
65
|
-
- [`benchmarks/locomo-conv26-development.json`](../benchmarks/locomo-conv26-development.json) for R1–R5.
|
|
66
|
-
|
|
67
|
-
Raw requests and per-question traces are not copied into this public repository.
|
|
68
|
-
|
|
69
|
-
| Source artifact | SHA-256 |
|
|
70
|
-
| --- | --- |
|
|
71
|
-
| Final R8 `summary.json` | `3e29d985fcdd88a385c106838c3046808c476affb63679c2e02601b5a2006656` |
|
|
72
|
-
| Final R8 `checkpoint.json` | `82a2f5be362369c72aff39c7d6eaf9b5b6904ccba15a186aef1e7ff770ff79db` |
|
|
73
|
-
| Final R8 `source-snapshot.patch` | `5eed8bd5fd7b316ad2aaf4b142992bac31c427ea81cbb1f7ab1e81449e08e581` |
|
|
74
|
-
| Mem0 `summary.json` | `88f39b729546c6f343e51a11ad8f80bc1eea06ba831f33008fad779b04962927` |
|
|
75
|
-
| Mem0 `paired-comparison.json` | `27b604692364f24600d9513d8d2b91da9b52245a4574f581afb0afc6f00ee7fc` |
|
|
76
|
-
| Mem0 `protocol-audit.json` | `c1e39714eb08a775f9cbe12d0a43de6d825c142991840eab329398d1b9d744eb` |
|
|
77
|
-
|
|
78
|
-
## Development sequence
|
|
79
|
-
|
|
80
|
-
All recorded rounds used the same `conv-26` development slice, but the model and scoring protocols changed. R1–R5 used `gpt-4o-mini` extraction with a GPT-4o answerer/Judge setup. R7 and R8 used ten `gpt-5.6-sol` Judge decisions per question. R6 stopped at a 123-question snapshot and has no final score.
|
|
81
|
-
|
|
82
|
-
| Run | Main intervention | Reported result | Protocol note |
|
|
83
|
-
| --- | --- | ---: | --- |
|
|
84
|
-
| R1 | Initial layered blocks and event cards | 67 / 152 (44.08%) | Temporal accuracy 18.92% |
|
|
85
|
-
| R2 | Multiple event cards per block and explicit occurrence time | 77 / 152 (50.66%) | Temporal accuracy rose to 45.95% |
|
|
86
|
-
| R3 | Extraction, read tools, and per-batch assessment changed together | 116 / 152 (76.32%) | One adoption-rule violation; strict result 115 / 152 (75.66%) |
|
|
87
|
-
| R4 | Bounded five-field assessment context | 118 / 152 (77.63%) | Zero recorded adoption violations and about 10.35% fewer QA tokens than R3 |
|
|
88
|
-
| R5 | Larger structured retrieval scratchpad | 97 / 152 (63.82%) | Reproducible regression led to restoring the smaller gate |
|
|
89
|
-
| R6 | Mini-model sensitivity run | incomplete | 123-question snapshot only; no final score |
|
|
90
|
-
| R7 | Sol retrieval, assessment, answer, and Judge | 71.9737% mean; 111 / 152 majority | Reused a state extracted with `gpt-4o-mini`; not end-to-end Sol |
|
|
91
|
-
| R8 initial | Fresh end-to-end Sol extraction and hybrid event/element retrieval | 70.3289% mean; 107 / 152 majority | Repeated card searches frequently exhausted the budget |
|
|
92
|
-
| **R8 final** | Fresh end-to-end Sol state with raw fallback and retrieval fixes | **80.4606% mean; 121 / 152 majority** | Best completed result on this slice |
|
|
93
|
-
|
|
94
|
-
The sequence supports several engineering conclusions, not a single cumulative causal curve:
|
|
95
|
-
|
|
96
|
-
1. Explicit occurrence time improved temporal questions on the fixed early-round protocol.
|
|
97
|
-
2. A small, enforceable evidence gate performed better than a larger structured scratchpad.
|
|
98
|
-
3. Model and Judge changes materially affect scores; at least one fixed answer moved from 10 / 10 correct under the mini Judge to 0 / 10 under the Sol Judge.
|
|
99
|
-
4. Retrieval strategy matters more than raw search count. Repeating the same card search can be worse than changing channel and checking the original source.
|
|
100
|
-
5. Element-card value remains unresolved. Final R8 used `search_elements` on only four questions; all four were correct, but this usage-conditioned subset is too small and selected to support a causal claim.
|
|
101
|
-
|
|
102
|
-
## Initial R8 versus final R8
|
|
103
|
-
|
|
104
|
-
| Metric | Initial R8 | Final R8 | Change |
|
|
105
|
-
| --- | ---: | ---: | ---: |
|
|
106
|
-
| Ten-Judge mean | 70.3289% | **80.4606%** | **+10.1317 pp** |
|
|
107
|
-
| Majority correct | 107 / 152 | **121 / 152** | **+14** |
|
|
108
|
-
| Retrieval rounds | 215 | **146** | -69 (-32.1%) |
|
|
109
|
-
| Assessment calls | 237 | **146** | -91 (-38.4%) |
|
|
110
|
-
| Total tokens | 6,692,417 | **4,088,324** | -2,604,093 (-38.9%) |
|
|
111
|
-
| Official-equivalent cost | $33.907499 | **$21.406145** | -$12.501354 (-36.9%) |
|
|
112
|
-
|
|
113
|
-
Question-level majority transitions were: 95 both correct, 26 final-R8-only correct, 12 initial-R8-only correct, and 19 both wrong.
|
|
114
|
-
|
|
115
|
-
The initial run had 19 questions with at least three `search_events` calls; only 2 were majority-correct. Final R8 answered 15 of those same questions correctly, with 12 using raw-message fallback. A representative temporal question asked when Caroline gave a school speech: the initial run repeatedly searched event cards and abstained, while final R8 fell back to the source message dated 2023-06-09, resolved “last week,” and received 10 / 10 correct Judge votes.
|
|
116
|
-
|
|
117
|
-
This is strong diagnostic evidence that the old repeated-search path was defective. It is not a clean ablation: retrieval policy, filters, element result shape, and freshly extracted memory contents all changed.
|
|
118
|
-
|
|
119
|
-
## Remaining-error analysis
|
|
120
|
-
|
|
121
|
-
Final R8 has 31 majority-wrong questions. Their observable failure stage is:
|
|
122
|
-
|
|
123
|
-
| Failure stage | Questions | Multi-hop | Temporal | Open-domain | Single-hop |
|
|
124
|
-
| --- | ---: | ---: | ---: | ---: | ---: |
|
|
125
|
-
| Direct answer without retrieval | 15 | 5 | 3 | 2 | 5 |
|
|
126
|
-
| Retrieval marked `sufficient`, final answer wrong | 14 | 6 | 6 | 0 | 2 |
|
|
127
|
-
| Retrieval remained `partial` at the limit | 2 | 0 | 1 | 0 | 1 |
|
|
128
|
-
| **Total** | **31** | **11** | **10** | **2** | **8** |
|
|
129
|
-
|
|
130
|
-
The two largest problems are therefore not a lack of retrieval rounds:
|
|
131
|
-
|
|
132
|
-
- **Direct-answer risk:** 15 wrong answers bypassed retrieval entirely. These include missed list facts, wrong event details, and unanchored relative dates.
|
|
133
|
-
- **False sufficiency:** 14 answers passed the evidence gate but were still wrong. The selected material was often related but belonged to an adjacent event, or it supported only part of a requested list.
|
|
134
|
-
|
|
135
|
-
Recurring patterns include:
|
|
136
|
-
|
|
137
|
-
- choosing the wrong research topic or the wrong pottery event;
|
|
138
|
-
- resolving a relative date against the wrong message or returning “next month” without an absolute anchor;
|
|
139
|
-
- omitting one item from books, instruments, purchases, or attended events;
|
|
140
|
-
- using a generally plausible reason instead of the event-specific reason requested;
|
|
141
|
-
- open-domain Judge disagreements where the memory evidence supports more than one cautious inference.
|
|
142
|
-
|
|
143
|
-
The next diagnostic should inject the gold-evidence raw block while keeping the answer and Judge protocol fixed. That oracle split will distinguish retrieval/selection failure from answer reasoning and temporal-calculation failure. Before increasing the retrieval budget, the implementation should also gate direct temporal/multi-hop answers, tighten `sufficient` against adjacent events, and add completeness checks for list questions.
|
|
144
|
-
|
|
145
|
-
## Reporting checklist
|
|
146
|
-
|
|
147
|
-
Before treating two scores as comparable, freeze and report:
|
|
148
|
-
|
|
149
|
-
- dataset version and conversation/question scope;
|
|
150
|
-
- included categories;
|
|
151
|
-
- extraction code and model;
|
|
152
|
-
- retrieval code, tools, budgets, and prompts;
|
|
153
|
-
- answer model, temperature, and reasoning configuration;
|
|
154
|
-
- Judge prompt, model, temperature, parser, and repetitions;
|
|
155
|
-
- provider and returned-model audit;
|
|
156
|
-
- memory-state provenance;
|
|
157
|
-
- retries, missing responses, and checkpoint completion;
|
|
158
|
-
- exact numerator and denominator, not only a rounded percentage.
|
|
159
|
-
|
|
160
|
-
## What the current evidence supports
|
|
161
|
-
|
|
162
|
-
The current evidence supports these narrow claims:
|
|
163
|
-
|
|
164
|
-
- on `conv-26` and the tested configurations, final R8 scored 121 / 152 by majority vote and Mem0 base scored 96 / 152;
|
|
165
|
-
- the largest observed paired category difference was temporal, while Mem0 remained slightly higher on open-domain questions;
|
|
166
|
-
- the final R8 retrieval policy avoided a measured repeated-event-search failure mode while using fewer rounds, tokens, and cost;
|
|
167
|
-
- explicit occurrence time, an enforceable evidence gate, and raw-source access are useful components on this development slice;
|
|
168
|
-
- remaining errors are split mainly between direct answers that skipped retrieval and retrieved evidence incorrectly marked sufficient;
|
|
169
|
-
- completed per-question checkpoints and request traces are necessary to distinguish model behavior from transport failure.
|
|
170
|
-
|
|
171
|
-
It does not yet support these broader claims:
|
|
172
|
-
|
|
173
|
-
- state of the art on LoCoMo;
|
|
174
|
-
- generalization across the full LoCoMo dataset;
|
|
175
|
-
- architectural superiority under a shared end-to-end retrieval and context protocol;
|
|
176
|
-
- a single-component causal explanation for the final R8 gain;
|
|
177
|
-
- a causal benefit from element cards without disabled/forced/fixed-state ablations.
|
|
178
|
-
|
|
179
|
-
The next credible milestone is a fixed-state component ablation, followed by the same frozen end-to-end protocol across more conversations and then the full dataset.
|
|
180
|
-
|
|
181
|
-
## Follow-up validation plan
|
|
182
|
-
|
|
183
|
-
The following are proposed experiments, not completed results:
|
|
184
|
-
|
|
185
|
-
1. Hold the model and memory state fixed and ablate short-term display decay and individual retrieval mechanisms. Compare answer accuracy, historical context size, background model input, and total call costs separately.
|
|
186
|
-
2. Give the answering model known-correct source evidence directly. This separates failures to retrieve evidence from reasoning failures that remain when evidence is available.
|
|
187
|
-
3. Repeat the frozen protocol across additional conversations before reporting a full LoCoMo result.
|
|
188
|
-
|
|
189
|
-
These experiments would help distinguish the contribution of each component from improvements observed between versions that changed multiple components together.
|
|
1
|
+
# Evaluation record and reporting rules
|
|
2
|
+
|
|
3
|
+
This document separates completed development experiments from benchmark claims. Every public score should state the dataset scope, question categories, extraction model, answer model, Judge model, prompt, repetitions, and whether the memory state was created inside the same run.
|
|
4
|
+
|
|
5
|
+
## Final round-eight `conv-26` result
|
|
6
|
+
|
|
7
|
+
The latest completed run covers one LoCoMo conversation, `conv-26`: 419 messages, 35 sessions, and 152 category 1–4 questions. StrataGate completed all 152 answers and all 1,520 Judge decisions with no unrecovered question failure.
|
|
8
|
+
|
|
9
|
+
> [!IMPORTANT]
|
|
10
|
+
> This is a single-conversation directional comparison, not a full LoCoMo score or a cross-project leaderboard. StrataGate and Mem0 used the same questions, answer model, Judge, prompt, parser, and repetitions, but different memory-construction, retrieval, embedding, and answer-context pipelines. The comparison does not isolate memory architecture as one causal variable.
|
|
11
|
+
|
|
12
|
+
### Overall result
|
|
13
|
+
|
|
14
|
+
| Metric | StrataGate final R8 | Mem0 base | StrataGate - Mem0 |
|
|
15
|
+
| --- | ---: | ---: | ---: |
|
|
16
|
+
| Ten-Judge mean accuracy | **80.4606%** | 63.2237% | **+17.2369 pp** |
|
|
17
|
+
| Standard deviation across Judge runs | 0.5138 pp | 0.9045 pp | -0.3907 pp |
|
|
18
|
+
| Judge-run range | 79.6053%–81.5789% | 61.8421%–65.1316% | — |
|
|
19
|
+
| Majority-correct questions | **121 / 152** | 96 / 152 | **+25** |
|
|
20
|
+
| Majority accuracy | **79.61%** | 63.1579% | **+16.45 pp** |
|
|
21
|
+
|
|
22
|
+
The ± values describe repeated Judge variation on one fixed answer set. They are not confidence intervals across LoCoMo conversations.
|
|
23
|
+
|
|
24
|
+
### Mean accuracy by category
|
|
25
|
+
|
|
26
|
+
| Category | Questions | StrataGate final R8 | Mem0 base | StrataGate - Mem0 |
|
|
27
|
+
| --- | ---: | ---: | ---: | ---: |
|
|
28
|
+
| Multi-hop | 32 | **66.5625%** | 61.5625% | +5.0000 pp |
|
|
29
|
+
| Temporal | 37 | **74.8649%** | 34.5946% | **+40.2703 pp** |
|
|
30
|
+
| Open-domain | 13 | 83.0769% | **84.6154%** | -1.5385 pp |
|
|
31
|
+
| Single-hop | 70 | **89.2857%** | 75.1429% | **+14.1428 pp** |
|
|
32
|
+
|
|
33
|
+
The largest observed difference is temporal. Mem0's local base run often anchored relative dates from the 2023 conversation to the 2026 experiment date. StrataGate retained source timestamps and could fall back to the original messages. This mechanism is consistent with the gap, but the paired result is not an ablation and does not prove that timestamps or raw fallback caused the full difference.
|
|
34
|
+
|
|
35
|
+
### Paired majority outcomes
|
|
36
|
+
|
|
37
|
+
| Outcome | Questions |
|
|
38
|
+
| --- | ---: |
|
|
39
|
+
| Both correct | 80 |
|
|
40
|
+
| StrataGate correct, Mem0 wrong | 41 |
|
|
41
|
+
| StrataGate wrong, Mem0 correct | 16 |
|
|
42
|
+
| Both wrong | 15 |
|
|
43
|
+
|
|
44
|
+
### Protocol matrix
|
|
45
|
+
|
|
46
|
+
| Field | StrataGate final R8 | Mem0 base |
|
|
47
|
+
| --- | --- | --- |
|
|
48
|
+
| Dataset scope | `conv-26`, categories 1–4, 152 questions | Same IDs, order, text, gold answers, and categories |
|
|
49
|
+
| Memory construction | Fresh build from 419 timestamped messages with `gpt-5.6-sol`; 17 blocks, 97 events, 4 elements | Fresh build with `gpt-5.6-sol`; 173 final memories |
|
|
50
|
+
| Retrieval and assessment | BM25/RRF event and fact-level element tools, raw-message fallback, four-round budget, five-field evidence gate | Two speaker searches, top-30 each; no graph |
|
|
51
|
+
| Answer model | `gpt-5.6-sol`, `reasoning_effort=low` | Same |
|
|
52
|
+
| Judge | `gpt-5.6-sol`, ten repeats, concurrency 1 | Same model, prompt, parser, and repeats |
|
|
53
|
+
| Judge prompt SHA-256 | `44fb3d8f7a1f37b2430772cf90518a32172e4056b7a0dec085402763fd179b9f` | Same |
|
|
54
|
+
| Answer context and prompt | StrataGate-specific | Mem0-specific |
|
|
55
|
+
| Embedding | No vector retrieval in the evaluated event/element search | `text-embedding-3-small`, 1536 dimensions |
|
|
56
|
+
|
|
57
|
+
Mem0 used the local base SDK version 0.1.97 pinned to commit `2b58775c17eb1c1b7532242b7154af6744102280`, with Graph, Cloud, and Platform v3 disabled. It processed 419 source messages through two speaker views and completed all 428 write units.
|
|
58
|
+
|
|
59
|
+
The StrataGate run recorded 2,065 successful model responses and 14 bodyless socket failures during extraction. All 14 failures were recovered from checkpoints, no completed question was replayed, and every successful response reported `gpt-5.6-sol`. The Mem0 run retained 187 historical failed-attempt traces, all recovered; its generated summary reports `passed=false` because it treats those bodyless attempts as missing `response.model`, even though successful responses returned the expected model. Completion and clean-transport acceptance are reported separately.
|
|
60
|
+
|
|
61
|
+
The public aggregates are:
|
|
62
|
+
|
|
63
|
+
- [`benchmarks/locomo-conv26-r8-final.json`](../benchmarks/locomo-conv26-r8-final.json) for final R8, its prior-round comparisons, and remaining-error stages;
|
|
64
|
+
- [`benchmarks/locomo-conv26-sol-mem0-paired.json`](../benchmarks/locomo-conv26-sol-mem0-paired.json) for the earlier round-seven/Mem0 pairing retained as historical evidence;
|
|
65
|
+
- [`benchmarks/locomo-conv26-development.json`](../benchmarks/locomo-conv26-development.json) for R1–R5.
|
|
66
|
+
|
|
67
|
+
Raw requests and per-question traces are not copied into this public repository.
|
|
68
|
+
|
|
69
|
+
| Source artifact | SHA-256 |
|
|
70
|
+
| --- | --- |
|
|
71
|
+
| Final R8 `summary.json` | `3e29d985fcdd88a385c106838c3046808c476affb63679c2e02601b5a2006656` |
|
|
72
|
+
| Final R8 `checkpoint.json` | `82a2f5be362369c72aff39c7d6eaf9b5b6904ccba15a186aef1e7ff770ff79db` |
|
|
73
|
+
| Final R8 `source-snapshot.patch` | `5eed8bd5fd7b316ad2aaf4b142992bac31c427ea81cbb1f7ab1e81449e08e581` |
|
|
74
|
+
| Mem0 `summary.json` | `88f39b729546c6f343e51a11ad8f80bc1eea06ba831f33008fad779b04962927` |
|
|
75
|
+
| Mem0 `paired-comparison.json` | `27b604692364f24600d9513d8d2b91da9b52245a4574f581afb0afc6f00ee7fc` |
|
|
76
|
+
| Mem0 `protocol-audit.json` | `c1e39714eb08a775f9cbe12d0a43de6d825c142991840eab329398d1b9d744eb` |
|
|
77
|
+
|
|
78
|
+
## Development sequence
|
|
79
|
+
|
|
80
|
+
All recorded rounds used the same `conv-26` development slice, but the model and scoring protocols changed. R1–R5 used `gpt-4o-mini` extraction with a GPT-4o answerer/Judge setup. R7 and R8 used ten `gpt-5.6-sol` Judge decisions per question. R6 stopped at a 123-question snapshot and has no final score.
|
|
81
|
+
|
|
82
|
+
| Run | Main intervention | Reported result | Protocol note |
|
|
83
|
+
| --- | --- | ---: | --- |
|
|
84
|
+
| R1 | Initial layered blocks and event cards | 67 / 152 (44.08%) | Temporal accuracy 18.92% |
|
|
85
|
+
| R2 | Multiple event cards per block and explicit occurrence time | 77 / 152 (50.66%) | Temporal accuracy rose to 45.95% |
|
|
86
|
+
| R3 | Extraction, read tools, and per-batch assessment changed together | 116 / 152 (76.32%) | One adoption-rule violation; strict result 115 / 152 (75.66%) |
|
|
87
|
+
| R4 | Bounded five-field assessment context | 118 / 152 (77.63%) | Zero recorded adoption violations and about 10.35% fewer QA tokens than R3 |
|
|
88
|
+
| R5 | Larger structured retrieval scratchpad | 97 / 152 (63.82%) | Reproducible regression led to restoring the smaller gate |
|
|
89
|
+
| R6 | Mini-model sensitivity run | incomplete | 123-question snapshot only; no final score |
|
|
90
|
+
| R7 | Sol retrieval, assessment, answer, and Judge | 71.9737% mean; 111 / 152 majority | Reused a state extracted with `gpt-4o-mini`; not end-to-end Sol |
|
|
91
|
+
| R8 initial | Fresh end-to-end Sol extraction and hybrid event/element retrieval | 70.3289% mean; 107 / 152 majority | Repeated card searches frequently exhausted the budget |
|
|
92
|
+
| **R8 final** | Fresh end-to-end Sol state with raw fallback and retrieval fixes | **80.4606% mean; 121 / 152 majority** | Best completed result on this slice |
|
|
93
|
+
|
|
94
|
+
The sequence supports several engineering conclusions, not a single cumulative causal curve:
|
|
95
|
+
|
|
96
|
+
1. Explicit occurrence time improved temporal questions on the fixed early-round protocol.
|
|
97
|
+
2. A small, enforceable evidence gate performed better than a larger structured scratchpad.
|
|
98
|
+
3. Model and Judge changes materially affect scores; at least one fixed answer moved from 10 / 10 correct under the mini Judge to 0 / 10 under the Sol Judge.
|
|
99
|
+
4. Retrieval strategy matters more than raw search count. Repeating the same card search can be worse than changing channel and checking the original source.
|
|
100
|
+
5. Element-card value remains unresolved. Final R8 used `search_elements` on only four questions; all four were correct, but this usage-conditioned subset is too small and selected to support a causal claim.
|
|
101
|
+
|
|
102
|
+
## Initial R8 versus final R8
|
|
103
|
+
|
|
104
|
+
| Metric | Initial R8 | Final R8 | Change |
|
|
105
|
+
| --- | ---: | ---: | ---: |
|
|
106
|
+
| Ten-Judge mean | 70.3289% | **80.4606%** | **+10.1317 pp** |
|
|
107
|
+
| Majority correct | 107 / 152 | **121 / 152** | **+14** |
|
|
108
|
+
| Retrieval rounds | 215 | **146** | -69 (-32.1%) |
|
|
109
|
+
| Assessment calls | 237 | **146** | -91 (-38.4%) |
|
|
110
|
+
| Total tokens | 6,692,417 | **4,088,324** | -2,604,093 (-38.9%) |
|
|
111
|
+
| Official-equivalent cost | $33.907499 | **$21.406145** | -$12.501354 (-36.9%) |
|
|
112
|
+
|
|
113
|
+
Question-level majority transitions were: 95 both correct, 26 final-R8-only correct, 12 initial-R8-only correct, and 19 both wrong.
|
|
114
|
+
|
|
115
|
+
The initial run had 19 questions with at least three `search_events` calls; only 2 were majority-correct. Final R8 answered 15 of those same questions correctly, with 12 using raw-message fallback. A representative temporal question asked when Caroline gave a school speech: the initial run repeatedly searched event cards and abstained, while final R8 fell back to the source message dated 2023-06-09, resolved “last week,” and received 10 / 10 correct Judge votes.
|
|
116
|
+
|
|
117
|
+
This is strong diagnostic evidence that the old repeated-search path was defective. It is not a clean ablation: retrieval policy, filters, element result shape, and freshly extracted memory contents all changed.
|
|
118
|
+
|
|
119
|
+
## Remaining-error analysis
|
|
120
|
+
|
|
121
|
+
Final R8 has 31 majority-wrong questions. Their observable failure stage is:
|
|
122
|
+
|
|
123
|
+
| Failure stage | Questions | Multi-hop | Temporal | Open-domain | Single-hop |
|
|
124
|
+
| --- | ---: | ---: | ---: | ---: | ---: |
|
|
125
|
+
| Direct answer without retrieval | 15 | 5 | 3 | 2 | 5 |
|
|
126
|
+
| Retrieval marked `sufficient`, final answer wrong | 14 | 6 | 6 | 0 | 2 |
|
|
127
|
+
| Retrieval remained `partial` at the limit | 2 | 0 | 1 | 0 | 1 |
|
|
128
|
+
| **Total** | **31** | **11** | **10** | **2** | **8** |
|
|
129
|
+
|
|
130
|
+
The two largest problems are therefore not a lack of retrieval rounds:
|
|
131
|
+
|
|
132
|
+
- **Direct-answer risk:** 15 wrong answers bypassed retrieval entirely. These include missed list facts, wrong event details, and unanchored relative dates.
|
|
133
|
+
- **False sufficiency:** 14 answers passed the evidence gate but were still wrong. The selected material was often related but belonged to an adjacent event, or it supported only part of a requested list.
|
|
134
|
+
|
|
135
|
+
Recurring patterns include:
|
|
136
|
+
|
|
137
|
+
- choosing the wrong research topic or the wrong pottery event;
|
|
138
|
+
- resolving a relative date against the wrong message or returning “next month” without an absolute anchor;
|
|
139
|
+
- omitting one item from books, instruments, purchases, or attended events;
|
|
140
|
+
- using a generally plausible reason instead of the event-specific reason requested;
|
|
141
|
+
- open-domain Judge disagreements where the memory evidence supports more than one cautious inference.
|
|
142
|
+
|
|
143
|
+
The next diagnostic should inject the gold-evidence raw block while keeping the answer and Judge protocol fixed. That oracle split will distinguish retrieval/selection failure from answer reasoning and temporal-calculation failure. Before increasing the retrieval budget, the implementation should also gate direct temporal/multi-hop answers, tighten `sufficient` against adjacent events, and add completeness checks for list questions.
|
|
144
|
+
|
|
145
|
+
## Reporting checklist
|
|
146
|
+
|
|
147
|
+
Before treating two scores as comparable, freeze and report:
|
|
148
|
+
|
|
149
|
+
- dataset version and conversation/question scope;
|
|
150
|
+
- included categories;
|
|
151
|
+
- extraction code and model;
|
|
152
|
+
- retrieval code, tools, budgets, and prompts;
|
|
153
|
+
- answer model, temperature, and reasoning configuration;
|
|
154
|
+
- Judge prompt, model, temperature, parser, and repetitions;
|
|
155
|
+
- provider and returned-model audit;
|
|
156
|
+
- memory-state provenance;
|
|
157
|
+
- retries, missing responses, and checkpoint completion;
|
|
158
|
+
- exact numerator and denominator, not only a rounded percentage.
|
|
159
|
+
|
|
160
|
+
## What the current evidence supports
|
|
161
|
+
|
|
162
|
+
The current evidence supports these narrow claims:
|
|
163
|
+
|
|
164
|
+
- on `conv-26` and the tested configurations, final R8 scored 121 / 152 by majority vote and Mem0 base scored 96 / 152;
|
|
165
|
+
- the largest observed paired category difference was temporal, while Mem0 remained slightly higher on open-domain questions;
|
|
166
|
+
- the final R8 retrieval policy avoided a measured repeated-event-search failure mode while using fewer rounds, tokens, and cost;
|
|
167
|
+
- explicit occurrence time, an enforceable evidence gate, and raw-source access are useful components on this development slice;
|
|
168
|
+
- remaining errors are split mainly between direct answers that skipped retrieval and retrieved evidence incorrectly marked sufficient;
|
|
169
|
+
- completed per-question checkpoints and request traces are necessary to distinguish model behavior from transport failure.
|
|
170
|
+
|
|
171
|
+
It does not yet support these broader claims:
|
|
172
|
+
|
|
173
|
+
- state of the art on LoCoMo;
|
|
174
|
+
- generalization across the full LoCoMo dataset;
|
|
175
|
+
- architectural superiority under a shared end-to-end retrieval and context protocol;
|
|
176
|
+
- a single-component causal explanation for the final R8 gain;
|
|
177
|
+
- a causal benefit from element cards without disabled/forced/fixed-state ablations.
|
|
178
|
+
|
|
179
|
+
The next credible milestone is a fixed-state component ablation, followed by the same frozen end-to-end protocol across more conversations and then the full dataset.
|
|
180
|
+
|
|
181
|
+
## Follow-up validation plan
|
|
182
|
+
|
|
183
|
+
The following are proposed experiments, not completed results:
|
|
184
|
+
|
|
185
|
+
1. Hold the model and memory state fixed and ablate short-term display decay and individual retrieval mechanisms. Compare answer accuracy, historical context size, background model input, and total call costs separately.
|
|
186
|
+
2. Give the answering model known-correct source evidence directly. This separates failures to retrieve evidence from reasoning failures that remain when evidence is available.
|
|
187
|
+
3. Repeat the frozen protocol across additional conversations before reporting a full LoCoMo result.
|
|
188
|
+
|
|
189
|
+
These experiments would help distinguish the contribution of each component from improvements observed between versions that changed multiple components together.
|
|
@@ -1,99 +1,99 @@
|
|
|
1
|
-
# 外部 AI 记忆导入
|
|
2
|
-
|
|
3
|
-
StrataGate 提供 `importExternalMemory()` 编排外部记忆迁移:
|
|
4
|
-
|
|
5
|
-
```text
|
|
6
|
-
外部 AI JSON
|
|
7
|
-
↓ extractor(候选 Event)
|
|
8
|
-
每个候选 Event → searchEvents()(确定性 BM25,Top-K)
|
|
9
|
-
↓ decider(ADD / MERGE / SUPERSEDE / CONFLICT / IGNORE)
|
|
10
|
-
写入新的规范 Event,保留来源和 supersedes/conflicts 关系
|
|
11
|
-
↓
|
|
12
|
-
只为新 Event 创建元素/知识图谱投影任务
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
## 最小接入
|
|
16
|
-
|
|
17
|
-
```ts
|
|
18
|
-
import {
|
|
19
|
-
EXTERNAL_MEMORY_EXPORT_PROMPT_ZH_CN,
|
|
20
|
-
StrataGate,
|
|
21
|
-
externalMemoryJsonExtractor,
|
|
22
|
-
} from '@diqier/stratagate';
|
|
23
|
-
|
|
24
|
-
// 把 EXTERNAL_MEMORY_EXPORT_PROMPT_ZH_CN 交给外部 AI,并把它返回的 JSON 放入 text。
|
|
25
|
-
const result = await memory.importExternalMemory({
|
|
26
|
-
text,
|
|
27
|
-
extractor: externalMemoryJsonExtractor,
|
|
28
|
-
topK: 5,
|
|
29
|
-
decider: async ({ candidate, matches }) => {
|
|
30
|
-
// 这里通常调用你的 LLM;它只能从 matches 中选择 existingEventIds。
|
|
31
|
-
// 返回的 MERGE/SUPERSEDE 会创建新 Event,不会覆盖旧 Event。
|
|
32
|
-
return {
|
|
33
|
-
action: matches.length === 0 ? 'ADD' : 'MERGE',
|
|
34
|
-
existingEventIds: matches.slice(0, 1).map(({ event }) => event.id),
|
|
35
|
-
mergedCandidate: candidate,
|
|
36
|
-
};
|
|
37
|
-
},
|
|
38
|
-
});
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
`decider` 的 `matches` 已经被限制为 `topK` 条;即使模型返回其它事件 ID,库也会丢弃这些越界引用。`IGNORE` 只留下审计记录,不会写入 Event。`CONFLICT` 会在新旧事件两侧建立对称的 `conflictsWithEventIds`。
|
|
42
|
-
|
|
43
|
-
## 给外部 AI 的提示词
|
|
44
|
-
|
|
45
|
-
直接使用导出的 `EXTERNAL_MEMORY_EXPORT_PROMPT_ZH_CN`。它要求外部 AI 只输出 `stratagate.external-memory.v2` JSON,并区分 `memoryKind`(instruction/preference/fact/event)与 `category`,同时特别约束时间:
|
|
46
|
-
|
|
47
|
-
- `mentionedAt`(被提及时间)与 `happenedStart/happenedEnd`(实际发生/计划时间)分开;
|
|
48
|
-
- 没有明确时间或可靠参照时,不填写日期,不把当前时间、导出时间或聊天顺序当作事件时间;
|
|
49
|
-
- 保留 `originalText`,用 `precision` 和 `basis` 标记粒度与依据;
|
|
50
|
-
- “上周”等相对时间只有在能依据已知消息时间唯一换算时才转换,否则保持 `unknown`。
|
|
51
|
-
|
|
52
|
-
如果外部 AI 仍然返回 Markdown 代码块,`parseExternalMemoryExport()` 会自动去除围栏;其它非 JSON 文本会被拒绝,避免把模型解释误写进记忆。
|
|
53
|
-
|
|
54
|
-
用于第二阶段裁决的系统提示词可使用 `EXTERNAL_MEMORY_DECIDER_PROMPT_ZH_CN`。它明确规定了五种写入动作的边界,并要求模型只能引用本次 Top-K 结果中的事件 ID。
|
|
55
|
-
|
|
56
|
-
## 导出常量、格式与解析器
|
|
57
|
-
|
|
58
|
-
| 入口 | 用途 |
|
|
59
|
-
| --- | --- |
|
|
60
|
-
| `EXTERNAL_MEMORY_EXPORT_PROMPT_ZH_CN` | 交给外部 AI,要求生成 `stratagate.external-memory.v2` JSON |
|
|
61
|
-
| `parseExternalMemoryExport()` | 严格解析导出内容,允许去除 Markdown 代码围栏 |
|
|
62
|
-
| `externalMemoryJsonExtractor` | 将严格 JSON 解析包装为可直接传给核心导入 API 的 extractor |
|
|
63
|
-
| `EXTERNAL_MEMORY_DECIDER_PROMPT_ZH_CN` | 指导裁决模型从 ADD、MERGE、SUPERSEDE、CONFLICT、IGNORE 中选择动作 |
|
|
64
|
-
|
|
65
|
-
v2 将记忆性质 `memoryKind` 与内容分类 `category` 分开。决定如何导入时,应同时保留原始说法、来源和时间依据;未知日期不应由导出日期补齐。最小接入示例中的 `memory` 是已经打开的 StrataGate 实例,`text` 是外部 AI 返回的内容。
|
|
66
|
-
|
|
67
|
-
示例里的“有匹配就 MERGE”只展示回调结构,不应直接作为实际裁决策略。检索相关不代表两条记忆属于同一件事;实际接入应结合候选内容和匹配结果决定动作。
|
|
68
|
-
|
|
69
|
-
## DSH 界面:预览、恢复与确认
|
|
70
|
-
|
|
71
|
-
DSH 管理界面使用可持久化的导入任务,而不是只调用一次严格解析器:
|
|
72
|
-
|
|
73
|
-
1. **创建任务并解析。** 保存导入文本,尝试解析候选记忆。合法 JSON 进入逐条处理;解析失败的任务进入 `extracting` 状态,由运行时调用模型尝试恢复候选。
|
|
74
|
-
2. **逐条比较。** 每条候选只与有限数量的本地 Event 比较。核心任务默认 `topK=5`,限制在 1–20;与已有有效记忆或本批次较早候选完全重复的内容会确定性地选择 IGNORE。
|
|
75
|
-
3. **生成处理建议。** 模型决定新增、合并、取代、冲突或忽略。引用仅限本次匹配范围;需要既有目标却没有有效目标的建议会降低置信度。
|
|
76
|
-
4. **确认与提交。** 正常解析的候选在置信度达到当前阈值 0.85 时无需逐项确认;低置信度项需要确认。由不合格 JSON 恢复出来的候选会强制进入确认流程,不能仅凭高置信度自动放行。
|
|
77
|
-
|
|
78
|
-
严格的 `parseExternalMemoryExport()` / `externalMemoryJsonExtractor` 本身不会调用模型修复 JSON。模型兜底属于 DSH 运行时的任务编排;恢复不出候选时,任务失败并记录错误。
|
|
79
|
-
|
|
80
|
-
## 进度保存与失败重试
|
|
81
|
-
|
|
82
|
-
任务保存原始输入、候选列表、已处理数量、逐条决定及错误信息。关闭后重新打开页面可以继续查看任务,不需要重新粘贴原始内容。持久化使用需要通过 `StrataGate.open()` 打开数据库;内存模式不提供进程退出后的保留保证。
|
|
83
|
-
|
|
84
|
-
核心任务接口分别处理:
|
|
85
|
-
|
|
86
|
-
- `createExternalMemoryImportJob()`:创建任务并尝试严格解析。
|
|
87
|
-
- `completeExternalMemoryFallback()`:保存运行时模型恢复出的候选。
|
|
88
|
-
- `prepareNextExternalMemoryImport()` / `completeNextExternalMemoryImport()`:准备和保存单条裁决;模型调用在事务外执行。
|
|
89
|
-
- `retryExternalMemoryImportJob()`:将失败任务恢复到解析恢复或逐条处理阶段,保留已保存进度。
|
|
90
|
-
|
|
91
|
-
这些接口管理任务状态;自定义接入方仍需驱动模型调用和后续提交。重复提交已经完成的候选索引不会再推进一次进度。
|
|
92
|
-
|
|
93
|
-
## 来源保留与批次撤销
|
|
94
|
-
|
|
95
|
-
正常导入把原文保存为来源 Block,新 Event 引用该来源。MERGE / SUPERSEDE 创建新的 Event,并维护旧事件状态和关系,不直接覆盖旧事件正文。只为新写入的 Event 安排后续投影任务。
|
|
96
|
-
|
|
97
|
-
显式撤销是独立操作:`undoExternalMemoryImport(sourceBlockId)` 会移除该批次导入的 Event,清理相应来源关系与派生数据,并按剩余替代关系恢复受影响的旧事件状态。它不等同于权重衰减,也不能理解为仅隐藏导入结果。DSH 界面提供提交后的批次撤销入口。
|
|
98
|
-
|
|
99
|
-
实现入口:[核心导入与任务状态](../packages/core/src/store.ts)、[格式与提示词](../packages/core/src/external-memory.ts)、[DSH 运行时](../src/runtime.ts)。
|
|
1
|
+
# 外部 AI 记忆导入
|
|
2
|
+
|
|
3
|
+
StrataGate 提供 `importExternalMemory()` 编排外部记忆迁移:
|
|
4
|
+
|
|
5
|
+
```text
|
|
6
|
+
外部 AI JSON
|
|
7
|
+
↓ extractor(候选 Event)
|
|
8
|
+
每个候选 Event → searchEvents()(确定性 BM25,Top-K)
|
|
9
|
+
↓ decider(ADD / MERGE / SUPERSEDE / CONFLICT / IGNORE)
|
|
10
|
+
写入新的规范 Event,保留来源和 supersedes/conflicts 关系
|
|
11
|
+
↓
|
|
12
|
+
只为新 Event 创建元素/知识图谱投影任务
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## 最小接入
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
import {
|
|
19
|
+
EXTERNAL_MEMORY_EXPORT_PROMPT_ZH_CN,
|
|
20
|
+
StrataGate,
|
|
21
|
+
externalMemoryJsonExtractor,
|
|
22
|
+
} from '@diqier/stratagate';
|
|
23
|
+
|
|
24
|
+
// 把 EXTERNAL_MEMORY_EXPORT_PROMPT_ZH_CN 交给外部 AI,并把它返回的 JSON 放入 text。
|
|
25
|
+
const result = await memory.importExternalMemory({
|
|
26
|
+
text,
|
|
27
|
+
extractor: externalMemoryJsonExtractor,
|
|
28
|
+
topK: 5,
|
|
29
|
+
decider: async ({ candidate, matches }) => {
|
|
30
|
+
// 这里通常调用你的 LLM;它只能从 matches 中选择 existingEventIds。
|
|
31
|
+
// 返回的 MERGE/SUPERSEDE 会创建新 Event,不会覆盖旧 Event。
|
|
32
|
+
return {
|
|
33
|
+
action: matches.length === 0 ? 'ADD' : 'MERGE',
|
|
34
|
+
existingEventIds: matches.slice(0, 1).map(({ event }) => event.id),
|
|
35
|
+
mergedCandidate: candidate,
|
|
36
|
+
};
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
`decider` 的 `matches` 已经被限制为 `topK` 条;即使模型返回其它事件 ID,库也会丢弃这些越界引用。`IGNORE` 只留下审计记录,不会写入 Event。`CONFLICT` 会在新旧事件两侧建立对称的 `conflictsWithEventIds`。
|
|
42
|
+
|
|
43
|
+
## 给外部 AI 的提示词
|
|
44
|
+
|
|
45
|
+
直接使用导出的 `EXTERNAL_MEMORY_EXPORT_PROMPT_ZH_CN`。它要求外部 AI 只输出 `stratagate.external-memory.v2` JSON,并区分 `memoryKind`(instruction/preference/fact/event)与 `category`,同时特别约束时间:
|
|
46
|
+
|
|
47
|
+
- `mentionedAt`(被提及时间)与 `happenedStart/happenedEnd`(实际发生/计划时间)分开;
|
|
48
|
+
- 没有明确时间或可靠参照时,不填写日期,不把当前时间、导出时间或聊天顺序当作事件时间;
|
|
49
|
+
- 保留 `originalText`,用 `precision` 和 `basis` 标记粒度与依据;
|
|
50
|
+
- “上周”等相对时间只有在能依据已知消息时间唯一换算时才转换,否则保持 `unknown`。
|
|
51
|
+
|
|
52
|
+
如果外部 AI 仍然返回 Markdown 代码块,`parseExternalMemoryExport()` 会自动去除围栏;其它非 JSON 文本会被拒绝,避免把模型解释误写进记忆。
|
|
53
|
+
|
|
54
|
+
用于第二阶段裁决的系统提示词可使用 `EXTERNAL_MEMORY_DECIDER_PROMPT_ZH_CN`。它明确规定了五种写入动作的边界,并要求模型只能引用本次 Top-K 结果中的事件 ID。
|
|
55
|
+
|
|
56
|
+
## 导出常量、格式与解析器
|
|
57
|
+
|
|
58
|
+
| 入口 | 用途 |
|
|
59
|
+
| --- | --- |
|
|
60
|
+
| `EXTERNAL_MEMORY_EXPORT_PROMPT_ZH_CN` | 交给外部 AI,要求生成 `stratagate.external-memory.v2` JSON |
|
|
61
|
+
| `parseExternalMemoryExport()` | 严格解析导出内容,允许去除 Markdown 代码围栏 |
|
|
62
|
+
| `externalMemoryJsonExtractor` | 将严格 JSON 解析包装为可直接传给核心导入 API 的 extractor |
|
|
63
|
+
| `EXTERNAL_MEMORY_DECIDER_PROMPT_ZH_CN` | 指导裁决模型从 ADD、MERGE、SUPERSEDE、CONFLICT、IGNORE 中选择动作 |
|
|
64
|
+
|
|
65
|
+
v2 将记忆性质 `memoryKind` 与内容分类 `category` 分开。决定如何导入时,应同时保留原始说法、来源和时间依据;未知日期不应由导出日期补齐。最小接入示例中的 `memory` 是已经打开的 StrataGate 实例,`text` 是外部 AI 返回的内容。
|
|
66
|
+
|
|
67
|
+
示例里的“有匹配就 MERGE”只展示回调结构,不应直接作为实际裁决策略。检索相关不代表两条记忆属于同一件事;实际接入应结合候选内容和匹配结果决定动作。
|
|
68
|
+
|
|
69
|
+
## DSH 界面:预览、恢复与确认
|
|
70
|
+
|
|
71
|
+
DSH 管理界面使用可持久化的导入任务,而不是只调用一次严格解析器:
|
|
72
|
+
|
|
73
|
+
1. **创建任务并解析。** 保存导入文本,尝试解析候选记忆。合法 JSON 进入逐条处理;解析失败的任务进入 `extracting` 状态,由运行时调用模型尝试恢复候选。
|
|
74
|
+
2. **逐条比较。** 每条候选只与有限数量的本地 Event 比较。核心任务默认 `topK=5`,限制在 1–20;与已有有效记忆或本批次较早候选完全重复的内容会确定性地选择 IGNORE。
|
|
75
|
+
3. **生成处理建议。** 模型决定新增、合并、取代、冲突或忽略。引用仅限本次匹配范围;需要既有目标却没有有效目标的建议会降低置信度。
|
|
76
|
+
4. **确认与提交。** 正常解析的候选在置信度达到当前阈值 0.85 时无需逐项确认;低置信度项需要确认。由不合格 JSON 恢复出来的候选会强制进入确认流程,不能仅凭高置信度自动放行。
|
|
77
|
+
|
|
78
|
+
严格的 `parseExternalMemoryExport()` / `externalMemoryJsonExtractor` 本身不会调用模型修复 JSON。模型兜底属于 DSH 运行时的任务编排;恢复不出候选时,任务失败并记录错误。
|
|
79
|
+
|
|
80
|
+
## 进度保存与失败重试
|
|
81
|
+
|
|
82
|
+
任务保存原始输入、候选列表、已处理数量、逐条决定及错误信息。关闭后重新打开页面可以继续查看任务,不需要重新粘贴原始内容。持久化使用需要通过 `StrataGate.open()` 打开数据库;内存模式不提供进程退出后的保留保证。
|
|
83
|
+
|
|
84
|
+
核心任务接口分别处理:
|
|
85
|
+
|
|
86
|
+
- `createExternalMemoryImportJob()`:创建任务并尝试严格解析。
|
|
87
|
+
- `completeExternalMemoryFallback()`:保存运行时模型恢复出的候选。
|
|
88
|
+
- `prepareNextExternalMemoryImport()` / `completeNextExternalMemoryImport()`:准备和保存单条裁决;模型调用在事务外执行。
|
|
89
|
+
- `retryExternalMemoryImportJob()`:将失败任务恢复到解析恢复或逐条处理阶段,保留已保存进度。
|
|
90
|
+
|
|
91
|
+
这些接口管理任务状态;自定义接入方仍需驱动模型调用和后续提交。重复提交已经完成的候选索引不会再推进一次进度。
|
|
92
|
+
|
|
93
|
+
## 来源保留与批次撤销
|
|
94
|
+
|
|
95
|
+
正常导入把原文保存为来源 Block,新 Event 引用该来源。MERGE / SUPERSEDE 创建新的 Event,并维护旧事件状态和关系,不直接覆盖旧事件正文。只为新写入的 Event 安排后续投影任务。
|
|
96
|
+
|
|
97
|
+
显式撤销是独立操作:`undoExternalMemoryImport(sourceBlockId)` 会移除该批次导入的 Event,清理相应来源关系与派生数据,并按剩余替代关系恢复受影响的旧事件状态。它不等同于权重衰减,也不能理解为仅隐藏导入结果。DSH 界面提供提交后的批次撤销入口。
|
|
98
|
+
|
|
99
|
+
实现入口:[核心导入与任务状态](../packages/core/src/store.ts)、[格式与提示词](../packages/core/src/external-memory.ts)、[DSH 运行时](../src/runtime.ts)。
|