Give Your Coding Agents a Memory You Own

Give Your Coding Agents a Memory You Own

为你的编程智能体赋予你所拥有的记忆

I work across several machines, and I switch coding agents depending on the task. Every one of them meets my projects as a stranger. The reasoning from “last Tuesday” disappears when the session ends. Each new agent, on each new host, starts from zero. 我需要在多台机器上工作,并根据任务切换不同的编程智能体。它们每一个在面对我的项目时都像是一个陌生人。上周二的推理过程在会话结束后就消失了。每一个新的智能体,在每一台新的主机上,都从零开始。

Earlier this year, Software Forgets: Agent Traces Are the Memory made the case that coding agents already produce the record we keep losing. As they search a codebase, try approaches, hit errors, read documentation, and change direction, they leave behind a dense account of not just what changed, but why. While the diagnosis is correct, traces are only potential memory. The session logs of an agent are still just an archive. You cannot grep your way to “why did we move off the streaming parser?” across ten thousand turns. 今年早些时候,《软件会遗忘:智能体轨迹即记忆》(Software Forgets: Agent Traces Are the Memory)一文指出,编程智能体其实已经产生了我们不断丢失的记录。当它们搜索代码库、尝试方案、遇到错误、阅读文档并改变方向时,它们留下了不仅关于“改了什么”,而且关于“为什么改”的详尽记录。虽然这一诊断是正确的,但轨迹仅仅是潜在的记忆。智能体的会话日志目前仅仅是一个存档。你无法通过 grep 命令在成千上万次的交互中找到“我们为什么要放弃流式解析器?”的答案。

For an agent to use those traces while it works, they need indexing, retrieval, ranking, and exact provenance. That is what funes provides. It is a durable memory layer for your agents (Claude Code, Codex, pi, and Hermes). It is built from the sessions already on your machine. It works locally and becomes part of your agent’s normal workflow with one command. When you want it to, it can also travel to a Hugging Face dataset you own, private by default. 为了让智能体在工作时利用这些轨迹,它们需要索引、检索、排序和精确的来源追溯。这正是 funes 所提供的。它是为你智能体(Claude Code、Codex、pi 和 Hermes)打造的持久化记忆层。它基于你机器上已有的会话构建,在本地运行,只需一条命令即可成为智能体正常工作流的一部分。当你需要时,它还可以同步到你拥有的 Hugging Face 数据集中,且默认是私有的。

Add memory to the agent you already use

为你正在使用的智能体添加记忆

funes is a single binary. Its default inference backend has no ML runtime dependency, and embedding and reranking happen on your machine. funes 是一个单一的二进制文件。其默认的推理后端没有任何机器学习运行时依赖,嵌入(embedding)和重排序(reranking)都在你的机器上完成。

Install it: 安装它: curl -fsSL https://huggingface.co/buckets/huggingface/funes/resolve/install.sh | sh

Then add it to an agent: 然后将其添加到智能体中: funes add claude # or: codex, pi, hermes

That one add command builds the first index, gives the agent recall and get tools, and installs the automation that indexes each completed turn. Indexing is incremental, with new runs adding new turns rather than embedding the whole history again. The older and deeper content can backfill in bounded steps. 这一条 add 命令会构建第一个索引,为智能体提供 recall(召回)和 get(获取)工具,并安装自动索引每个已完成交互的程序。索引是增量式的,新的运行会添加新的交互,而不是重新嵌入整个历史记录。更早、更深层的内容可以在有限的步骤内进行回填。

From there, you just work. When a task touches a past decision, rationale, or finding, the agent can reach for recall itself. You do not need to remember the old session or paste its context into the new one. With funes added, recall happens inside the conversation. The agent reaches for its memory on its own and names the session behind its answer. 此后,你只需正常工作。当任务触及过去的决策、逻辑或发现时,智能体可以自行调用 recall。你不需要记住旧的会话,也不需要将上下文粘贴到新的会话中。添加 funes 后,召回过程在对话内部完成。智能体会主动获取记忆,并指出其答案背后的会话来源。

recall returns the original text, not a summary, and shows exactly where it came from (the agent, timestamp, session, and turn). Each result includes a get command that opens the full turn and its surrounding context. recall 返回的是原始文本而非摘要,并精确显示其来源(智能体、时间戳、会话和交互轮次)。每个结果都包含一个 get 命令,用于打开完整的交互轮次及其周围的上下文。

