User as Code: Executable Memory for Personalized Agents
Summary
User as Code (UaC) introduces an executable memory paradigm for personalized AI agents, contrasting with traditional unstructured text, knowledge graph, or flat fact stores that rely on retrieval. UaC models a user as a living software project, utilizing typed Python objects for user state and ordinary Python functions to encode governing rules, allowing representation and reasoning within a single, interpretable medium. Its enabling mechanism is a two-phase pipeline: an append-only log that periodically checkpoints into typed code. This approach significantly enhances memory capabilities, matching prior systems on recall (78.8% on LOCOMO) while demonstrating superior performance on aggregate questions over user history, achieving 99% accuracy where retrieval-based methods yield only 6-43%. Furthermore, UaC can surface unsolicited, safety-critical alerts, such as drug-allergy conflicts, a capability absent in query-driven memory systems.
Key takeaway
For AI Engineers designing personalized agents, traditional retrieval-based memory systems often fall short on complex reasoning and proactive alerts. You should explore User as Code's executable memory paradigm to build more robust user models. This approach, using typed Python objects and functions, enables accurate aggregate queries and critical unsolicited safety alerts, significantly enhancing agent intelligence and reliability beyond simple fact recall.
Key insights
User as Code proposes executable memory for AI agents, using Python objects and functions for dynamic, rule-based user modeling.
Principles
- User memory should be executable, not just retrievable.
- Representing and reasoning about user state should occur in one medium.
- Deterministic rule execution enables proactive safety alerts.
Method
A two-phase pipeline: an append-only log captures facts, which are periodically checkpointed into typed Python code representing user state and rules.
In practice
- Aggregate user history queries with high accuracy.
- Proactively detect safety-critical conflicts (e.g., drug interactions).
Topics
- User as Code
- Personalized Agents
- Executable Memory
- AI Memory Systems
- Python Programming
- Knowledge Representation
- Safety-Critical AI
Best for: Research Scientist, AI Architect, AI Product Manager, AI Scientist, Machine Learning Engineer, AI Engineer
Related on AIssential
Editorial summary, takeaway, and curation by AIssential. Original article published by Artificial Intelligence.