The conventional wisdom in building AI agents suggests a straightforward approach: if the model can process it, provide it. Feed the system documentation, ticket histories, product specifications, and archived communications, then let the model determine what matters. Larger context windows have made this strategy increasingly feasible. Yet this assumption overlooks a critical problem: additional information does not automatically produce superior results.

As the volume of available context expands, identifying genuinely relevant evidence becomes harder. Outdated material, conflicting information, and tangential details compete for the model's attention, even when the correct answer sits somewhere in the data. An agent may possess access to the right information but still arrive at incorrect conclusions. The solution requires more than simply expanding context windows or deploying more capable models—it demands ensuring agents receive precisely the evidence needed for their task, without extraneous noise obscuring that evidence.

This challenge appears obvious in theory but proves difficult in practice. Understanding what relevance truly means, and why it extends far beyond identifying documents similar to a query, forms the foundation for addressing it.

Research reveals how additional context undermines accuracy

Studies of long-context language models have documented multiple mechanisms through which supplementary information degrades performance.

  • Document positioning affects retrieval success. Stanford's 2023 "Lost in the Middle" research demonstrated that when models received 20 documents with one containing the answer, accuracy peaked when that document appeared first or last, declining by approximately 20 percentage points when positioned in the middle.
  • Misleading similar content causes the most damage. Chroma's 2025 "Context Rot" report evaluated 18 frontier models, including GPT-4.1, Claude 4, Gemini 2.5, and Qwen3. All showed uneven degradation as input volume increased, with distractors closely resembling the correct answer inflicting the greatest harm. Researchers from LMU Munich and Adobe Research independently confirmed this pattern.
  • Length itself impairs performance. A 2025 paper presented at the Empirical Methods in Natural Language Processing conference, titled "Context Length Alone Hurts LLM Performance Despite Perfect Retrieval," had models recite relevant evidence verbatim before responding. Despite perfect recall, accuracy dropped from 13.9% to 85% across five models as input length grew. Performance declined even when additional tokens consisted of blank whitespace.
  • Incomplete evidence breeds overconfident responses. Google's "Sufficient Context" research found that frontier models perform well when retrieved context is complete. When context proves insufficient, models tend to answer anyway rather than acknowledging gaps, and adding more context can paradoxically reduce their willingness to express uncertainty.

These constraints carry greater consequences for agents than for traditional chatbots. While a chatbot typically retrieves information once to answer a single question, an agent may execute a dozen or more retrieval operations within a single task as it plans, validates results, and adjusts its approach. Each retrieval call introduces additional tokens, processing delays, and potential for misleading or irrelevant information to influence subsequent decisions. An incorrect intermediate result can cascade through the workflow, allowing errors to compound across multiple steps.

Reliable agent performance depends on two distinct properties of the context provided: sufficiency (the evidence required to complete the task exists) and relevance (the information supplied actually helps accomplish that task). Maximizing context window usage prioritizes coverage while sacrificing relevance, betting that sheer volume will include everything the agent needs. Effective retrieval instead pursues both properties simultaneously: delivering sufficient evidence to support the task while excluding unnecessary information that could mislead or distract the agent.

Defining relevance beyond surface similarity

Relevance appears straightforward but represents one of retrieval's most challenging aspects to implement correctly. Vespa CEO Jon Bratseth observes that "relevance is your moat." As models become more capable and widely accessible, organizations increasingly have access to comparable underlying intelligence. What sets them apart is their proprietary information and how effectively their systems leverage it. For AI agents, this means locating evidence that genuinely supports task completion, not merely information related to the topic.

Consider a practical question: "Can I enable this feature on our current deployment without upgrading?" Semantic search might surface feature documentation, release announcements, and technical explanations of how the feature operates. All address the topic, and some might rank highly due to linguistic similarity to the query, yet none directly answer the question. The agent actually needs evidence about which versions support the feature, what version the customer runs, and any licensing or configuration prerequisites.

This distinction separates topical similarity from task relevance. The difference between relevance and sufficiency becomes practical in three scenarios:

  • Relevant but insufficient: The agent locates feature documentation but misses version requirements essential to answering the question.
  • Sufficient but noisy: The agent retrieves all necessary evidence, but it arrives mixed with obsolete release notes, deprecated procedures, and other material that could steer it toward the wrong conclusion.
  • Sufficient and relevant: The agent retrieves current feature requirements and deployment details needed to answer, without unnecessary distractions.

Achieving the final outcome requires more than selecting a quality embedding model or retrieving additional documents. Bratseth identifies four dimensions of relevance that illuminate the engineering required: freshness (information reflects current state), authority (source trustworthiness), recall (finding necessary candidates), and ranking (prioritizing useful evidence).

