deepagents-memory
在 Deep Agents 中实现长期内存,使用 StoreBackend、CompositeBackend 和 InMemoryStore 进行跨会话的持久化数据存储。
npx skills add majiayu000/claude-skill-registry --skill deepagents-memory --agent claude-code
Same command for any agent — swap --agent for codex, cursor, copilot.
Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.
# deepagents-memory (JavaScript/TypeScript) ## 概述 **短期(StateBackend)**:仅单会话 **长期(StoreBackend)**:跨会话持久化 **混合(CompositeBackend)**:两者结合 ## 长期内存设置 ```typescript import { createDeepAgent, CompositeBackend, StateBackend, StoreBackend } from "deepagents"; import { InMemoryStore } from "@langchain/langgraph"; const store = new InMemoryStore(); const agent = await createDeepAgent({ backend: (config) => new CompositeBackend( new StateBackend(config), { "/memories/": new StoreBackend(config) } ), store }); // /memories/* 文件跨会话持久化 // 其他文件是临时的 ``` ## 代码示例 ### 示例 1:跨会话的用户偏好 ```typescript import { createDeepAgent, CompositeBackend, StateBackend, StoreBackend } from "deepagents"; import { InMemoryStore } from "@langchain/langgraph"; const store = new InMemoryStore(); const agent = await createDeepAgent({ backend: (config) => new CompositeBackend( new StateBackend(config), { "/memories/": new StoreBackend(config) } ), store }); // 会话 1:保存偏好 const config1 = { configurable: { thread_id: "thread-1" } }; await agent.invoke({ messages: [{ role: "user", content: "将我的编码风格保存到 /memories/style.txt:TypeScript、async/await、Jest" }] }, config1); // 会话 2:访问偏好 const config2 = { configurable: { thread_id: "thread-
- 概述
- 长期内存设置
- 代码示例
- 示例 1:跨会话的用户偏好
- 示例 2:在工具中直接使用 Store
- 示例 3:项目知识库
- 决策表
- 边界
- Agent 可以做的事情
- Agent 不能做的事情
- 注意事项
- 1. StoreBackend 需要 Store
- 2. 路径前缀很重要
- 3. InMemoryStore 不持久化
What does the deepagents-memory skill do?
在 Deep Agents 中实现长期内存,使用 StoreBackend、CompositeBackend 和 InMemoryStore 进行跨会话的持久化数据存储。
How do I install it?
Run `npx skills add majiayu000/claude-skill-registry --skill deepagents-memory --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.
Where does this skill come from?
From majiayu000/claude-skill-registry, a repository with 534 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.
Is a popular skill a good skill?
Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.
