Overview
Suppose a code file contains 10,000 tokens, but the agent only needs one function occupying 2,000 tokens.
Loading the complete file wastes context and introduces unrelated material. A search tool can locate the function and return only the relevant section plus enough surrounding text to understand it.
The same process can operate across a codebase:
- Search for a filename, function name, class, phrase, or pattern.
- Identify likely files.
- Read the most relevant section.
- Expand the range only if additional context is required.
- Avoid loading unrelated files.
This is a successive narrowing process. The agent begins with a broad search and progressively focuses on the exact information required for the next decision.