These dimensions interact. A perfectly ranked result provides little value if the underlying information is stale. An up-to-date index cannot help if retrieval overlooks the correct document. High recall introduces more noise if ranking cannot distinguish useful evidence from related content.

Similarity tells you whether a piece of text is related to a question. Relevance tells you whether it will help the agent answer the question correctly.

Jon Bratseth

Relevance is not an inherent property of a document. It depends on what the agent is attempting to accomplish. Achieving it requires engineering the entire path from available information to the evidence that ultimately reaches the model. Most agent failures occur in the gap between similarity and relevance.

Common retrieval approaches and their limitations

Many retrieval strategies function adequately initially. Limitations become apparent as data volumes expand, information changes, and agents handle increasingly complex, multistep workflows. The issue often lies not in individual technologies but in how they combine. A retrieval pipeline can fail even when the information needed exists somewhere in the system.

Failures typically fall into three categories.

1. The right evidence never gets retrieved

Agents cannot use information that never enters the candidate set. Several common design decisions cause this:

  • Relying exclusively on vector similarity. Vector search excels at finding conceptually related information, but similarity does not capture every task requirement. Exact product names, error codes, version numbers, and business rules may matter more than semantic similarity. Without lexical matching, metadata constraints, or other relevance signals, a system retrieves documents that sound appropriate while missing those containing the answer.
  • Filtering after retrieval. Many systems retrieve top results by similarity, then apply permissions or date filters afterward. The result set shrinks unpredictably, sometimes to nothing, and the agent concludes the information does not exist. Applying constraints during retrieval ensures the candidate set contains eligible information.
  • Expecting reranking to compensate for poor retrieval. A sophisticated reranker can improve candidate ordering, but cannot recover a document retrieval missed. If the right document never reaches the ranking stage, downstream scoring cannot restore it.

These represent fundamentally recall problems. The information may exist and be current, but the retrieval process fails to surface it.

2. The right evidence gets buried

Locating correct information represents only half the challenge. The system must also distinguish the most useful evidence from other results that relate to the query but offer less value for task completion.

  • Merging result lists instead of ranking them together. Many hybrid setups run keyword and vector search independently, then merge the lists using fusion methods like reciprocal rank fusion. Fusion only examines where each result ranks in each list, not why. It cannot recognize that one document is the official specification while another is a forum post, or that one matches the customer's version while another describes two releases ago. Weighing authority, version compatibility, and freshness requires ranking that scores candidates directly on those signals.
  • Losing context through chunking. Small passages improve retrieval precision but may omit surrounding information needed to interpret them correctly. A configuration instruction might appear relevant until the preceding paragraph reveals it applies only to an older software version. Ranking passages without document-level information can prioritize incorrect evidence.

These are ranking and evidence-selection problems. The right information has been found, but less useful information may receive priority or selection instead.

3. The agent receives the wrong amount of context

Even when retrieval finds and prioritizes useful evidence, the system must still determine how much information to send to the model.

  • Using long context as a substitute for retrieval. Large context windows permit providing more information, but do not eliminate the need to select what matters. Including obsolete, contradictory, or loosely related material makes it harder for the model to use the right evidence. For agents making repeated model calls, unnecessary context also increases token costs and latency.
  • Returning whole documents. Sending complete documents preserves surrounding context but can consume the model's context window with task-unrelated material.
  • Sending a fixed number of results. A rule like "Always send 10 chunks" assumes every question requires the same amount of evidence. Some need one passage, others may need 15. A fixed cutoff can leave an agent with insufficient evidence or overwhelm it with unnecessary information.

These are context-selection problems. The goal is not minimizing tokens at all costs, but providing sufficient relevant evidence for the agent to complete the task without unnecessary distractions.

Across all three categories, the underlying issue remains constant: retrieving information differs from delivering sufficient, relevant evidence. A larger context window cannot fix missing candidates, poor ranking, or incomplete evidence. Reliable agents need retrieval pipelines that find the right information, prioritize it appropriately, and select what the model actually needs.

Building retrieval systems for relevant, sufficient evidence

Relevance is not a setting to activate. It emerges from multiple techniques working together, within latency constraints and against constantly changing data. Getting it right requires engineering the entire retrieval pipeline, from finding candidates to deciding which evidence reaches the model.

Five practices prove particularly valuable.

1. Combine retrieval methods

Integrate keyword matching and vector search within the same query. Keyword matching captures exact names, codes, and version numbers. Vector search captures paraphrases and intent. Agents ask both kinds of questions, often in the same session, so both retrieval types need to work together, not as two systems merged afterward. Combining retrieval methods within a unified query and ranking pipeline also enables evaluating candidates using shared relevance signals.

2. Apply constraints during retrieval

