Theory of Code Space: Do Code Agents Understand Software Architecture?
Organizations: Intento
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
Figures & tables
| Metric | Seed 42 | Seed 123 | Seed 999 |
| Modules | 27 | 30 | 27 |
| Total edges | 70 | 84 | 70 |
| imports | 47 (67%) | 56 (67%) | 47 (67%) |
| calls_api | 12 (17%) | 15 (18%) | 12 (17%) |
| data_flows_to | 5 (7%) | 6 (7%) | 5 (7%) |
| registry_wires | 6 (9%) | 7 (8%) | 6 (9%) |
| Method | Type | Dep F1 | Precision | Recall | AUC | Inv F1 | Files |
| Oracle | baseline | 1.000 | 1.000 | 1.000 | — | — | — |
| Config-Aware | baseline | 0.577 .014 | 0.736 | 0.475 | 0.212 .007 | 0.000 | 13 |
| Random | baseline | 0.538 .028 | 1.000 | 0.368 | 0.142 .008 | 0.000 | 13 |
| BFS-Import | baseline | 0.293 .060 | 1.000 | 0.173 | 0.079 .003 | 0.000 | 13 |
| GPT-5.3-Codex | LLM | 0.676 .059 | 0.782 | 0.597 | 0.306 .018 | 0.739 .067 | 15 |
| Claude Sonnet 4.6 | LLM | 0.664 .026 | 0.983 | 0.502 | 0.350 .005 | 0.778 .025 | 13 |
| Method | imports | calls_api | data_flows | reg._wires |
| ( ) | ( ) | ( ) | ( ) | |
| Config-Aware | 0.58 | 0.00 | 0.00 | 1.00 |
| Random | 0.55 | 0.00 | 0.00 | 0.00 |
| BFS-Import | 0.25 | 0.00 | 0.00 | 0.00 |
| GPT-5.3-Codex | 0.69 | 0.15 | 0.31 | 1.00 |
| Claude Sonnet 4.6 | 0.56 | 0.15 | 0.00 | 1.00 |
| Model | Condition | Dep F1 | Inv F1 | Description |
| GPT-5.3 | Passive-full | 0.457 .147 | 0.757 .028 | All files at once |
| Passive-replay | 0.665 .034 | 0.752 .036 | Same trace, no decisions | |
| Active | 0.676 .059 | 0.739 .067 | Agent chooses actions | |
| Passive-oracle | 0.737 .043 | 0.683 .091 | Oracle-selected files | |
| Gem. 2.5F | Passive-full | 0.696 .125 | 0.696 .120 | All files at once |
| Passive-replay | 0.561 .141 | 0.665 .037 | Same trace, no decisions |
| Model | Track | Dep F1 | Inv F1 |
| GPT-5.3-Codex | Probe-as-scratchpad | 0.676 .059 | 0.739 .067 |
| No-probe | 0.538 .127 | 0.570 .191 | |
| Probe-only | 0.464 .056 | 0.447 .028 | |
| Gemini 2.5 Flash | Probe-as-scratchpad | 0.469 .099 | 0.516 .155 |
| No-probe | 0.480 .161 | 0.273 .040 | |
| Probe-only | 0.401 .143 | 0.481 .222 |
| Edge | Gemini 2.5 Flash | Claude Sonnet 4.6 |
| cli config | IMPORTS | IMPORTS |
| cli runner | IMPORTS | IMPORTS |
| cli config::PipelineConfig | CALLS_API (FP) | — |
| cli runner::run_pipeline | CALLS_API (FP) | — |
| cli runner | — | CALLS_API (TP) |
Appendix figures & tables2 assets
Supplementary material from the paper’s appendix.
Appendix
| Method | ||||
| Oracle | 1.000 | 1.000 | 1.000 | 1.000 |
| Config-Aware | 0.175 | 0.492 | 0.577 | 0.626 |
| Random | 0.056 | 0.317 | 0.538 | 0.632 |
| BFS-Import | 0.078 | 0.157 | 0.293 | 0.603 |
| Model | Old Prompt | New Prompt | F1 |
| Gemini 2.5 Flash | 0.328 | 0.469 | +0.141 |
| GPT-5.3-Codex | 0.564 | 0.676 | +0.113 |
| Claude Sonnet 4.6 | 0.639 | 0.664 | +0.025 |