User as Code: Executable Memory for Personalized Agents
A team of researchers has proposed a new architecture for AI agent memory called User as Code, which represents a user's history and preferences as executable Python code instead of unstructured text or knowledge graphs, according to a paper submitted to arXiv in June 2026 [1]. The paper, titled "User as Code: Executable Memory for Personalized Agents," argues that current memory systems for personalized AI agents store user information as a "bag-of-facts" — unstructured text, knowledge graphs, or flat stores — and retrieve it by searching for entries similar to a new request [1]. This approach, the authors contend, recalls individual facts well but struggles with tasks requiring reasoning across many stored records, such as resolving contradictions or answering aggregate questions [1]. User as Code (UaC) instead models the user as a living software project. Typed Python objects hold the user's state, and ordinary Python functions encode the rules that govern it, so that representing and reasoning about the user occur in a single medium an interpreter can run [1]. The system relies on a two-phase pipeline: an append-only log that never discards a fact, which is periodically checkpointed into typed code [1]. The performance gap is stark on aggregate questions. On the LOCOMO long-term conversation benchmark, UaC achieved 78.8% recall, matching both a full-context upper bound and the strongest prior memory systems [1]. But when asked questions that require computation over a user's history — such as "how many international trips did I take last year?" — retrieval-based memory fell to between 6% and 43% recall, while UaC remained near-perfect at 99% [1]. The paper attributes this to the fact that the answer becomes a one-line computation over typed state rather than a search over text [1]. The deterministic execution of rules also enables a capability that query-driven memory cannot provide: unsolicited, safety-critical alerts. The paper gives the example of a newly prescribed drug that conflicts with an allergy recorded months earlier, which UaC can surface automatically whenever the state changes [1]. The paper was posted on arXiv, the open-access repository of electronic preprints that, as of November 2024, receives about 24,000 submissions per month and has surpassed two million articles [9]. The work appears under arXiv's Artificial Intelligence category and is accessible through arXivLabs, a framework launched in 2020 that allows community collaborators to develop and share experimental tools directly on the platform [7]. arXivLabs projects operate under guidelines requiring partners to share arXiv's values of openness, community, excellence, and user data privacy, with third-party collaborators granted access only to minimal and anonymized user data [7].
applicationresearch-paper
Background sources we checked (10)
- arxiv.org ↗ 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 retriev…
- en.wikipedia.org ↗ An HTTP cookie (also called web cookie, Internet cookie, browser cookie, or simply cookie) is a small block of data created by a web server while a user is browsing a website and placed on the user's computer or other device by the user's web browser. Cookies are placed on the de…
- en.wikipedia.org ↗ A large language model (LLM) is a neural network trained on a vast amount of text for natural language processing tasks, especially language generation. LLMs can typically generate, summarize, translate, and analyze text in many contexts, and are a foundational technology behind …
- en.wikipedia.org ↗ ChatGPT is a generative artificial intelligence chatbot developed by OpenAI. Originally released in November 2022, the product uses large language models—specifically generative pre-trained transformers (GPTs)—to generate text, speech, and images in response to user prompts. Chat…
- info.arxiv.org ↗ arXiv Labs - arXiv info | arXiv e-print repository Skip to content # arXiv Labs Attention arXiv Users: arXiv Labs is pausing new proposals ## What are arXiv Labs? arXiv Labs are a way for the community to contribute new, useful features to arXiv. These integrations are avail…
- blog.arxiv.org ↗ arXivLabs: a space for community innovation – arXiv blog arXiv has launched a new, formalized framework enabling innovative collaborations with individuals and organizations. “Members of our community want to contribute tools that enhance the arXiv experience, and we val…
- info.arxiv.org ↗ arXivLabs: Showcase - arXiv info | arXiv e-print repository ... # arXivLabs: Showcase ... arXiv is surrounded by a community of researchers and developers working at the cutting edge of information science and technology. ... While the arXiv team is focused on our core mission—pr…
- en.wikipedia.org ↗ arXiv (pronounced as "archive"—the X represents the Greek letter chi ⟨χ⟩) is an open-access repository of electronic preprints and postprints (known as e-prints) approved for posting after moderation, but not peer reviewed. It consists of scientific papers in the fields of mathem…
- en.wikipedia.org ↗ 14 (fourteen) is the natural number following 13 and preceding 15.…
- en.wikipedia.org ↗ A large language model (LLM) is a type of machine learning model designed for natural language processing tasks such as language generation. LLMs are language models with many parameters, and are trained with self-supervised learning on a vast amount of text.…
Sources
- export.arxiv.org — User as Code: Executable Memory for Personalized Agents ↗