Dates, customers, permissions, regions, and product versions are hard rules, not suggestions. Applying filters during retrieval prevents a limited top-K candidate set from shrinking unpredictably through post-filtering. It also ensures the system searches among eligible documents rather than finding the most similar results first and discarding those that do not qualify. Filtering at retrieval time complements access controls; it does not replace them.

3. Rank in phases, on more than similarity

Retrieving the right candidates is only the beginning. The system must still determine which results provide the most useful evidence for the task. Multiphase ranking balances relevance quality with computational cost. An inexpensive first phase evaluates candidates using signals such as keyword relevance, vector similarity, freshness, or source authority. More sophisticated ranking functions or machine-learned models can then evaluate a smaller set of promising results. The signals and their relative importance depend on the task. Making these signals explicit allows developers to inspect, evaluate, and tune relevance rather than relying entirely on a model to infer what matters from the text.

4. Select passages, not entire documents

Finding the right document does not mean the agent needs to read it all. A lengthy technical guide might contain only two passages relevant to the question. Returning entire documents preserves context but can consume the model's token budget with unnecessary information. Retrieving isolated chunks can be more precise, but those chunks may lack the surrounding information needed to interpret or rank them correctly. A better approach preserves document-level information while ranking and selecting the most useful passages to send to the model. This retains the context needed to evaluate evidence without requiring the agent to process every paragraph.

5. Measure relevance and sufficiency separately

Do not judge retrieval quality solely by whether the model produces a convincing answer. Build an evaluation set from real agent tasks and measure whether retrieval finds the necessary evidence, whether ranking places it near the top, and whether the selected passages collectively contain enough information to complete the task. Retrieval and ranking evaluation can identify where relevant evidence is lost. Recall measures whether retrieval finds the right candidates. Ranking metrics such as normalized discounted cumulative gain (NDCG), which rewards placing the most useful results near the top, help assess how effectively the system prioritizes useful results. Evidence sufficiency requires an additional check: whether the selected information collectively supports the answer.

Test difficult cases deliberately. What happens when evidence is missing, outdated, contradictory, or spread across multiple sources? Does the agent retrieve more information, acknowledge uncertainty, or confidently produce an unsupported answer?

A convincing answer based on the wrong evidence is still wrong.

None of these techniques is new to search. Web search and e-commerce teams have spent decades refining retrieval, ranking, and relevance evaluation. What differs with agents is how frequently these decisions are made and how directly they influence subsequent actions. A single task can involve repeated retrieval calls, with each result shaping what the agent does next.

Before expanding your agent's context window

Before increasing the amount of information an agent can process, ensure it is receiving the right information in the first place. A few practical checks can reveal whether the real limitation is context size or retrieval quality.

  • Index everything the agent might need, and keep it current. Bring all relevant sources into the searchable corpus: documentation, tickets, release notes, and customer and deployment records. Apply additions, updates, and deletions as they happen, not in periodic batches. Retrieval cannot surface evidence that was never indexed. An index that lags behind reality will hand the agent instructions that no longer apply. A comprehensive index does not mean a bigger context. It gives retrieval more to choose from so it can be more selective about what the agent reads.
  • Use more than semantic similarity. Combine vector search with keyword matching when exact names, error codes, versions, or identifiers matter. Apply permissions and other constraints during retrieval so the right candidates make it into the results.
  • Make recency and authority rankable. Capture metadata like update timestamps and source types so ranking can distinguish current, authoritative information from outdated or less trustworthy material.
  • Treat context as a limited resource. Set a token budget for each step and prioritize the most useful passages rather than entire documents. Put the strongest evidence first, rather than burying it among less relevant material.
  • Match the amount of evidence to the task. Some questions need one authoritative source; others require information from several. Do not assume a fixed number of retrieved chunks will always be sufficient.
  • Let agents search again. Permit agents to refine queries and retrieve missing information instead of loading everything into the initial prompt. When the evidence is incomplete, another targeted search may be more useful than a larger context window.
  • Make uncertainty an acceptable outcome. When evidence is missing, outdated, or contradictory, the agent should acknowledge the limitation rather than produce an unsupported answer. A reliable agent needs to recognize when it does not have enough information to proceed.

The goal is to provide enough reliable evidence to complete the task without making the agent sort through information it does not need.

Moving forward

Large context windows offer genuine value. They provide agents with headroom for long tasks and complex instructions, but they represent capacity, not judgment. An agent can only be as reliable as the evidence it receives, and that evidence originates from the retrieval and ranking system.

More data gives an agent more to read. Relevant data gives it what it needs to get the answer right.

This is why relevance warrants more attention than it typically receives. It is not a single feature or a better embedding model. It is comprehensiveness, freshness, recall accuracy, and ranking quality working together, plus the permission and sufficiency checks agents need on top. Each one requires deliberate engineering.