Context for an agent on a large codebase
Give an AI agent the context it needs by surveying, localizing or resolving, then planning context, so each request stays inside the token budget.
Goal: hand an AI agent the context for a task on a large .NET codebase without spending its window on files the task does not touch.
The principle is to work from the warm index: a cheap map first, then localize or resolve the task, then plan context for the result. Each step is one MCP tool call. The payoff is measured on the benchmark corpus: open-ended localize from a title alone recalls 37.7 percent of changed files at a median 1,348 tokens. Change review starts from a Git diff and packages the changed files plus blast-radius context at 93.4 percent precision in a median 1,026 tokens. Its 100 percent changed-file recall follows from must-keep Git seeding; it is not a file-discovery result.
The Sequence
- Survey. Call
fuse_workspacewithaction=mapfirst. It lists indexed symbols, routes, and counts, a low-token map of the workspace, no bodies, so the agent sees the shape before fetching anything. - Localize or resolve. When the task is open-ended, call
fuse_findwithkind=taskand the task text to rank candidate files and symbols. When the task names a route, interface, request, or config section, callfuse_findwith the matching wiringkind(service,request,route,config) to map it to the type that actually runs. Neither returns bodies. - Plan context. Feed the candidate file paths from
fuse_find(or the resolved names) tofuse_contextto fetch their bodies and dependency neighborhood, packed to a budget. - Review a change. For a pull request, call
fuse_reviewwith the base branch. It uses Git-known changed files as must-keep seeds and returns compact branch context, including the available semantic blast radius.
Example Call Sequence
fuse_workspace(action="map", path="C:/Projects/MyApp/src", detail="all")
fuse_find(path="C:/Projects/MyApp/src", kind="task", query="discount applied at checkout")
fuse_context(path="C:/Projects/MyApp/src", files=["src/Checkout/DiscountPolicy.cs"], depth=2, maxTokens=25000)The first call orients the agent, the second ranks candidate files, and the third pulls the selected files and their dependency neighborhood as packed context.
Resolve When the Task Names Wiring
When the task names a service, request, route, or config section, skip localize and resolve it directly:
fuse_find(path="C:/Projects/MyApp/src", kind="service", query="IOrderService")
fuse_context(path="C:/Projects/MyApp/src", services=["IOrderService"], maxTokens=25000)fuse_context can take services, requests, routes, and configs seeds and resolve
and expand them itself, so you can often plan context in one call once you know the name.
Budget Guidance
| Stage | Tool | Typical tokens |
|---|---|---|
| Survey | fuse_workspace (action=map) | low, counts only |
| Localize or resolve | fuse_find (kind=task or wiring) | low, no bodies |
| Plan context | fuse_context | 15,000 to 50,000 |
| Change review | fuse_review | 15,000 to 50,000 |
Refine across Turns
Across calls in one task, pass a sessionId to fuse_context and fuse_review so files
already returned are not sent again. See
Refine across turns.
When to Use It
Use this progressive flow on any codebase too large to hand an agent whole. When a git
base is available, fuse_review provides Git-seeded branch context directly.
Run the First Three Calls
Copy the example call sequence into your agent, replace the path and task text, and keep
the fuse_context budget at 25,000 tokens. Check the returned manifest before asking the
agent to edit: each included file should name its seed or graph provenance.