The Library Theorem: How External Organization Governs Agentic Reasoning Capacity
Zachary F. Mainen

TL;DR
This paper formalizes how external structured memory significantly reduces retrieval costs in transformer agents, demonstrating through theory and experiments that indexing outperforms sequential search, especially as reasoning depth increases.
Contribution
It introduces a formal model of external memory indexing in transformer agents, proving exponential efficiency gains and validating these with empirical benchmarks across content types and model generations.
Findings
Indexed external memory achieves logarithmic retrieval cost.
Sequential search incurs linear or quadratic costs, less scalable.
Models sometimes bypass retrieval, relying on parametric memory, leading to inefficiencies.
Abstract
Externalized reasoning is already exploited by transformer-based agents through chain-of-thought, but structured retrieval -- indexing over one's own reasoning state -- remains underexplored. We formalize the transformer context window as an I/O page and prove that tool-augmented agents with indexed external memory achieve exponentially lower retrieval cost than agents restricted to sequential scanning: versus page reads per query, and versus cumulative cost over reasoning steps -- a gap that widens as deliberation deepens. We test these predictions on a controlled lookup benchmark across three content types -- random hashes, ordered integers, and encyclopedia entries -- varying store size from 50 to 5,000 items, and replicate key conditions across two model generations (GPT-4o-mini and GPT-5.4). On abstract content, the…
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
Taxonomy
TopicsLanguage and cultural evolution · Information Retrieval and Search Behavior · Topic Modeling
