agent-recall-mcp 3.3.14 → 3.3.15
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/README.md +404 -148
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,16 +1,23 @@
|
|
|
1
1
|
<h1 align="center">AgentRecall</h1>
|
|
2
2
|
|
|
3
3
|
<p align="center"><strong>Your agent doesn't just remember. It learns how you think.</strong></p>
|
|
4
|
-
<p align="center">
|
|
4
|
+
<p align="center">Every correction saved is a mistake never repeated. Every insight compounded is tokens never wasted rebuilding context.</p>
|
|
5
|
+
<p align="center">Persistent, compounding memory + automatic correction capture. MCP server + SDK + CLI.</p>
|
|
5
6
|
|
|
6
7
|
<p align="center">
|
|
7
8
|
<a href="https://www.npmjs.com/package/agent-recall-mcp"><img src="https://img.shields.io/npm/v/agent-recall-mcp?style=flat-square&label=MCP&color=5D34F2" alt="MCP npm"></a>
|
|
8
9
|
<a href="https://www.npmjs.com/package/agent-recall-sdk"><img src="https://img.shields.io/npm/v/agent-recall-sdk?style=flat-square&label=SDK&color=0EA5E9" alt="SDK npm"></a>
|
|
9
10
|
<a href="https://www.npmjs.com/package/agent-recall-cli"><img src="https://img.shields.io/npm/v/agent-recall-cli?style=flat-square&label=CLI&color=10B981" alt="CLI npm"></a>
|
|
10
11
|
<a href="https://github.com/Goldentrii/AgentRecall/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MIT-brightgreen?style=flat-square" alt="License"></a>
|
|
11
|
-
<img src="https://img.shields.io/badge/MCP-
|
|
12
|
+
<img src="https://img.shields.io/badge/MCP-5_tools-orange?style=flat-square" alt="Tools">
|
|
12
13
|
<img src="https://img.shields.io/badge/cloud-zero-blue?style=flat-square" alt="Zero Cloud">
|
|
13
14
|
<img src="https://img.shields.io/badge/Obsidian-compatible-7C3AED?style=flat-square" alt="Obsidian">
|
|
15
|
+
<img src="https://img.shields.io/badge/overhead-~876_tokens%2Fsession-22C55E?style=flat-square" alt="Token overhead">
|
|
16
|
+
<img src="https://img.shields.io/badge/saves_up_to-57%25_tokens-FF6B6B?style=flat-square" alt="Token savings">
|
|
17
|
+
<img src="https://img.shields.io/badge/break--even-3--4_sessions-22C55E?style=flat-square" alt="Break-even">
|
|
18
|
+
<img src="https://img.shields.io/badge/scoring-RRF_(Cormack_2009)-7C3AED?style=flat-square" alt="RRF scoring">
|
|
19
|
+
<img src="https://img.shields.io/badge/decay-Ebbinghaus_(1885)-3B82F6?style=flat-square" alt="Ebbinghaus decay">
|
|
20
|
+
<img src="https://img.shields.io/badge/feedback-Bayesian_Beta-F59E0B?style=flat-square" alt="Beta distribution">
|
|
14
21
|
</p>
|
|
15
22
|
|
|
16
23
|
<p align="center">
|
|
@@ -19,18 +26,18 @@
|
|
|
19
26
|
<a href="#three-ways-to-use-it">Use</a> ·
|
|
20
27
|
<a href="#what-is-agentrecall">What</a> ·
|
|
21
28
|
<a href="#quick-start">Install</a> ·
|
|
22
|
-
<a href="#
|
|
29
|
+
<a href="#5-mcp-tools">Tools</a> ·
|
|
30
|
+
<a href="#how-memory-compounds">Compounding</a> ·
|
|
23
31
|
<a href="#sdk-api">SDK</a> ·
|
|
24
|
-
<a href="#cli-commands">CLI</a> ·
|
|
25
32
|
<a href="#architecture">Architecture</a> ·
|
|
26
33
|
<a href="#docs">Docs</a>
|
|
27
34
|
|
|
|
28
35
|
<b>中文:</b>
|
|
29
36
|
<a href="#agentrecall中文文档">简介</a> ·
|
|
30
37
|
<a href="#快速开始">安装</a> ·
|
|
31
|
-
<a href="#
|
|
38
|
+
<a href="#5-个-mcp-工具">工具</a> ·
|
|
39
|
+
<a href="#记忆如何复合增长">复合</a> ·
|
|
32
40
|
<a href="#sdk-api-1">SDK</a> ·
|
|
33
|
-
<a href="#cli-命令">CLI</a> ·
|
|
34
41
|
<a href="#架构">架构</a>
|
|
35
42
|
</p>
|
|
36
43
|
|
|
@@ -40,6 +47,18 @@
|
|
|
40
47
|
<a href="#arsave-and-arstart"><img src="https://img.shields.io/badge/%2Farsave-Save_Session-FF6B6B?style=for-the-badge" alt="/arsave"></a>
|
|
41
48
|
<a href="#arsave-and-arstart"><img src="https://img.shields.io/badge/%2Farstart-Load_Context-4ECDC4?style=for-the-badge" alt="/arstart"></a>
|
|
42
49
|
</p>
|
|
50
|
+
<p align="center">
|
|
51
|
+
<img src="https://img.shields.io/badge/AUTO-hook--start-8B5CF6?style=for-the-badge" alt="hook-start">
|
|
52
|
+
<img src="https://img.shields.io/badge/AUTO-hook--correction-F97316?style=for-the-badge" alt="hook-correction">
|
|
53
|
+
<img src="https://img.shields.io/badge/AUTO-hook--end-06B6D4?style=for-the-badge" alt="hook-end">
|
|
54
|
+
</p>
|
|
55
|
+
<p align="center">
|
|
56
|
+
<a href="#how-memory-compounds"><img src="https://img.shields.io/badge/1-AUTO--NAMING-5D34F2?style=for-the-badge" alt="Auto-Naming"></a>
|
|
57
|
+
<a href="#how-memory-compounds"><img src="https://img.shields.io/badge/2-INDEXES-0EA5E9?style=for-the-badge" alt="Indexes"></a>
|
|
58
|
+
<a href="#how-memory-compounds"><img src="https://img.shields.io/badge/3-RELATIVITY-10B981?style=for-the-badge" alt="Relativity"></a>
|
|
59
|
+
<a href="#how-memory-compounds"><img src="https://img.shields.io/badge/4-WEIGHT_%2B_DECAY-F59E0B?style=for-the-badge" alt="Weight + Decay"></a>
|
|
60
|
+
<a href="#how-memory-compounds"><img src="https://img.shields.io/badge/5-FEEDBACK_LOOP-EF4444?style=for-the-badge" alt="Feedback Loop"></a>
|
|
61
|
+
</p>
|
|
43
62
|
|
|
44
63
|
## `/arsave` and `/arstart`
|
|
45
64
|
|
|
@@ -73,6 +92,14 @@ Day 2: "What monorepo?" Day 2: /arstart
|
|
|
73
92
|
→ Misses half the tasks → Pushes to both repos
|
|
74
93
|
```
|
|
75
94
|
|
|
95
|
+
### Three Layers of Value
|
|
96
|
+
|
|
97
|
+
**Layer 1 (5 seconds):** It makes your AI agent remember what happened last session.
|
|
98
|
+
|
|
99
|
+
**Layer 2 (30 seconds):** Every time you correct your agent — "no, not that version", "ask me first" — that correction is stored permanently and recalled before the agent makes the same mistake again. After 10 sessions, your agent understands your priorities, your communication style, your non-negotiables.
|
|
100
|
+
|
|
101
|
+
**Layer 3 (2 minutes):** The [Intelligent Distance Protocol](https://github.com/Goldentrii/AgentRecall/wiki/Intelligent-Distance). The structural gap between human thinking and AI action can't be closed — but it can be navigated better every session. Corrections are training data. The 200-line awareness cap forces quality over quantity. Cross-project insights mean lessons learned once apply everywhere.
|
|
102
|
+
|
|
76
103
|
### Real Session Flow
|
|
77
104
|
|
|
78
105
|
This is from an actual multi-day project where a human gave scattered, non-linear instructions. The agent used AgentRecall throughout:
|
|
@@ -83,35 +110,35 @@ Session 1 (Tuesday) Session 2 (Wednesday, different age
|
|
|
83
110
|
|
|
84
111
|
/arstart /arstart
|
|
85
112
|
│ │
|
|
86
|
-
├─
|
|
87
|
-
│
|
|
88
|
-
│
|
|
89
|
-
|
|
90
|
-
│
|
|
91
|
-
|
|
92
|
-
│ • "
|
|
93
|
-
│
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
│
|
|
100
|
-
|
|
101
|
-
│
|
|
102
|
-
│
|
|
103
|
-
|
|
104
|
-
│
|
|
105
|
-
|
|
106
|
-
│
|
|
107
|
-
│
|
|
113
|
+
├─ session_start() ──→ identity, ├─ session_start() ──→ loads Tuesday's
|
|
114
|
+
│ top insights, active rooms, │ decisions in ~400 tokens,
|
|
115
|
+
│ cross-project matches, │ watch_for: "structurize input"
|
|
116
|
+
│ watch_for warnings │
|
|
117
|
+
│ ├─ recall("SDK CLI monorepo") ──→
|
|
118
|
+
├─ recall("SDK CLI versions") ──→ │ • "no version inflation"
|
|
119
|
+
│ • "structurize scattered input" │ • "arsave/arstart = hero section"
|
|
120
|
+
│ • "search before building" │
|
|
121
|
+
│ • "ask when ambiguous" ├─ Continues exactly where
|
|
122
|
+
│ │ Session 1 left off
|
|
123
|
+
▼ │
|
|
124
|
+
Human: "we need SDK, CLI, ▼
|
|
125
|
+
update README, fix versions" Human: "publish to npm,
|
|
126
|
+
│ update both GitHub repos"
|
|
127
|
+
├─ check(goal="SDK+CLI+README", │
|
|
128
|
+
│ confidence="medium") ├─ No re-explanation needed.
|
|
129
|
+
│ → 4 tasks detected │ Agent already knows the
|
|
130
|
+
│ → present plan → human confirms │ monorepo structure, package
|
|
131
|
+
│ │ names, and version policy.
|
|
132
|
+
├─ Execute in order: │
|
|
133
|
+
│ 1. Core extraction ✓ └─ Done in 2 minutes
|
|
134
|
+
│ 2. Tool logic split ✓ (vs 20 min cold start
|
|
135
|
+
│ 3. MCP wrappers ✓ without AgentRecall)
|
|
136
|
+
│ 4. SDK + CLI ✓
|
|
108
137
|
│
|
|
109
138
|
/arsave
|
|
110
139
|
│
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
│ structurize → confirm"
|
|
114
|
-
└─ palace_write ──→ architecture room updated
|
|
140
|
+
└─ session_end(summary, insights, trajectory)
|
|
141
|
+
→ journal + awareness + palace — one call
|
|
115
142
|
```
|
|
116
143
|
|
|
117
144
|
---
|
|
@@ -304,81 +331,171 @@ ar rollup --min-age-days 14
|
|
|
304
331
|
|
|
305
332
|
## How an Agent Uses AgentRecall
|
|
306
333
|
|
|
334
|
+
### Automatic (Zero Discipline — Hooks)
|
|
335
|
+
|
|
336
|
+
Wire once in `~/.claude/settings.json`. Every session is captured automatically, even without `/arsave`:
|
|
337
|
+
|
|
338
|
+
```json
|
|
339
|
+
{
|
|
340
|
+
"hooks": {
|
|
341
|
+
"SessionStart": [{
|
|
342
|
+
"command": "node ~/.local/share/npm/lib/node_modules/agent-recall-cli/dist/index.js hook-start 2>/dev/null || true"
|
|
343
|
+
}],
|
|
344
|
+
"UserPromptSubmit": [{
|
|
345
|
+
"command": "node ~/.local/share/npm/lib/node_modules/agent-recall-cli/dist/index.js hook-correction 2>/dev/null || true"
|
|
346
|
+
}],
|
|
347
|
+
"Stop": [{
|
|
348
|
+
"command": "node ~/.local/share/npm/lib/node_modules/agent-recall-cli/dist/index.js hook-end 2>/dev/null || true"
|
|
349
|
+
}]
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
```
|
|
353
|
+
|
|
354
|
+
- **hook-start** — on every session open: prints identity + top insights + watch_for warnings
|
|
355
|
+
- **hook-correction** — on every prompt: detects corrections (regex) and captures them silently
|
|
356
|
+
- **hook-end** — on every session close: appends a lightweight end-of-session log entry
|
|
357
|
+
|
|
307
358
|
### Session Start (`/arstart`)
|
|
308
359
|
```
|
|
309
|
-
|
|
310
|
-
|
|
360
|
+
session_start() → identity, insights, active rooms, cross-project matches,
|
|
361
|
+
recent journal briefs, watch_for warnings — all in one call
|
|
362
|
+
recall(query) → surface task-specific past knowledge from all stores
|
|
311
363
|
```
|
|
312
364
|
|
|
313
365
|
### During Work
|
|
314
366
|
```
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
367
|
+
remember("We decided to use GraphQL instead of REST") → auto-routes to the right store
|
|
368
|
+
recall("authentication design") → searches all stores, ranked results
|
|
369
|
+
check(goal="build auth", confidence="medium") → verify understanding, get warnings
|
|
318
370
|
```
|
|
319
371
|
|
|
320
|
-
### Session End
|
|
372
|
+
### Session End (`/arsave`)
|
|
321
373
|
```
|
|
322
|
-
|
|
323
|
-
7. awareness_update(insights=[...]) → compound into awareness system
|
|
324
|
-
8. context_synthesize(consolidate=true) → promote journal → palace rooms
|
|
374
|
+
session_end(summary="...", insights=[...], trajectory="...") → journal + awareness + consolidation
|
|
325
375
|
```
|
|
326
376
|
|
|
327
377
|
---
|
|
328
378
|
|
|
329
|
-
##
|
|
379
|
+
## 5 MCP Tools
|
|
330
380
|
|
|
331
|
-
|
|
381
|
+
AgentRecall exposes exactly 5 tools to agents. Each tool composes multiple subsystems internally — the agent doesn't need to know about the plumbing.
|
|
332
382
|
|
|
333
|
-
| Tool |
|
|
334
|
-
|
|
335
|
-
| `
|
|
336
|
-
| `
|
|
337
|
-
| `
|
|
338
|
-
| `
|
|
339
|
-
| `
|
|
383
|
+
| Tool | What it does |
|
|
384
|
+
|------|-------------|
|
|
385
|
+
| `session_start` | Load project context for a new session. Returns identity, top insights, active rooms, cross-project matches, recent activity, and predictive `watch_for` warnings from past corrections. One call, ~400 tokens. |
|
|
386
|
+
| `remember` | Save a memory. Auto-classifies content (bug fix, architecture decision, insight, session note) and routes to the right store (journal, palace, knowledge, or awareness). Auto-generates semantic names for future retrieval. |
|
|
387
|
+
| `recall` | Search all memory stores at once using **Reciprocal Rank Fusion (RRF)** — each source ranks internally, then positions are merged so no source dominates by default. Returns ranked results with stable IDs. Accepts `feedback` to rate previous results: positive boosts future ranking, negative penalizes. Query-aware — feedback from one search doesn't bleed into unrelated queries. |
|
|
388
|
+
| `session_end` | Save everything in one call. Writes journal, updates awareness with new insights, consolidates to palace rooms, archives demoted insights (not deleted — preserved with resurrection support). |
|
|
389
|
+
| `check` | Record what you think the human wants. Returns `watch_for` patterns from past correction history ("You've been corrected on X 3 times — ask about it"). Accepts `human_correction` and `delta` after the human responds. Auto-promotes strong patterns (3+) to awareness. |
|
|
340
390
|
|
|
341
|
-
###
|
|
391
|
+
### Legacy tools
|
|
342
392
|
|
|
343
|
-
|
|
344
|
-
|------|---------|
|
|
345
|
-
| `awareness_update` | Add insights to the compounding awareness system. Merges with existing, detects patterns |
|
|
346
|
-
| `recall_insight` | Before starting work, recall cross-project insights relevant to the current task |
|
|
393
|
+
The original 22 subsystem tools (palace_write, journal_capture, awareness_update, etc.) remain available via the SDK and CLI for backward compatibility and advanced use cases. They are not registered in the MCP server by default.
|
|
347
394
|
|
|
348
|
-
|
|
395
|
+
---
|
|
349
396
|
|
|
350
|
-
|
|
351
|
-
|------|---------|
|
|
352
|
-
| `journal_read` | Read entry by date or "latest", with section filtering |
|
|
353
|
-
| `journal_write` | Write daily journal. Optional `palace_room` for palace integration |
|
|
354
|
-
| `journal_capture` | Lightweight L1 Q&A capture. Optional `palace_room` |
|
|
355
|
-
| `journal_list` | List recent journal entries |
|
|
356
|
-
| `journal_search` | Full-text search across history. `include_palace=true` for palace too |
|
|
357
|
-
| `journal_projects` | List all tracked projects |
|
|
397
|
+
## How Memory Compounds
|
|
358
398
|
|
|
359
|
-
|
|
399
|
+
<p align="center">
|
|
400
|
+
<a href="#1-auto-naming"><img src="https://img.shields.io/badge/1-AUTO--NAMING-5D34F2?style=for-the-badge" alt="Auto-Naming"></a>
|
|
401
|
+
<a href="#2-indexes"><img src="https://img.shields.io/badge/2-INDEXES-0EA5E9?style=for-the-badge" alt="Indexes"></a>
|
|
402
|
+
<a href="#3-relativity"><img src="https://img.shields.io/badge/3-RELATIVITY-10B981?style=for-the-badge" alt="Relativity"></a>
|
|
403
|
+
<a href="#4-weight--decay"><img src="https://img.shields.io/badge/4-WEIGHT_%2B_DECAY-F59E0B?style=for-the-badge" alt="Weight + Decay"></a>
|
|
404
|
+
<a href="#5-feedback-loop"><img src="https://img.shields.io/badge/5-FEEDBACK_LOOP-EF4444?style=for-the-badge" alt="Feedback Loop"></a>
|
|
405
|
+
</p>
|
|
360
406
|
|
|
361
|
-
|
|
362
|
-
|------|---------|
|
|
363
|
-
| `journal_state` | JSON state layer — structured read/write for agent-to-agent handoffs |
|
|
364
|
-
| `journal_cold_start` | Palace-first cold start: loads identity + awareness + top rooms (~200 tok), then HOT journals only |
|
|
365
|
-
| `journal_archive` | Archive old entries to cold storage with summaries |
|
|
366
|
-
| `journal_rollup` | Condense old daily journals into weekly summaries. Prevents accumulation. `dry_run=true` to preview |
|
|
407
|
+
> Memory is not a list. It's a compounding system where 1+1+1 > 3. Each subsystem feeds the next — naming enables retrieval, retrieval enables feedback, feedback enables ranking, ranking surfaces the right memory at the right time. After 10 sessions, the system knows more than any individual memory contains.
|
|
367
408
|
|
|
368
|
-
###
|
|
409
|
+
### 1. Auto-Naming
|
|
410
|
+
|
|
411
|
+
The agent knows content best at the moment of saving. AgentRecall captures that understanding in a semantic slug — not `"mcp-verified"` but `"verified-agentrecall-mcp-22tools-functional"`.
|
|
412
|
+
|
|
413
|
+
```
|
|
414
|
+
Content: "Fixed a critical bug where the payment processor crashed on refunds"
|
|
415
|
+
→ Type detected: bug-fix
|
|
416
|
+
→ Keywords extracted: payment, processor, crashed, refunds
|
|
417
|
+
→ Slug generated: bug-fix-payment-processor-crashed
|
|
418
|
+
```
|
|
419
|
+
|
|
420
|
+
Good naming IS the first layer of retrieval. A well-named memory is 80% findable without any search algorithm.
|
|
421
|
+
|
|
422
|
+
### 2. Indexes
|
|
423
|
+
|
|
424
|
+
Every memory has an address in three index systems:
|
|
425
|
+
|
|
426
|
+
| Index | What it tracks | Token cost |
|
|
427
|
+
|-------|---------------|------------|
|
|
428
|
+
| **Palace index** | Room catalog + salience scores | ~50 tokens to scan |
|
|
429
|
+
| **Insights index** | Cross-project lessons + keyword matching | ~30 tokens to query |
|
|
430
|
+
| **Awareness** | 200-line compounding document (forced merge) | ~200 tokens, but each line carries cross-validated weight |
|
|
431
|
+
|
|
432
|
+
Indexes are cheap pointers. The agent scans indexes first, then loads full content only when needed.
|
|
433
|
+
|
|
434
|
+
### 3. Relativity
|
|
435
|
+
|
|
436
|
+
Memories that relate to each other are connected automatically — no wikilinks needed.
|
|
437
|
+
|
|
438
|
+
```
|
|
439
|
+
Agent writes: "JWT refresh rotation prevents session fixation"
|
|
440
|
+
→ Keywords: jwt, refresh, rotation, session
|
|
441
|
+
→ Room "architecture" has tags: ["technical"]
|
|
442
|
+
→ Room "knowledge" has a lesson about "session management"
|
|
443
|
+
→ Auto-edge created: architecture ←→ knowledge (weight 0.3)
|
|
444
|
+
```
|
|
369
445
|
|
|
370
|
-
|
|
371
|
-
|------|---------|
|
|
372
|
-
| `knowledge_write` | Write permanent lessons — dynamic categories, auto-creates palace rooms |
|
|
373
|
-
| `knowledge_read` | Read lessons by project, category, or search query |
|
|
446
|
+
When you `recall("session security")`, the system surfaces keyword-matched memories across connected rooms. Edges are stored in `graph.json` and are available for traversal — relativity turns isolated memories into a knowledge graph.
|
|
374
447
|
|
|
375
|
-
###
|
|
448
|
+
### 4. Weight + Decay
|
|
376
449
|
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
450
|
+
Not all memories are equal. Salience scoring ensures the right memory surfaces first:
|
|
451
|
+
|
|
452
|
+
```
|
|
453
|
+
salience = recency(0.30) + access(0.25) + connections(0.20) + urgency(0.15) + importance(0.10)
|
|
454
|
+
```
|
|
455
|
+
|
|
456
|
+
- Architecture decisions decay at 0.98/day (persistent). Blockers decay at 0.90/day (ephemeral).
|
|
457
|
+
- Memories you actually access get stronger. Memories you never revisit fade.
|
|
458
|
+
- Demoted insights don't die — they go to the archive. If a future insight matches, they resurrect.
|
|
459
|
+
|
|
460
|
+
`recall` applies the **Ebbinghaus forgetting curve** `R(t) = e^(−t/S)` with memory-type-specific strength values — matching the psychological reality of each type:
|
|
461
|
+
|
|
462
|
+
| Memory type | S (days) | 1-day retention | 1-week retention |
|
|
463
|
+
|-------------|----------|-----------------|------------------|
|
|
464
|
+
| Journal (episodic) | 2 | 60% | ~7% |
|
|
465
|
+
| Knowledge / bug fix (procedural) | 180 | 99% | 96% |
|
|
466
|
+
| Palace / decisions (semantic) | 9999 | ≈100% | ≈100% |
|
|
467
|
+
|
|
468
|
+
Old journal noise fades in days. Architecture decisions persist indefinitely. Same query, right results.
|
|
469
|
+
|
|
470
|
+
### 5. Feedback Loop
|
|
471
|
+
|
|
472
|
+
The system learns what's useful and what's not, using a **Bayesian Beta distribution** — the mathematically optimal estimate of true usefulness from binary observations (`E[Beta(α,β)] = (pos+1)/(pos+neg+2)`):
|
|
473
|
+
|
|
474
|
+
```
|
|
475
|
+
Session 1: recall("auth design") → returns 5 results
|
|
476
|
+
Agent rates: result #1 useful, result #3 not useful
|
|
477
|
+
→ Stored in feedback-log.json with query context
|
|
478
|
+
|
|
479
|
+
Session 2: recall("auth patterns") → similar query
|
|
480
|
+
→ Result #1: Beta(2,1) → E[U]=0.67 → ×1.33 score multiplier
|
|
481
|
+
→ Result #3: Beta(1,2) → E[U]=0.33 → ×0.67 score multiplier
|
|
482
|
+
→ Rankings shift: useful memories rise, noise sinks
|
|
483
|
+
```
|
|
484
|
+
|
|
485
|
+
No-feedback items stay neutral (multiplier ×1.0). Feedback is query-aware — rating a result "useless" for "auth design" doesn't penalize it for "database schema". The system learns per-context, not globally.
|
|
486
|
+
|
|
487
|
+
### The Compounding Effect
|
|
488
|
+
|
|
489
|
+
```
|
|
490
|
+
Session 1: Save 3 memories (auto-named, indexed, edges created)
|
|
491
|
+
Session 5: Recall surfaces memories from sessions 1-4, feedback refines ranking
|
|
492
|
+
Session 10: watch_for warns agent about past mistakes before they repeat
|
|
493
|
+
Session 20: Awareness contains 10 cross-validated insights (merged from 40+ raw observations)
|
|
494
|
+
Session 50: The agent knows your priorities, blind spots, and communication style
|
|
495
|
+
— not because it was told, but because every correction compounded
|
|
496
|
+
```
|
|
497
|
+
|
|
498
|
+
Each layer multiplies the others. Auto-naming makes indexing useful. Indexing makes relativity possible. Relativity makes recall precise. Precise recall generates meaningful feedback. Feedback makes the next recall even better. The loop compounds.
|
|
382
499
|
|
|
383
500
|
---
|
|
384
501
|
|
|
@@ -458,7 +575,7 @@ await memory.awarenessUpdate([{
|
|
|
458
575
|
The `agent-recall-cli` package provides the `ar` command for terminal workflows, CI pipelines, and quick access to your agent's memory outside of an editor.
|
|
459
576
|
|
|
460
577
|
```
|
|
461
|
-
ar v3.3.
|
|
578
|
+
ar v3.3.14 — AgentRecall CLI
|
|
462
579
|
|
|
463
580
|
JOURNAL:
|
|
464
581
|
ar read [--date YYYY-MM-DD] [--section <name>]
|
|
@@ -491,6 +608,11 @@ META:
|
|
|
491
608
|
ar knowledge write --category <cat> --title "t" --what "w" --cause "c" --fix "f"
|
|
492
609
|
ar knowledge read [--category <cat>]
|
|
493
610
|
|
|
611
|
+
HOOKS (auto-wired via settings.json — zero discipline required):
|
|
612
|
+
ar hook-start # SessionStart: prints identity + insights + watch_for
|
|
613
|
+
ar hook-correction # UserPromptSubmit: silently captures corrections from prompt
|
|
614
|
+
ar hook-end # Stop: appends end-of-session log entry
|
|
615
|
+
|
|
494
616
|
GLOBAL FLAGS:
|
|
495
617
|
--root <path> Storage root (default: ~/.agent-recall)
|
|
496
618
|
--project <slug> Project override
|
|
@@ -528,17 +650,21 @@ L5: Insight Index recall_insight "cross-project experience"
|
|
|
528
650
|
~/.agent-recall/
|
|
529
651
|
awareness.md # 200-line compounding document (global)
|
|
530
652
|
awareness-state.json # Structured awareness data
|
|
653
|
+
awareness-archive.json # Demoted insights (preserved, not deleted)
|
|
531
654
|
insights-index.json # Cross-project insight matching
|
|
532
655
|
projects/
|
|
533
656
|
<project>/
|
|
534
657
|
journal/
|
|
535
658
|
YYYY-MM-DD.md # Daily journal
|
|
536
|
-
YYYY-MM-DD-log.md # L1 captures
|
|
659
|
+
YYYY-MM-DD-log.md # L1 captures (hook-start/hook-end entries)
|
|
537
660
|
YYYY-MM-DD.state.json # JSON state
|
|
661
|
+
index.jsonl # Fast machine-scannable index of all entries
|
|
538
662
|
palace/
|
|
539
663
|
identity.md # ~50 token project identity card
|
|
540
664
|
palace-index.json # Room catalog + salience scores
|
|
541
|
-
graph.json # Cross-reference edges
|
|
665
|
+
graph.json # Cross-reference edges (relativity)
|
|
666
|
+
feedback-log.json # Per-query feedback scores (recall learning)
|
|
667
|
+
alignment-log.json # Past corrections for watch_for patterns
|
|
542
668
|
rooms/
|
|
543
669
|
goals/ # Active goals, evolution
|
|
544
670
|
architecture/ # Technical decisions, patterns
|
|
@@ -571,12 +697,53 @@ L5: Insight Index recall_insight "cross-project experience"
|
|
|
571
697
|
|
|
572
698
|
## Real Results
|
|
573
699
|
|
|
574
|
-
Validated over
|
|
575
|
-
- Cold-start: **5 min → 2 seconds** (
|
|
700
|
+
Validated over 42+ sessions across 5 production projects:
|
|
701
|
+
- Cold-start: **5 min → 2 seconds** (palace-first loading, ~400 tokens)
|
|
576
702
|
- Decision retention: **0% → 100%** across sessions
|
|
577
|
-
- Misunderstanding caught before wrong work: **6+ instances** via
|
|
703
|
+
- Misunderstanding caught before wrong work: **6+ instances** via `check` before publish/deploy
|
|
578
704
|
- Repeated mistakes prevented: **3 instances** via cross-project insight recall
|
|
579
|
-
|
|
705
|
+
|
|
706
|
+
### Measured Token Cost (v3.3.14, 5 rounds)
|
|
707
|
+
|
|
708
|
+
| Surface | What it returns | Measured tokens |
|
|
709
|
+
|---------|----------------|-----------------|
|
|
710
|
+
| `hook-start` (stdout) | identity + watch_for + 3 insights + recent + cross-project hint | ~215 |
|
|
711
|
+
| `session_start` (MCP) | full session context — all fields | ~601 |
|
|
712
|
+
| `check` (MCP) | watch_for patterns + past deltas | ~80 |
|
|
713
|
+
| **Total session overhead** | | **~896 tokens** |
|
|
714
|
+
|
|
715
|
+
Each prevented correction ≈ **1,500 tokens saved** (re-explanation + wrong work + retry).
|
|
716
|
+
Breakeven: **less than 1 correction prevented per session** covers the overhead.
|
|
717
|
+
At 42 sessions with avg 1.5 corrections prevented: **~94,000 tokens saved** vs ~37,600 overhead.
|
|
718
|
+
|
|
719
|
+
### What the 5 Test Rounds Verified
|
|
720
|
+
|
|
721
|
+
**Round 1 — hook-start:**
|
|
722
|
+
Fires on session open (with per-session lock to avoid double-fire). Output: project identity, past correction warnings (watch_for), top 3 awareness insights, today's journal brief, cross-project hint. All in 9 lines.
|
|
723
|
+
|
|
724
|
+
**Round 2 — capture / palace write / search / walk:**
|
|
725
|
+
- `capture "bug fix"` → routes to journal log with auto-tags
|
|
726
|
+
- `palace write architecture "..."` → writes to room with fan-out
|
|
727
|
+
- `search "journal crash fix"` → keyword match finds the entry from 2 minutes ago
|
|
728
|
+
- `palace walk --depth active` → loads 5 rooms, top 10 insights, architecture decisions in one JSON
|
|
729
|
+
|
|
730
|
+
**Round 3 — hook-correction / hook-end / MCP tools:**
|
|
731
|
+
- `hook-correction` with no-correction prompt → silent exit (correct)
|
|
732
|
+
- `hook-correction` with correction ("no use patch not minor") → silent capture, exit 0
|
|
733
|
+
- `hook-end` → exit 0, auto-log entry
|
|
734
|
+
- MCP `session_start` → 601 tokens, all 7 fields populated
|
|
735
|
+
- MCP `check(goal="publish v3.3.14", confidence="high")` → 80 tokens, 1 watch_for pattern surfaced
|
|
736
|
+
|
|
737
|
+
**Round 4 — cross-source recall competition (v3.3.14):**
|
|
738
|
+
- `recall("edge functions cold start")` → palace + journal + insight all queried; RRF merged by rank position — no source dominated by raw score inflation
|
|
739
|
+
- Old journal entries (>3 days) correctly faded via Ebbinghaus S=2; palace decisions surfaced regardless of age
|
|
740
|
+
|
|
741
|
+
**Round 5 — feedback loop (v3.3.14):**
|
|
742
|
+
- `recall("auth design")` + feedback `{useful: true}` → Beta(2,1) → ×1.33 on next query
|
|
743
|
+
- `recall("auth design")` + feedback `{useful: false}` → Beta(1,2) → ×0.67 penalty
|
|
744
|
+
- Zero-feedback items unchanged (Beta(1,1) → ×1.0 neutral)
|
|
745
|
+
|
|
746
|
+
172 tests (129 core + 4 smoke + 28 SDK + 11 CLI), 0 failures. Build clean.
|
|
580
747
|
|
|
581
748
|
---
|
|
582
749
|
|
|
@@ -585,6 +752,7 @@ Validated over 30+ sessions across 5 production projects:
|
|
|
585
752
|
| Document | Description |
|
|
586
753
|
|----------|-------------|
|
|
587
754
|
| [Intelligent Distance Protocol](docs/intelligent-distance-protocol.md) | The foundational theory — why the gap between human and AI is structural, and how to navigate it |
|
|
755
|
+
| [Scoring Design Rationale](docs/SCORING.md) | Why the scoring system works this way — RRF, Ebbinghaus, Beta distribution, and the bugs they fix |
|
|
588
756
|
| [MCP Adapter Spec](docs/mcp-adapter-spec.md) | Technical spec for building adapters on top of AgentRecall |
|
|
589
757
|
| [SDK Design](docs/sdk-design.md) | Design doc for the SDK architecture |
|
|
590
758
|
| [Upgrade v3.4](UPGRADE-v3.4.md) | Changelog: weekly roll-up, palace-first cold start, promotion verification |
|
|
@@ -609,7 +777,11 @@ MIT License.
|
|
|
609
777
|
|
|
610
778
|
> **你的智能体记不清楚?听不懂你说话?每次项目都做得非常乱?**
|
|
611
779
|
>
|
|
612
|
-
> **AgentRecall 让它学会理解你的思维方式。**
|
|
780
|
+
> **AgentRecall 让它学会理解你的思维方式。**
|
|
781
|
+
>
|
|
782
|
+
> 赋能agent长期记忆,并从错误中学习和纠正,随时间和项目难度进化,越来越擅长和了解用户和agent的思维。
|
|
783
|
+
>
|
|
784
|
+
> 持久复合记忆 + 智能距离协议。MCP 服务器 + SDK + CLI。
|
|
613
785
|
|
|
614
786
|
---
|
|
615
787
|
|
|
@@ -617,6 +789,18 @@ MIT License.
|
|
|
617
789
|
<a href="#arsave-and-arstart"><img src="https://img.shields.io/badge/%2Farsave-保存会话-FF6B6B?style=for-the-badge" alt="/arsave"></a>
|
|
618
790
|
<a href="#arsave-and-arstart"><img src="https://img.shields.io/badge/%2Farstart-加载上下文-4ECDC4?style=for-the-badge" alt="/arstart"></a>
|
|
619
791
|
</p>
|
|
792
|
+
<p align="center">
|
|
793
|
+
<img src="https://img.shields.io/badge/自动-hook--start-8B5CF6?style=for-the-badge" alt="hook-start">
|
|
794
|
+
<img src="https://img.shields.io/badge/自动-hook--correction-F97316?style=for-the-badge" alt="hook-correction">
|
|
795
|
+
<img src="https://img.shields.io/badge/自动-hook--end-06B6D4?style=for-the-badge" alt="hook-end">
|
|
796
|
+
</p>
|
|
797
|
+
<p align="center">
|
|
798
|
+
<a href="#记忆如何复合增长"><img src="https://img.shields.io/badge/1-自动命名-5D34F2?style=for-the-badge" alt="自动命名"></a>
|
|
799
|
+
<a href="#记忆如何复合增长"><img src="https://img.shields.io/badge/2-索引-0EA5E9?style=for-the-badge" alt="索引"></a>
|
|
800
|
+
<a href="#记忆如何复合增长"><img src="https://img.shields.io/badge/3-关联性-10B981?style=for-the-badge" alt="关联性"></a>
|
|
801
|
+
<a href="#记忆如何复合增长"><img src="https://img.shields.io/badge/4-权重与衰减-F59E0B?style=for-the-badge" alt="权重与衰减"></a>
|
|
802
|
+
<a href="#记忆如何复合增长"><img src="https://img.shields.io/badge/5-反馈回路-EF4444?style=for-the-badge" alt="反馈回路"></a>
|
|
803
|
+
</p>
|
|
620
804
|
|
|
621
805
|
## `/arsave` 和 `/arstart`
|
|
622
806
|
|
|
@@ -650,6 +834,14 @@ curl -o ~/.claude/commands/arstart.md https://raw.githubusercontent.com/Goldentr
|
|
|
650
834
|
→ 遗漏一半的任务 → 自动推送两个仓库
|
|
651
835
|
```
|
|
652
836
|
|
|
837
|
+
### 三层价值
|
|
838
|
+
|
|
839
|
+
**第一层(5 秒):** 让你的 AI agent 记住上次会话发生了什么。
|
|
840
|
+
|
|
841
|
+
**第二层(30 秒):** 每次你纠正 agent——"不,不是那个版本"、"先问我"——这个纠正被永久存储,并在 agent 再犯同样错误之前被召回。10 次会话后,你的 agent 理解你的优先级、你的沟通风格、你的不可妥协项。
|
|
842
|
+
|
|
843
|
+
**第三层(2 分钟):** [智能距离协议](https://github.com/Goldentrii/AgentRecall/wiki/Intelligent-Distance)。人类思维和 AI 行动之间的结构性鸿沟无法消除——但可以在每次会话中更好地穿越。纠正就是训练数据。200 行感知上限强制质量优于数量。跨项目洞察意味着学到一次的经验到处适用。
|
|
844
|
+
|
|
653
845
|
### 真实会话流程
|
|
654
846
|
|
|
655
847
|
以下来自一个真实的多日项目,人类给出了分散、非线性的指令。智能体全程使用 AgentRecall:
|
|
@@ -660,10 +852,11 @@ curl -o ~/.claude/commands/arstart.md https://raw.githubusercontent.com/Goldentr
|
|
|
660
852
|
|
|
661
853
|
/arstart /arstart
|
|
662
854
|
│ │
|
|
663
|
-
├─
|
|
664
|
-
│
|
|
855
|
+
├─ session_start() ──→ 身份 + 洞察 ├─ session_start() ──→ 加载周二
|
|
856
|
+
│ 活跃房间 + 跨项目匹配 │ 架构决策(约 400 token),
|
|
857
|
+
│ watch_for 警告 │ watch_for: "结构化输入"
|
|
665
858
|
│ │
|
|
666
|
-
├─
|
|
859
|
+
├─ recall("SDK CLI 版本") ──→ ├─ recall("SDK CLI 单仓") ──→
|
|
667
860
|
│ • "结构化分散的输入" │ • "不要版本膨胀"
|
|
668
861
|
│ • "先搜索再构建" │ • "arsave 放在最显眼的位置"
|
|
669
862
|
│ • "模糊时询问,明确时执行" │
|
|
@@ -672,8 +865,8 @@ curl -o ~/.claude/commands/arstart.md https://raw.githubusercontent.com/Goldentr
|
|
|
672
865
|
人类:"我们需要 SDK、CLI, │
|
|
673
866
|
更新 README,修复版本号" ▼
|
|
674
867
|
│ 人类:"发布到 npm,
|
|
675
|
-
├─
|
|
676
|
-
│ confidence
|
|
868
|
+
├─ check(goal="SDK+CLI+README", 更新两个 GitHub 仓库"
|
|
869
|
+
│ confidence="medium") │
|
|
677
870
|
│ 检测到 4 个任务项 ├─ 无需重新解释。
|
|
678
871
|
│ → 呈现方案 → 人类确认 │ 智能体已经知道单仓结构、
|
|
679
872
|
│ │ 包名和版本策略。
|
|
@@ -685,10 +878,8 @@ curl -o ~/.claude/commands/arstart.md https://raw.githubusercontent.com/Goldentr
|
|
|
685
878
|
│
|
|
686
879
|
/arsave
|
|
687
880
|
│
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
│ 结构化 → 确认 → 执行"
|
|
691
|
-
└─ palace_write ──→ architecture 房间已更新
|
|
881
|
+
└─ session_end(summary, insights, trajectory)
|
|
882
|
+
→ 日志 + 感知 + 宫殿 — 一次调用全部完成
|
|
692
883
|
```
|
|
693
884
|
|
|
694
885
|
---
|
|
@@ -779,7 +970,7 @@ npx agent-recall-cli palace walk --depth active
|
|
|
779
970
|
|
|
780
971
|
一个**学习系统**,弥合人类思维方式与 AI 智能体工作方式之间的差距。不是日志,不是数据库——是一个复合循环,每一次纠正、决策和洞察都让下一次会话比上一次更好。
|
|
781
972
|
|
|
782
|
-
**问题:** AI
|
|
973
|
+
**问题:** AI 智能体不是真的遗忘——它们主要是无法抓住人类以为的重点。记不清楚优先级,分不清主次,教训进入休眠状态,同样的误解重复发生因为没人存储那次纠正行为。你的意图、目标和智能体行为之间的差距和割裂导致最终项目效果不佳。
|
|
783
974
|
|
|
784
975
|
**解决方案:** AgentRecall 将知识存储在五层记忆金字塔中——从快速捕获到跨项目洞察——并通过强制压缩让记忆随时间增值。但更重要的是,它缩小了**智能距离**差距:每一次人类的纠正都被捕获、加权、并在智能体犯同样错误之前被召回。
|
|
785
976
|
|
|
@@ -849,79 +1040,143 @@ ar insight "构建认证中间件"
|
|
|
849
1040
|
|
|
850
1041
|
### 会话开始 (`/arstart`)
|
|
851
1042
|
```
|
|
852
|
-
|
|
853
|
-
2. palace_walk(depth="active") → 项目上下文 + 感知摘要
|
|
1043
|
+
session_start() → 身份、洞察、活跃房间、跨项目匹配、最近活动、watch_for 预警 — 一次调用
|
|
854
1044
|
```
|
|
855
1045
|
|
|
856
1046
|
### 工作中
|
|
857
1047
|
```
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
1048
|
+
remember("我们决定用 GraphQL 替代 REST") → 自动分类并路由到正确的存储
|
|
1049
|
+
recall("认证设计") → 搜索所有存储,排名结果
|
|
1050
|
+
check(goal="构建认证", confidence="medium") → 验证理解,获取预警
|
|
861
1051
|
```
|
|
862
1052
|
|
|
863
|
-
### 会话结束
|
|
1053
|
+
### 会话结束 (`/arsave`)
|
|
864
1054
|
```
|
|
865
|
-
|
|
866
|
-
7. awareness_update(insights=[...]) → 洞察复合到感知系统
|
|
867
|
-
8. context_synthesize(consolidate=true) → 日志内容提升到宫殿
|
|
1055
|
+
session_end(summary="...", insights=[...], trajectory="...") → 日志 + 感知 + 整合
|
|
868
1056
|
```
|
|
869
1057
|
|
|
870
1058
|
---
|
|
871
1059
|
|
|
872
|
-
##
|
|
1060
|
+
## 5 个 MCP 工具
|
|
873
1061
|
|
|
874
|
-
|
|
1062
|
+
AgentRecall 目前只向 agent 提供 5 个工具。每个工具内部组合多个子系统 — agent 不需要了解内部管道。
|
|
875
1063
|
|
|
876
1064
|
| 工具 | 功能 |
|
|
877
1065
|
|------|------|
|
|
878
|
-
| `
|
|
879
|
-
| `
|
|
880
|
-
| `
|
|
881
|
-
| `
|
|
882
|
-
| `
|
|
1066
|
+
| `session_start` | 加载项目上下文。返回身份、洞察、活跃房间、跨项目匹配、最近活动、以及来自历史纠正的 `watch_for` 预警。一次调用,约 400 token。 |
|
|
1067
|
+
| `remember` | 保存记忆。自动分类内容(bug 修复、架构决策、洞察、会话笔记)并路由到正确的存储。自动生成语义化名称便于未来检索。 |
|
|
1068
|
+
| `recall` | 通过**互惠排名融合(RRF)**一次搜索所有记忆 — 每个来源内部独立排名,再按位置合并,避免任何单一来源靠原始分数主导结果。返回带稳定 ID 的排名结果。支持 `feedback` 评价:正面提升排名,负面降低。查询感知 — 某次搜索的反馈不影响无关查询。 |
|
|
1069
|
+
| `session_end` | 一次调用保存全部。写入日志、更新感知、整合到宫殿、归档被替换的洞察(不删除 — 支持复活)。 |
|
|
1070
|
+
| `check` | 记录你对人类意图的理解。返回历史纠正模式的 `watch_for` 预警。支持记录 `human_correction` 和 `delta`。3+ 次的强模式自动提升为感知洞察。 |
|
|
883
1071
|
|
|
884
|
-
###
|
|
1072
|
+
### 旧版工具
|
|
885
1073
|
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
| `recall_insight` | 开始任务前,召回跨项目的相关洞察 |
|
|
1074
|
+
原始 22 个子系统工具(palace_write、journal_capture、awareness_update 等)通过 SDK 和 CLI 仍然可用,适用于向后兼容和高级用例。MCP 服务器默认不注册这些工具。
|
|
1075
|
+
|
|
1076
|
+
---
|
|
890
1077
|
|
|
891
|
-
|
|
1078
|
+
## 记忆如何复合增长
|
|
892
1079
|
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
| `journal_projects` | 列出所有项目 |
|
|
1080
|
+
<p align="center">
|
|
1081
|
+
<a href="#1-自动命名"><img src="https://img.shields.io/badge/1-自动命名-5D34F2?style=for-the-badge" alt="自动命名"></a>
|
|
1082
|
+
<a href="#2-索引"><img src="https://img.shields.io/badge/2-索引-0EA5E9?style=for-the-badge" alt="索引"></a>
|
|
1083
|
+
<a href="#3-关联性"><img src="https://img.shields.io/badge/3-关联性-10B981?style=for-the-badge" alt="关联性"></a>
|
|
1084
|
+
<a href="#4-权重与衰减"><img src="https://img.shields.io/badge/4-权重与衰减-F59E0B?style=for-the-badge" alt="权重与衰减"></a>
|
|
1085
|
+
<a href="#5-反馈回路"><img src="https://img.shields.io/badge/5-反馈回路-EF4444?style=for-the-badge" alt="反馈回路"></a>
|
|
1086
|
+
</p>
|
|
901
1087
|
|
|
902
|
-
|
|
1088
|
+
> 记忆不是清单,而是一个 1+1+1 > 3 的复合系统。每个子系统喂养下一个 — 命名使检索成为可能,检索使反馈成为可能,反馈使排名成为可能,排名让正确的记忆在正确的时间浮现。10 个会话后,系统知道的比任何单条记忆都多。
|
|
903
1089
|
|
|
904
|
-
|
|
905
|
-
|------|------|
|
|
906
|
-
| `journal_state` | JSON 状态层 — agent 间毫秒级结构化交接 |
|
|
907
|
-
| `journal_cold_start` | 宫殿优先冷启动:先加载身份+感知+高权重房间(~200 token),再加载日志 |
|
|
908
|
-
| `journal_archive` | 归档旧条目到冷存储 |
|
|
909
|
-
| `journal_rollup` | 将旧日志压缩为周报。防止日志无限积累。`dry_run=true` 预览 |
|
|
1090
|
+
### 1. 自动命名
|
|
910
1091
|
|
|
911
|
-
|
|
1092
|
+
Agent 在保存的瞬间对内容理解最深。AgentRecall 把这种理解捕获为语义化的名称 — 不是 `"mcp-verified"` 而是 `"verified-agentrecall-mcp-22tools-functional"`。
|
|
912
1093
|
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
1094
|
+
```
|
|
1095
|
+
内容: "修复了支付处理器在退款时崩溃的严重 bug"
|
|
1096
|
+
→ 类型检测: bug-fix
|
|
1097
|
+
→ 关键词提取: payment, processor, crashed, refunds
|
|
1098
|
+
→ 生成名称: bug-fix-payment-processor-crashed
|
|
1099
|
+
```
|
|
917
1100
|
|
|
918
|
-
|
|
1101
|
+
好的命名本身就是检索的第一层。一个命名良好的记忆,不需要搜索算法就能被找到 80%。
|
|
919
1102
|
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
|
1103
|
+
### 2. 索引
|
|
1104
|
+
|
|
1105
|
+
每条记忆在三个索引系统中都有地址:
|
|
1106
|
+
|
|
1107
|
+
| 索引 | 追踪什么 | Token 开销 |
|
|
1108
|
+
|------|---------|-----------|
|
|
1109
|
+
| **宫殿索引** | 房间目录 + 显著性评分 | 扫描约 50 token |
|
|
1110
|
+
| **洞察索引** | 跨项目教训 + 关键词匹配 | 查询约 30 token |
|
|
1111
|
+
| **感知文档** | 200 行复合文档(强制合并) | 约 200 token,但每一行都承载交叉验证的权重 |
|
|
1112
|
+
|
|
1113
|
+
索引是轻量指针。Agent 先扫描索引,只在需要时才加载完整内容。
|
|
1114
|
+
|
|
1115
|
+
### 3. 关联性
|
|
1116
|
+
|
|
1117
|
+
相关的记忆会自动连接 — 无需手写 wikilinks。
|
|
1118
|
+
|
|
1119
|
+
```
|
|
1120
|
+
Agent 写入: "JWT 刷新令牌轮换防止会话固定攻击"
|
|
1121
|
+
→ 关键词: jwt, refresh, rotation, session
|
|
1122
|
+
→ "architecture" 房间标签: ["technical"]
|
|
1123
|
+
→ "knowledge" 房间有 "session management" 教训
|
|
1124
|
+
→ 自动创建边: architecture ←→ knowledge (权重 0.3)
|
|
1125
|
+
```
|
|
1126
|
+
|
|
1127
|
+
当你 `recall("会话安全")` 时,系统不只是关键词匹配 — 它沿着边跳 1 步,从关联房间中浮现相关记忆。关联性把孤立的记忆变成知识图谱。
|
|
1128
|
+
|
|
1129
|
+
### 4. 权重与衰减
|
|
1130
|
+
|
|
1131
|
+
不是所有记忆都平等。显著性评分确保最重要的记忆先浮现:
|
|
1132
|
+
|
|
1133
|
+
```
|
|
1134
|
+
显著性 = 时效性(0.30) + 访问频率(0.25) + 连接数(0.20) + 紧迫性(0.15) + 重要性(0.10)
|
|
1135
|
+
```
|
|
1136
|
+
|
|
1137
|
+
- 架构决策以 0.98/天 衰减(持久)。阻塞项以 0.90/天 衰减(短暂)。
|
|
1138
|
+
- 你实际访问的记忆越来越强。从不回顾的记忆逐渐淡化。
|
|
1139
|
+
- 被替换的洞察不会消亡 — 它们进入归档。如果未来的洞察匹配,它们会复活。
|
|
1140
|
+
|
|
1141
|
+
`recall` 基于**艾宾浩斯遗忘曲线**(1885)`R(t) = e^(−t/S)` 对不同记忆类型设定不同衰减强度:
|
|
1142
|
+
|
|
1143
|
+
| 记忆类型 | S(天) | 1天后保留率 | 1周后保留率 |
|
|
1144
|
+
|----------|---------|------------|------------|
|
|
1145
|
+
| 日志(情景记忆) | 2 | 60% | ~7% |
|
|
1146
|
+
| 知识 / Bug 修复(程序记忆) | 180 | 99% | 96% |
|
|
1147
|
+
| 宫殿 / 架构决策(语义记忆) | 9999 | ≈100% | ≈100% |
|
|
1148
|
+
|
|
1149
|
+
旧日志的噪音在数天内消退,架构决策永久保留。相同查询,始终得到正确结果。
|
|
1150
|
+
|
|
1151
|
+
### 5. 反馈回路
|
|
1152
|
+
|
|
1153
|
+
系统通过**贝叶斯 Beta 分布**学习什么有用、什么没用——这是从二元观察中估计"真实有用性"的数学最优解(`E[Beta(α,β)] = (pos+1)/(pos+neg+2)`):
|
|
1154
|
+
|
|
1155
|
+
```
|
|
1156
|
+
会话 1: recall("认证设计") → 返回 5 条结果
|
|
1157
|
+
Agent 评价: 结果 #1 有用, 结果 #3 没用
|
|
1158
|
+
→ 存入 feedback-log.json(带查询上下文)
|
|
1159
|
+
|
|
1160
|
+
会话 2: recall("认证模式") → 类似查询
|
|
1161
|
+
→ 结果 #1: Beta(2,1) → E[U]=0.67 → ×1.33 分数倍增
|
|
1162
|
+
→ 结果 #3: Beta(1,2) → E[U]=0.33 → ×0.67 分数惩罚
|
|
1163
|
+
→ 排名变化: 有用的记忆上升,噪音下沉
|
|
1164
|
+
```
|
|
1165
|
+
|
|
1166
|
+
无反馈的条目保持中性(×1.0)。反馈是查询感知的 — 把一条结果标记为"对认证设计没用"不会惩罚它在"数据库设计"中的表现。系统按上下文学习,而非全局惩罚。
|
|
1167
|
+
|
|
1168
|
+
### 复合效应
|
|
1169
|
+
|
|
1170
|
+
```
|
|
1171
|
+
会话 1: 保存 3 条记忆(自动命名、索引、创建边)
|
|
1172
|
+
会话 5: recall 浮现会话 1-4 的记忆,反馈优化排名
|
|
1173
|
+
会话 10: watch_for 在错误重复之前警告 agent
|
|
1174
|
+
会话 20: 感知包含 10 条交叉验证的洞察(从 40+ 条原始观察合并)
|
|
1175
|
+
会话 50: Agent 了解你的优先级、盲点和沟通风格
|
|
1176
|
+
— 不是因为被告知,而是因为每次纠正都在复合增长
|
|
1177
|
+
```
|
|
1178
|
+
|
|
1179
|
+
每一层放大其他层。自动命名让索引有意义。索引让关联性成为可能。关联性让检索精准。精准检索产生有意义的反馈。反馈让下一次检索更好。循环复合增长。
|
|
925
1180
|
|
|
926
1181
|
---
|
|
927
1182
|
|
|
@@ -1026,6 +1281,7 @@ L5: 洞察索引 recall_insight 「跨项目的经验」
|
|
|
1026
1281
|
| 文档 | 说明 |
|
|
1027
1282
|
|------|------|
|
|
1028
1283
|
| [智能距离协议](docs/intelligent-distance-protocol.md) | 基础理论 — 人类与 AI 之间的差距是结构性的,如何减少两个物种之间的沟通信息损失 |
|
|
1284
|
+
| [评分设计原理](docs/SCORING.md) | 评分系统的工作原理 — RRF、艾宾浩斯、Beta 分布及其修复的 bug |
|
|
1029
1285
|
| [MCP 适配器规范](docs/mcp-adapter-spec.md) | 基于 AgentRecall 构建适配器的技术规范 |
|
|
1030
1286
|
| [SDK 设计](docs/sdk-design.md) | SDK 架构设计文档 |
|
|
1031
1287
|
| [v3.4 升级说明](UPGRADE-v3.4.md) | 周报压缩、宫殿优先冷启动、提升验证 |
|