Underneath, one deterministic pipeline parses every supported trace into the same turn-and-block shape, chunks it, embeds it with a pinned local model, and writes it to a local Lance dataset. A query combines vector and BM25 search, fuses their rankings, reranks the candidates with a cross-encoder, reweights them by recency, and attaches neighboring chunks. That design gives funes three important properties: 在底层,一个确定性的流水线将所有支持的轨迹解析为统一的“交互-块”格式,进行分块,使用固定的本地模型进行嵌入,并将其写入本地的 Lance 数据集。查询过程结合了向量搜索和 BM25 搜索,融合两者的排名,使用交叉编码器(cross-encoder)对候选结果进行重排序,根据时效性重新加权,并附加相邻的数据块。这种设计赋予了 funes 三个重要特性:

  • One memory across agents: Claude Code, Codex, pi, and Hermes all write to the same shape. recall spans their histories, and every hit says which agent produced it. 跨智能体的统一记忆: Claude Code、Codex、pi 和 Hermes 都写入相同的格式。recall 可以跨越它们的历史记录,且每一次命中都会标明是由哪个智能体产生的。
  • Raw evidence stays intact: Nothing is distilled into a fact at write time. A result can always lead back to the turn that produced it. 原始证据保持完整: 在写入时,没有任何内容被提炼成事实。结果总是可以追溯到产生它的原始交互。
  • recall is local by default: No account or Hub repository is required. A hosted model does not process your sessions for indexing; embedding and reranking run on your machine, and your coding agent does the reasoning. 默认本地召回: 不需要账户或 Hub 仓库。托管模型不会处理你的会话进行索引;嵌入和重排序都在你的机器上运行,由你的编程智能体负责推理。

The agent as a stranger problem is already solved on one machine. But memory gets more useful when the next agent is running somewhere else. “智能体是陌生人”的问题在单台机器上已经解决了。但当下一个智能体在别处运行时,记忆会变得更有用。

A memory is a dataset, not a service

记忆是一个数据集,而不是一项服务

To make a memory follow your work, bind one when you add funes to an agent: 为了让记忆跟随你的工作,在将 funes 添加到智能体时绑定一个记忆: funes add codex acme/funes-memory

The bind publishes your current memory there. funes then keeps it current, indexing each turn locally and publishing at session boundaries. The agent recalls from it throughout. Run the same command on another machine and the memory follows you there. 绑定操作会将你当前的记忆发布到该位置。funes 随后会保持其更新,在本地索引每一轮交互,并在会话结束时进行发布。智能体在整个过程中都会从中进行召回。在另一台机器上运行相同的命令,记忆就会跟随你到那里。

Underneath, the local memory is a Lance dataset, and the shared memory is a Hugging Face dataset (private by default) you own. Before anything reaches the Hub, credentials have already been redacted during indexing. Publishing then scans every chunk again and withholds anything that still looks like a secret. The scanner behind this is documented in SECURITY.md, including what it does and doesn’t cover. 在底层,本地记忆是一个 Lance 数据集,而共享记忆是你拥有的 Hugging Face 数据集(默认私有)。在任何内容到达 Hub 之前,凭据已在索引过程中被脱敏。发布时会再次扫描每个数据块,并拦截任何看起来像密钥的内容。其背后的扫描器在 SECURITY.md 中有详细记录,包括其覆盖和未覆盖的范围。

When an agent reads a remote memory, funes caches the dataset files locally, so warm queries return to local speed. The Hub supplies the ownership, access control, versioning, and distribution it already supplies for other datasets. Your memory does not become an account in a separate memory service, and you do not rent it back through an API. 当智能体读取远程记忆时,funes 会在本地缓存数据集文件,因此热查询可以达到本地速度。Hub 提供了它为其他数据集所具备的所有权、访问控制、版本控制和分发功能。你的记忆不会变成独立记忆服务中的一个账户,你也不需要通过 API 租用它。

Ask first, wire later

先询问,后连接

recall is shaped for agents. When you want to put a question to a memory yourself, use ask. It reads your local memory by default: recall 是为智能体设计的。当你自己想向记忆提问时,请使用 ask。它默认读取你的本地记忆: funes ask claude "what did we decide about the streaming parser"

Or point it at a shared memory. We published a memory of funes development, so you can ask why funes works the way it does without creating a memory of your own: 或者将其指向共享记忆。我们发布了一个关于 funes 开发过程的记忆,因此你无需创建自己的记忆即可询问 funes 为何以这种方式工作: funes ask claude "why is funes append-only" --memory huggingface/funes-memory

funes ask is the read-only, one-question sibling of funes add. It recalls the passages, hands them to a coding agent, and returns a grounded answer that names its sources. It does not install an integration or change the agent’s persistent setup. A retrieval miss is not papered over. If the passages do not support an answer, the agent says so. You can rephrase the question or add funes to the agent so it can search the memory iteratively during normal work. funes ask 是 funes add 的只读、单次提问版本。它召回相关段落,交给编程智能体,并返回一个有据可查的答案,同时标明来源。它不会安装集成,也不会改变智能体的持久化设置。检索失败不会被掩盖。如果段落不支持回答,智能体会直接说明。你可以重新措辞问题,或者将 funes 添加到智能体中,以便它在正常工作期间迭代地搜索记忆。

Switching agents without losing the thread

切换智能体而不丢失线索

A shared memory is not tied to the agent or model that created it. Start a task in Claude Code, continue it in Codex next week, and the second agent can recall the first agent’s reasoning. Use pi with a local mode… 共享记忆并不绑定到创建它的智能体或模型。在 Claude Code 中开始一个任务,下周在 Codex 中继续,第二个智能体可以召回第一个智能体的推理过程。在本地模式下使用 pi……