Skip to content

Lesson 8 of 8 · 5 min read

Building a Ranked Repository Map Under a Token Budget

The repository-context lesson showed the idea of a map: files and their symbols, a few hundred tokens that tell an agent where things are. This lesson builds the version that works on a large repository. Definitions and references are parsed from source into a graph in which a file earns rank from the files that use what it defines. A personalised random walk, seeded by the files and symbols the task mentions, turns that graph into an ordering that is specific to the task rather than a fixed list of the most central files. The map is then filled to a token budget in rank order, whole entries at a time, with a cap on what any one file may contribute so that generated code and test files do not crowd out the rest. Parsing is cached per file by content hash so that one edit re-parses one file, and the map is kept byte-stable across the turns of a run so it remains part of the cached prefix rather than a fresh cost on every call.

Premium lessonReviewed By the AIAgentInterviews editorial team
Get full Premium access · $25

All 19 topics with every worked answer, all lessons and courses, the full practice bank, and anything new that appears during your access.

6 months · One payment · No auto-renewal

Practise it as an interviewer asks it

Related lessons