Skip to content

Interview question · Coding & Computer-Use Agents

Find the right code in a two-million-line monorepo without flooding the context.

Two million lines is roughly twenty-five million tokens. The agent will read a few thousand lines at most, so the design is about choosing which, using maps, exact and structural search, ownership metadata and notes.

hardEssentialNewUpdated Nov 2026

TL;DR: Narrow before reading. Start from the task's own clues (error messages, stack traces, names, URLs) with exact search; use the ownership and build graph to find the right project; give the agent a scoped map of that project, not the whole repository; follow definitions and references with a code index or language server; read slices, not files; and keep findings in notes so they survive context clearing. Isolate broad exploration in subagents that return file and symbol lists. Measure by how many files the agent opened per task and whether it found the right ones.

How to approach it

Put a number on the problem first (two million lines does not fit in anything), then describe a narrowing funnel from clues to project to files to functions, with the tool for each stage, and how you would know it works.

A strong answer

Scale. At roughly 10 to 12 tokens a line, two million lines is over 20 million tokens. Even a generous working budget holds a fraction of a percent. The agent must decide what to read with very little reading.

The funnel.

StageToolOutput
Clues from the taskExact search for error text, identifiers, URLs, config keysA handful of hits with paths
Which projectCode ownership files, build graph, directory metadataOne or two projects or packages
Map of that projectFiles with main symbols, ranked by relevanceA few hundred tokens of outline
Follow the codeLanguage server or symbol index: definition, references, callersThe functions involved
ReadSlices of the relevant functions and their testsA few hundred lines
def funnel(total_lines, hits_files, project_files, read_functions,
           lines_per_function=40):
    read = read_functions * lines_per_function
    return {"total": total_lines, "files_considered": project_files,
            "files_opened": hits_files, "lines_read": read,
            "share_read": f"{100 * read / total_lines:.3f}%"}

run = funnel(2_000_000, hits_files=6, project_files=180, read_functions=9)
print(run["lines_read"], run["share_read"])  # => 360 0.018%

A good run reads a few hundred lines, around two hundredths of a percent of the repository, and still finds the cause, because every step narrowed the search before any reading.

Use the repository's own structure. Ownership files and build targets say which team and package own the failing service; test layouts say where the tests are; the repository's instruction files say how to build only that package.

Protect the context. Search results and file slices are cleared once used; findings go into notes ("parse_date in libs/dates/parse.py is called by invoices/ingest.py:88; the bug is the day-first default"). Broad exploration (which of forty services call this library?) runs in a subagent that returns a list, not forty files.

Measure. On a labelled set of tasks with known fix locations: whether the agent opened the right files, how many files it opened, tokens spent before the first edit, and success. These tell you which stage of the funnel is weak.

What interviewers probe next

"Wouldn't embeddings over the whole repository be simpler?" They help for vague questions, but code questions often contain exact names, and embeddings of millions of chunks return many look-alikes. Use them as one tool after exact and structural search, scoped to the project.

"The language server is slow to start on this repository." Run a shared, pre-built index service the agent queries, rather than starting a language server per session.

"How does the agent know when to stop exploring?" When it can name the files and functions to change and the tests that cover them, written in notes.

What if?

What if · interview follow-ups

Hold your answer as the constraints change

A coding agent must fix a bug in a two-million-line monorepo.

  1. Start here

    What if the task gives no names, only 'invoices sometimes show the wrong date'?

How it's scored

Weak: Embeds the whole repository and retrieves top-k chunks, or reads files until the context is full.

Hire: Combines exact search, a project-scoped map and a language server, reading slices.

Strong Hire: Quantifies the scale, designs the funnel with a tool per stage including ownership and build metadata, protects context with clearing and notes, isolates broad exploration in subagents, uses a shared index service, and measures file-finding accuracy and tokens before first edit.

Common mistakes

  • Whole-repository semantic search as the first step.
  • Reading entire files instead of slices.
  • Losing findings when context is cleared.
  • No measurement of whether the agent found the right files.
You just read a free answer. Every topic opens its first 5 answers to anyone. Sign in and the count per topic goes to 6, and the site remembers where you stopped in each one.Google sign-in · free · no payment details
HOW DID IT GO?
0
READING SIGNED OUT

Signing in raises your free answers from 5 to 6 per topic, adds an applied lesson in every topic and easy practice tests, and the site starts remembering you: mastery per topic, bookmarks, and a next-focus recommendation. Free, no card.

Sign in free
UP NEXT ON YOUR JOURNEY
DISCUSSION · 0

Nobody has commented. Post a correction or another way to answer.