arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2606.16707cs.AI
收藏

用户即代码:面向个性化智能体的可执行记忆

User as Code: Executable Memory for Personalized Agents

Pine AI

Bojie Li

AI总结:

提出可执行记忆范式User as Code,将用户模型转化为可运行的Python代码,通过两阶段流水线实现精确聚合与规则执行,在长对话基准上达到78.8%召回率,聚合问题准确率99%,并能主动触发安全警报。

摘要:

个性化AI智能体需要用户记忆:一个关于用户是谁的持久模型,通过多次对话构建并在每次新对话中查询。如今,这种记忆几乎总是以非结构化文本、知识图谱或扁平事实存储的形式保存,并通过检索——获取与当前请求最相似的条目——来查询。这种“事实袋”记忆能很好地回忆单个事实,但由于存储事实和基于事实行动是分离的步骤,它在解决矛盾、聚合多条记录或执行规则方面存在困难。我们认为用户记忆应该是可执行的。我们引入用户即代码(UaC)范式,其中智能体对用户的模型是一个活的软件项目:类型化的Python对象保存用户状态,普通的Python函数编码管理状态的规则,因此表示和推理用户发生在同一个可由解释器运行的媒介中。实现机制是一个两阶段流水线:一个只追加的日志从不丢弃任何事实,并定期检查点化为类型化代码。这改变了记忆的能力。在标准的长对话基准测试中,UaC在召回率上匹配全上下文上限和最强的先前记忆系统(LOCOMO上78.8%)。其优势在表示至关重要的地方显现。在关于用户历史的聚合问题(如“我去年进行了多少次国际旅行?”)上,基于检索的记忆崩溃(6-43%),而UaC保持近乎完美(99%),因为答案是对类型化状态的一行计算,而不是对文本的搜索。而且,由于其规则在状态变化时确定性执行,UaC能够呈现未经请求的、安全关键的警报——例如新开的药物与数月前记录的过敏相冲突——这是查询驱动记忆无法提供的能力。

英文摘要:

A personalized AI agent needs a user memory: a persistent model of who the user is, built across many conversations and consulted on each new one. Today this memory is almost always stored as unstructured text, a knowledge graph, or a flat store of facts, and consulted by retrieval -- fetching the entries most similar to the current request. Such "bag-of-facts" memory recalls individual facts well, but because storing a fact and acting on it are separate steps, it struggles to resolve contradictions, aggregate over many records, or enforce rules. We argue that user memory should instead be executable. We introduce User as Code (UaC), a paradigm in which an agent's model of a user is a living software project: typed Python objects hold the user's state and ordinary Python functions encode the rules that govern it, so representing and reasoning about the user happen in one medium an interpreter can run. The enabling mechanism is a two-phase pipeline: an append-only log that never discards a fact, periodically checkpointed into typed code. This changes what memory can do. On standard long-term conversation benchmarks, UaC matches both a full-context upper bound and the strongest prior memory systems on recall (78.8% on LOCOMO). Its advantage emerges where representation matters most. On aggregate questions over a user's history -- "how many international trips did I take last year?" -- retrieval-based memory collapses (6-43%) while UaC stays near-perfect (99%), because the answer is a one-line computation over typed state rather than a search over text. And because its rules execute deterministically whenever the state changes, UaC can surface unsolicited, safety-critical alerts -- such as a newly prescribed drug that conflicts with an allergy recorded months earlier -- a capability query-driven memory cannot provide.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