Hugging Face 开源 funes:赋予编码智能体持久记忆

原标题:Give Your Coding Agents a Memory You Own
68AI 研判分

Hugging Face 推出开源工具 funes,旨在解决编码智能体跨会话、跨设备“失忆”痛点。该工具将智能体产生的执行轨迹(Traces)转化为可检索的结构化长期记忆,使不同主机上的代理能共享上下文与决策逻辑。目前项目已开源并集成至 Hub 生态,支持开发者自定义记忆存储方案。

报道正文

本文目录8 个章节

返回文章列表

赋予你的编程智能体一份由你掌控的记忆

发布于 2026 年 9 月 3 日 在 GitHub 上更新 点赞 155

David Corvoysier dacorvo

我在多台机器上工作,并根据任务切换不同的编程智能体。每一个智能体初次接触我的项目时都如同陌生人。“上周二”的推理过程随着会话结束而消失。每个新智能体、在新主机上,都是从零开始。

今年早些时候,软件会遗忘:智能体轨迹即是记忆一文指出,编程智能体其实已经生成了我们一直丢失的记录。当它们在代码库中搜索、尝试不同方法、遇到错误、阅读文档并改变方向时,它们留下了一份详尽的记录,不仅说明了什么发生了变化,更解释了为什么发生变化。

虽然这一诊断是正确的,但轨迹仅仅是潜在的记忆。智能体的会话日志仍然只是一个存档。你无法通过 grep 命令在数万轮对话中检索出 “我们为什么放弃了流式解析器?” 这样的答案。为了让智能体在工作过程中利用这些轨迹,它们需要索引、检索、排序以及精确的来源追溯。

这正是 funes 所提供的功能。它是一个为智能体(Claude Code, Codex, pi 和 Hermes)打造的持久化记忆层。它基于你机器上已有的会话构建。它在本地运行,并通过一条命令融入智能体的常规工作流程。当你需要时,它还可以迁移到一个默认私有的、由你拥有的 Hugging Face 数据集中。

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

funes 是一个单一二进制文件。其默认推理后端没有 ML 运行时依赖,嵌入(embedding)和重排序(reranking)均在你的机器上完成。安装如下:

BASH
curl -fsSL https://huggingface.co/buckets/huggingface/funes/resolve/install.sh | sh

然后将其添加到某个智能体中:

BASH
funes add claude    

这条 add 命令会构建初始索引,为智能体提供 recall 和 get 工具,并安装自动化机制以索引每一轮完成的对话。索引是增量式的,新的运行只会添加新的对话轮次,而不是重新嵌入整个历史记录。较旧且更深层次的内容可以在有限的步骤中进行回填。

从那时起,你只需专注于工作。当任务涉及过去的决策、理由或发现时,智能体可以自行调用 recall。你无需记住旧的会话,也无需将其上下文粘贴到新会话中。

编码智能体自行调用 funes,回忆之前的决策,并基于检索到的会话为答案提供依据

引入 funes 后,回忆过程发生在对话内部。智能体会主动访问其记忆,并指明其答案背后的会话来源。

recall 返回的是原始文本,而非摘要,并准确显示其来源(智能体、时间戳、会话和轮次)。每个结果都包含一个 get 命令,用于打开完整轮次及其周边上下文。

在底层,一条确定性的流水线会将所有支持的追踪数据解析为统一的“轮次-块”结构,对其进行分块,使用固定的本地模型进行嵌入,并将其写入本地的 Lance 数据集。查询操作结合了向量搜索和 BM25 搜索,融合两者的排名,使用交叉编码器对候选项重新排序,根据时效性重新加权,并附加相邻的分块。

这种设计赋予 funes 三个重要特性:

  • 跨智能体的统一记忆: Claude Code、Codex、pi 和 Hermes 都写入相同的结构。recall 能够跨越它们的历史记录,并且每次命中都会指明是哪个智能体产生的。
  • 原始证据保持完整: 在写入时不会将任何内容提炼为事实。结果始终可以追溯到产生它的那个轮次。
  • recall 默认本地运行: 无需账户或 Hub 仓库。托管模型不会处理你的会话以进行索引;嵌入和重排序在你的机器上运行,而你的编码智能体负责推理。

智能体作为陌生人的问题在一台机器上已经解决。但当下一个智能体在别处运行时,记忆会变得更有用。

记忆是数据集,而非服务

为了让记忆跟随你的工作,在向智能体添加 funes 时绑定一个记忆:

BASH
funes add codex acme/funes-memory

该绑定会将你当前的记忆发布到那里。随后,funes 会保持其最新状态,在本地索引每一轮,并在会话边界处发布。智能体在整个过程中从中回忆。在另一台机器上运行相同的命令,记忆就会跟随你到那里。

Underneath, the local memory is a Lance dataset, and the shared memory is a Hugging Face dataset (private by default) you own.

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.

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:

BASH
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:

BASH
funes ask claude "why is funes append-only" --memory huggingface/funes-memory

Asking the published funes memory why it is append-only; funes retrieves the relevant sessions and a coding agent answers from them

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.

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 model or one served through the Hugging Face router, then return to Claude.

Claude Code chooses an embedding model, then Codex recalls that decision in a separate session

Claude makes a decision; a hook indexes it; Codex recalls it in another session. The older hits in the demo are earlier recordings of the same experiment: an append-only memory remembered the rehearsals too.

This matters in a few different scopes:

  • Across your machines: Bind each agent to one memory and recall the history from whichever host you are using.
  • Across a team: A new teammate's agent can retrieve months of decisions on day one, including dead ends and rationale that never made it into a pull request.
  • Alongside an open-source project: A maintainer can publish the sessions behind a release, naming them on the push. Think of it as a searchable CLAUDE.md that holds the history of why the project is the way it is, instead of a page someone must keep rewriting. Anyone can read a public memory with --memory.

Published memories carry a dataset card and the funes tag, making them recognizable and discoverable on the Hub. The Hub already hosts open weights and datasets. funes adds open working memory. It holds the decisions, failed approaches, and rationale behind a project, queryable by another agent and traceable to the sessions that produced them.

The cheapest way out of a long session

A long investigation bloats a session until each turn costs more to carry the context than to do the work. The usual answers are to let the agent compact and carry on, or to write a handoff and start fresh. Recall is a third, so we measured them against each other on the handoff-vs-recall benchmark: two tasks whose answer cannot be reconstructed without the session prior knowledge.

Compaction is what most agents do by default, and it was the only one of the three whose result divided: it arrived on one task and never arrived on the other. Where it failed, its summary had flattened the findings that mattered. Recall returns the passages themselves, so a finding does not have to survive summarization.

Recall was the cheapest of the three on both tasks, 8x cheaper than a written handoff on one and 4x on the other.

[注:本文篇幅超长,以上为核心前篇精译,后续内容保留原文呈现]

Weighted tokens per successful task for five channels across two tasks, with recall the shortest bar on both

The lighter segment of each bar is the one-time charge for preparing the channel, the handoff or the compaction, paid before the first question is asked and counted once. A cross marks a channel that never arrives, and so has no cost per success.

Stop starting from zero

“To think is to forget differences, generalize, make abstractions.” — Jorge Luis Borges, Funes the Memorious

Your agents already wrote the record. funes lives at github.com/huggingface/funes, one command away from turning that record into a memory the next agent can read, on whichever machine you happen to be on.

Built on open source

funes invents little of this. It leans on open-source embedding models good enough to run locally, on Lances caching and content-dedup for datasets. The work is in fitting them into a memory an agent can actually use.

funes is open source too. Open an issue for anything from an install snag to a recall that missed, or an agent you'd like supported.