Just-in-time context retrieval
Keep file paths, queries and links in context; load the data with tools only when it is needed.
Also called Dynamic context discovery, Progressive disclosure
Anthropic, Cursor
The problem
Loading everything up front fills the context window, and a model recalls less as the window fills.
Some MCP servers include many tools, often with long descriptions, which can significantly bloat the context window.
Studies on needle-in-a-haystack style benchmarking have uncovered the concept of context rot: as the number of tokens in the context window increases, the model’s ability to accurately recall information from that context decreases.
Therefore
Rather than pre-processing all relevant data up front, agents built with the “just in time” approach maintain lightweight identifiers (file paths, stored queries, web links, etc.) and use these references to dynamically load data into context at runtime using tools.
As models have become better as agents, we've found success by providing fewer details up front, making it easier for the agent to pull relevant context on its own.
In use
Claude Code
Anthropic’s agentic coding solution Claude Code uses this approach to perform complex data analysis over large databases.
Cursor
In Cursor, we support dynamic context discovery for MCP by syncing tool descriptions to a folder.
Where it breaks
Exploring at run time is slower than reading prepared data, and an agent without guidance wastes context.
runtime exploration is slower than retrieving pre-computed data.…Without proper guidance, an agent can waste context by misusing tools, chasing dead-ends, or failing to identify key information.
Sources
- Effective context engineering for AI agentsPrithvi Rajasekaran, Ethan Dixon, Carly Ryan, and Jeremy Hadfield, Anthropic, Sep 29, 2025
Letting agents navigate and retrieve data autonomously also enables progressive disclosure—in other words, allows agents to incrementally discover relevant context through exploration.
- Dynamic context discoveryJediah Katz, Cursor, Jan 6, 2026
We're calling this pattern dynamic context discovery, in contrast to static context which is always included.
Added Nov 14, 2026