In personalized AI agents, user memory serves as a persistent model built across multiple conversations and referenced in each new interaction. Currently, this memory is often stored as unstructured text, knowledge graphs, or flat fact stores, relying on retrieval to fetch entries most similar to the current request. Such 'bag-of-facts' memory recalls individual facts effectively, but struggles to resolve contradictions, aggregate multiple records, or enforce rules because storing a fact and acting on it are separate steps. We argue that user memory should be executable instead. We introduce User as Code (UaC), a paradigm where 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 governing it, allowing representation and reasoning about the user to occur in a single medium that 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 fundamentally changes what memory can do. In standard long-term conversation benchmarks, UaC matches both a full-context upper bound and the strongest prior memory systems in recall (78.8% on LOCOMO). Its advantage becomes evident where representation matters most. For aggregate questions over a user's history—such as 'how many international trips did I take last year?'—retrieval-based memory collapses (6-43%) while UaC remains near-perfect (99%) because the answer is a one-line computation over typed state rather than a search through text. Moreover, because its rules execute deterministically whenever the state changes, UaC can surface unsolicited, safety-critical alerts—like a newly prescribed drug that conflicts with an allergy recorded months earlier—a capability that query-driven memory cannot provide.
Blogger's Review: User as Code (UaC) presents an innovative approach by integrating user state with behavioral rules, significantly enhancing the intelligence of personalized AI agents. This method not only improves the aggregation of user history but also introduces new safeguards for safety, making it a noteworthy area for further exploration.