WEEK 1 · LESSON 6 · TOPIC 10 OF 26 · Selective File and Code Retrieval

Selective File and Code Retrieval

Lesson progress

0% Complete

SECTION 1 OF 1

In this topic · 1 sections
  1. Overview

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:

  1. Search for a filename, function name, class, phrase, or pattern.
  2. Identify likely files.
  3. Read the most relevant section.
  4. Expand the range only if additional context is required.
  5. 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.