MemCodex is a hierarchical memory system for language agents that self-evolves through program rewriting. It organizes memory into layers for summaries, relational knowledge, skills, and latent memory. At query time, it traverses from coarse to fine layers, stopping when sufficient evidence is found.
The system achieved a 10.1% relative improvement in average task success over the strongest adaptive-memory baseline. It also used 3.4x fewer context tokens and achieved 2.1x faster inference.
This approach adapts both within-layer implementations and cross-layer composition, addressing the heterogeneity of memory access needs across different query types. The open-ended evolution allows the system to discover effective memory architectures automatically.