Overview
Given a user request for how to change a codebase, you want to retrieve only the files relevant to implementing that request. This is important for two reasons:- Polluting the context window with irrelevant files makes the generated code worse.
- The fewer files you pass in, the more you save on input tokens.
Prerequisites
Prepare Your Query and Codebase
Define your user request and collect the files from your codebase that need to be ranked for relevance.
Call the Code Reranker API
Send your query and codebase to the reranker to get relevance scores for each file.
Parse Ranked Results from Response
The API returns files ranked by relevance with scores between 0 and 1 up to the token limit you set.We recommend additionally filtering out results with low relevance scores. See the agent tool definition or workflow guide for specific recommendations based on your system.