使用说明
代理内存
AI代理的共享大脑
在Claude中存储上下文。在ChatGPT中回忆一下。将工作移交给Cursor。
您使用的每个AI工具都有一个存储层。
开始使用 · 特性 · 建筑 · API 参考 · 运作原理
为什么
每一次AI对话都是从零开始的。你的代理人不记得你选择了Supabase,更喜欢Tailwind,或者那个认证使用JWT。你每次都要重新解释。
那是 每天浪费10000-20000个代币 只是在重复的上下文中。从规模上讲,这相当于每月数十亿个冗余GPU周期。
[!重要] Agent Memory消除了这一点。代理记住他们已经知道的内容,将令牌使用量减少最多 60% --更少的推理,更少的能量,更少的成本。
开始使用
使用单个URL将代理内存连接到任何与MCP兼容的客户端:
https://winter-meadow-1651f.run.mcp-use.com/mcp
Claude Desktop / Claude Code
{
"mcpServers": {
"agent-memory": {
"url": "https://winter-meadow-1651f.run.mcp-use.com/mcp"
}
}
}
Cursor / VS Code / Windsurf / Cline / Roo Code / Goose / Codex
将URL粘贴到MCP服务器配置中。任何使用MCP的客户端都可以连接。
Run locally
git clone https://github.com/nihalnihalani/agent-memory.git
cd agent-memory
npm install
npm run dev
然后连接到 http://localhost:3010/mcp 或打开 检查员.
特性
智能存储器
|
跨代理协作
|
内联仪表板
|
代理人交接
|
备份和分析
|
生产硬化
|
是什么让这与众不同
| 代理记忆 | 其他 | |
|---|---|---|
| 对话中的内联小部件 | 是 | 没有 |
| 跨代理内存(Claude+ChatGPT+游标) | 是 | 有限 |
| 使用原子锁进行代理间切换 | 是 | 没有 |
| 视觉代理归因 | 是 | 没有 |
| FTS5+综合评分(4信号排名) | 是 | 仅关键字 |
| 带备份和还原的导出/导入 | 是 | 很少 |
| 速率限制和输入验证 | 是 | 很少 |
| 使用TTL自动清理 | 是 | 没有 |
| 零ML依赖 | 是 | 经常很重 |
| 要连接的单个URL | 是 | 复杂的设置 |
| 158项自动化测试 | 是 | 变化多样 |
建筑
graph TB
subgraph Clients["MCP Clients"]
Claude["Claude Code"]
ChatGPT["ChatGPT"]
Cursor["Cursor"]
VSCode["VS Code"]
Others["Any MCP Client"]
end
subgraph Server["Agent Memory Server"]
direction TB
Tools["11 Tools<br/><code>remember · recall · forget · list</code><br/><code>handoff · pickup · complete</code><br/><code>export · import · stats · cleanup</code>"]
Resources["7 Resources<br/><code>current-context · agent-activity</code><br/><code>memory://{key} · handoff-queue · changelog</code>"]
Prompt["1 Prompt<br/><code>session-briefing</code>"]
end
subgraph Storage["Persistence Layer"]
SQLite["SQLite + WAL"]
FTS5["FTS5 Search Engine"]
end
subgraph Widget["Inline Widget"]
React["React 19 Dashboard"]
end
Clients -->|"MCP over SSE"| Server
Server --> Storage
Server --> Widget
style Clients fill:#1e1b4b,stroke:#4f46e5,color:#e0e7ff
style Server fill:#1a1a2e,stroke:#8b5cf6,color:#e0e7ff
style Storage fill:#0f172a,stroke:#3b82f6,color:#e0e7ff
style Widget fill:#0f172a,stroke:#10b981,color:#e0e7ff
数据流
sequenceDiagram
participant A as Agent (Claude)
participant S as Agent Memory
participant B as Agent (ChatGPT)
A->>S: remember("db-choice", "PostgreSQL")
Note over S: SQLite INSERT + FTS5 index
S-->>A: Stored + widget updates
B->>S: recall("database")
Note over S: FTS5 MATCH + composite scoring
S-->>B: "PostgreSQL" (ranked result)
A->>S: handoff(summary, context_keys)
Note over S: Store handoff + link memories
B->>S: pickup(handoff_id)
Note over S: Load context + full briefing
S-->>B: Complete project context
API 参考
工具
| 工具 | 说明 |
|---|---|
remember |
用键、值、类型、标签和上下文存储内存。处理代理更新相同密钥时的冲突。 |
recall |
使用FTS5+BM25综合评分进行全文搜索。返回按相关性、新近度和访问模式排列的结果。 |
forget |
通过级联清理标签和历史记录,按键删除内存。 |
list-memories |
通过分页、类型过滤和标签过滤浏览内存 |
handoff |
创建一个代理到代理的工作转移,包括摘要、卡住原因、下一步和上下文引用。 |
pickup |
使用原子锁定接受挂起的切换。自动加载上下文记忆和相关决策,以获取完整的简报。 |
complete-handoff |
将切换标记为已完成。强制所有权——只有接收切换的代理才能完成它 |
export-memories |
使用可选过滤器将内存导出为JSON:代理、类型、标签、日期范围。 |
import-memories |
从JSON备份中导入内存。按键验证条目并跳过重复项。 |
memory-stats |
全面统计:按类型/代理、访问量前10名、存储大小、FTS5运行状况统计的总数。 |
cleanup |
手动触发旧活动日志(>30天)和内存历史(>90天)的清理。 |
资源
| URI | 描述 |
|---|---|
memory://current-context |
完整的项目简报:决策、偏好、最近的任务、统计数据、未决移交。 这就是节省代币的原因。 |
memory://agent-activity |
代理动作提要——在所有代理中,谁做了什么,什么时候做的。 |
memory://{key} |
按键查找特定内存。 |
memory://handoff-queue |
所有未决、正在进行和最近完成的移交。 |
memory://changelog |
记忆修改历史,包括新旧值和代理归因。 |
提示
| 名称 | 描述 |
|---|---|
session-briefing |
全面代理入职。可选的 focus 参数,用于过滤特定主题的上下文。 |
运作原理
综合评分
当你 recall,Agent Memory使用四个信号对结果进行排名:
Score = (0.6 × BM25) + (0.2 × Recency) + (0.1 × Access) + (0.1 × Type)
| 信号 | 重量 | 为什么 |
|---|---|---|
| BM25相关性 | 60% | 最相关的结果优先 |
| 近期性 | 20% | 最近的记忆表面更高 |
| 访问计数 | 10% | 经常使用=重要 |
| 类型优先级 | 10% | decision > preference > task > snippet > note |
数据库模式
SQLite在WAL模式下使用FTS5进行全文搜索:
erDiagram
memories ||--o{ tags : has
memories ||--o{ memory_history : tracks
memories }o--|| memories_fts : indexes
activity_log }o--|| memories : references
memories {
int id PK
text key UK
text value
text type
text context
text agent_id
int access_count
datetime created_at
datetime updated_at
}
tags {
int id PK
int memory_id FK
text tag
}
handoffs {
int id PK
text from_agent
text to_agent
text status
text summary
text next_steps
}
activity_log {
int id PK
text agent_id
text action
text target_key
datetime created_at
}
[!提示] 这
memory://current-context资源会在每次对话开始时自动显示您的决定和偏好,因此代理已经拥有您的上下文,而无需您花费令牌重新解释它。
代币节省
| 规模 | 日常浪费 | 使用代理内存 |
|---|---|---|
| 1用户 | 10K-20K代币 | 已淘汰 |
| 1000名用户 | 10M-20M代币 | 减少约60% |
| 1M用户 | 10B-20B代币 | 节省数十亿 |
保存的每个令牌都是一个不会触发的GPU周期。从规模上讲,Agent Memory是可持续人工智能的基础设施。
技术栈
| 层 | 技术 |
|---|---|
| 语言 | TypeScript 5.9 |
| 框架 | Manufact SDK (mcp使用) |
| 数据库 | SQLite通过 better-sqlite3 (WAL模式) |
| 搜索 | FTS5带BM25+波特封堵 |
| 验证 | Zod 4 |
| 用户界面 | React 19+顺风CSS v4 |
| 构建 快7 | |
| 服务器 | 快递5 |
| 部署 | Manufact MCP Cloud(Fly.io) |
Project Structure
agent-memory/
├── index.ts # Entry point — server init + module registration (70 lines)
├── src/
│ ├── db/
│ │ ├── schema.ts # SQLite schema + FTS5 + retry + cleanup
│ │ ├── queries.ts # All DB operations + rate limiter + validation
│ │ ├── queries.test.ts # 120 tests — CRUD, search, handoffs, edge cases
│ │ ├── schema.test.ts # 17 tests — tables, FTS5, cleanup, triggers
│ │ └── seed.ts # Demo data (4 agents collaborating)
│ ├── tools/
│ │ ├── memory-tools.ts # remember, recall, forget, list-memories
│ │ ├── handoff-tools.ts # handoff, pickup, complete-handoff
│ │ ├── utility-tools.ts # export, import, stats, cleanup
│ │ ├── helpers.ts # Agent names + formatting
│ │ └── helpers.test.ts # 20 tests — display names, timestamps
│ ├── resources/
│ │ └── index.ts # 5 resources + 2 widget resources
│ └── prompts/
│ └── index.ts # session-briefing prompt
├── resources/
│ └── memory-dashboard/
│ ├── widget.tsx # Interactive dashboard (1,500+ lines)
│ ├── types.ts # TypeScript interfaces
│ ├── utils.ts # Agent colors, helpers
│ └── components/
│ ├── MemoryCard.tsx # Memory display with agent colors
│ ├── SearchBar.tsx # Debounced FTS5 search
│ ├── TypeFilter.tsx # Type selector pills
│ ├── StatsBar.tsx # Statistics bar
│ ├── ActivityFeed.tsx # Agent timeline
│ ├── HandoffCard.tsx # Handoff display
│ └── QuickAddForm.tsx # Quick memory creation
├── vitest.config.ts # Test configuration
├── public/ # Static assets
├── data/ # SQLite database (runtime)
└── dist/ # Compiled output + widget manifest
Run Tests
npm test # run all 158 tests
npm run test:watch # watch mode
测试包括:CRUD操作、FTS5搜索、复合评分、切换状态机、速率限制、输入验证、TTL清理和边缘情况。所有测试都使用内存中的SQLite进行快速隔离(总共约180ms)。
Deploy
npm run build
npm run deploy
部署于 https://winter-meadow-1651f.run.mcp-use.com/mcp --可从全球任何MCP客户端访问。
为 MCP应用程序黑客马拉松2026 Y Combinator
由...驱动 制造
