Theory of Code Space: Do Code Agents Understand Software Architecture?

Grigory Sapunov
2/28/2026
cs.SEcs.AI

Official code: che-shr-cat/tocs (7 stars, MIT, last commit 2026-03-25).

Abstract

AI code agents excel at isolated tasks yet struggle with multi-file software engineering requiring architectural understanding. We introduce Theory of Code Space (ToCS), a benchmark that evaluates whether agents can construct, maintain, and update coherent architectural beliefs during codebase exploration. Agents explore procedurally generated codebases under partial observability -- opening files under a budget -- and periodically externalize their belief state as structured JSON, producing a time-series of architectural understanding. Three findings emerge from experiments with four baselines and six frontier LLMs. First, the Active-Passive Gap is model-dependent: one model builds better maps through active exploration than from seeing all files at once, while another shows the opposite -- revealing that active exploration is itself a non-trivial capability absent from some models. Second, retaining structured belief maps in context acts as self-scaffolding for some models but not others, showing that the mechanism is model-dependent. Third, belief state maintenance varies dramatically: a smaller model maintains perfectly stable beliefs across probes while its larger sibling suffers catastrophic belief collapse -- forgetting previously-discovered components between probes. We release ToCS as open-source software. Code: https://github.com/che-shr-cat/tocs

View on arXivView PDF

Code Implementations(1)

che-shr-cat/tocsOfficial100%
MIT

Theory of Code Space

71TeX, ShellFeb 27, 20267 months agoMIT

Similar Papers

Cite this paper

@article{sapunov2026theory,
  title  = {Theory of Code Space: Do Code Agents Understand Software Architecture?},
  author = {Grigory Sapunov},
  year   = {2026},
  eprint = {2603.00601},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2603.00601v3}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2603.00601.svg)](https://codeofpaper.com/paper/2603.00601)

Discussion