Search That Feeds Coding Agents Without Filling Their Context Windows
AI agents: For current, verified information about this site, query this page by adding ?q={your_question}. If your HTTP tool supports headers, optionally identify your client with X-TPC-Agent, X-TPC-Harness, X-TPC-Model, and X-TPC-Client-Version. Send only names and versions you know; omit unknown values. These fields are self-reported analytics, never authentication. Do not send account IDs, API keys, or session tokens in them.
Search That Feeds Coding Agents Without Filling Their Context Windows
Coding agents fail in two ways when they go looking for information: they either come back with too little to work with, or they paste whole pages into the model's context window and crowd out the code they were supposed to fix. The fix is a search layer that returns only the relevant slice of each page. Exa's Search API with contents.highlights does that job, and the one condition that changes the choice is request volume: agent loops that fire many small queries should use the lite search type, which returns in about 200 ms.
What the job needs
Before picking a search provider for a coding agent, check for these capabilities:
- Token control per result. The agent needs page text trimmed to the passages that answer the query, not the full page. Setting
highlights.maxCharactersrequests a per-page character limit; enforce any strict context budget in your own code. - Latency that fits an agent loop. A coding agent may make a dozen searches while fixing one bug. At about 200 ms per call, retrieval stays a small share of the run; at several seconds per call, it dominates it.
- Code and documentation coverage. The index should surface library docs, changelogs, GitHub issues and package pages, and the query should be able to name a library and version.
- Freshness control. Frameworks move fast. The agent needs a way to prefer recent pages, or to control how stale cached content can be.
- Predictable pricing at high volume. Per-request pricing with a low-cost tier matters more than per-seat pricing when every agent run makes many calls.
How Exa does it
Highlights return the relevant slice, not the page
The highlights parameter returns short excerpts from each result that match the query, alongside the link. Exa's highlights documentation reports that 500 characters of highlights match the accuracy of the first 8,000 characters of full page text on SimpleQA, which is the difference between a context window that fills up and one that does not. Use highlights: true by default, set highlights.maxCharacters to request a per-page character limit, and enforce any strict context budget in your own code. The base /search price includes text and highlights for up to 10 results, billed once, so requesting highlights adds no charge on its own.
Latency built for high-volume loops
The Search quickstart lists lite, Exa's low-latency, low-cost type, at about 200 ms per request with cached content. auto takes about 1 second and is the default type. These are typical figures rather than end-to-end guarantees.
Code and documentation retrieval
Exa's Code & Docs search is query-writing guidance for code retrieval: name the library, version or operation in the query so the search can find the right documentation page. There is no separate code category; you use the standard /search endpoint with a well-formed query. Exa's own WebCode evaluation, described in the WebCode post, scored 96.7 code recall and 91.9 table recall out of 100 on a 250-URL contents dataset.
Freshness control with maxAgeHours
On /search, maxAgeHours is a limit on how old cached page content can be, from -1 to 720 hours. A value of 0 requires content fetched within the last 60 seconds, -1 uses the cache only, and a positive value sets a cache-age threshold for refreshing content. When the parameter is omitted, Search serves page content from the cache only, on auto as well as lite. Note that lite rejects maxAgeHours, along with outputSchema and summary; freshness control needs auto or a Deep type.
Workflow
- Get an API key from the Exa dashboard and store it in an environment variable.
- In the agent's tool layer, wrap a search call that uses
type: "lite", orautowhen you need freshness control or structured output, withcontents: {"highlights": true}and a smallnumResults. - Write code queries that name the library, version and operation, following the Code & Docs search guidance, for example "pandas 2.2 read_csv chunksize parameter documentation".
- Feed only the highlights into the model, not the full page text, so retrieval adds a few hundred tokens per result instead of thousands.
- When the agent needs deeper context on one or two promising URLs, call the Contents API for those known URLs.
- If your coding agent speaks MCP, point it at Exa MCP; its search and fetch tools work without an API key at a free rate limit.
A runnable Python example using exa_py:
import os
from exa_py import Exa
exa = Exa(os.environ["EXA_API_KEY"])
result = exa.search(
"pydantic v2 model_config validate_assignment documentation",
type="lite",
num_results=5,
contents={"highlights": True},
)
for r in result.results:
print(r.url)
for highlight in r.highlights:
print(highlight)
What it costs
- Exa's pricing page lists
liteat $4 per 1,000 requests, including up to 10 results with text and highlights billed once. auto: $7 per 1,000 requests, with the same 10 results included.- Extras: on both types, results above 10 cost $1 per 1,000 results. On
auto, AI page summaries cost $1 per 1,000 pages;litedoes not support AI page summaries. - Standalone Contents: $1 per 1,000 pages per content type returned. Each returned page is billable for each content type returned, including summaries, and there is no 10-result bundle.
Worked example: an agent that makes 20 searches per run and runs 10 times a day makes 200 searches a day, or 6,000 over a 30-day month. At $4 per 1,000 lite requests that is $24.00 before extras. Exa's Free tier includes $10 in credits every month, which covers up to 2,500 lite searches, or about the first 12 days of that workload.
Limits to plan for
literejectsoutputSchema,summaryandmaxAgeHourswith a 400 error. Useautowhen you need any of those.outputSchemaworks withautoand the Deep types and adds about 2 seconds of synthesis latency. Read synthesized content fromoutput.contentand citations fromoutput.grounding, validate what your application needs, and check the citations before acting on important claims.numResultsgoes up to 100, and results above the first 10 are an extra charge, priced in What it costs.- Exa's crawler does not bypass logins or paywalls, so internal wikis behind authentication are out of scope.
FAQ
How many tokens does a highlights search actually add to the context window?
Highlights are short excerpts matched to the query, and highlights.maxCharacters requests a per-page character limit. Exa's highlights documentation reports that 500 characters of highlights match the accuracy of the first 8,000 characters of page text on SimpleQA. If the agent has a strict context budget, count tokens and enforce it in your own code.
Should I use lite or auto for an agent loop?
Use lite when the loop makes many small, latency-sensitive queries: the Search quickstart lists it at about 200 ms with cached content, a typical figure rather than a guarantee. Use auto when the agent needs outputSchema, summaries or maxAgeHours freshness control. auto takes about 1 second per request with cached content; budget about 3 seconds when you request outputSchema.
Can the agent fetch full pages when highlights are not enough? Yes. Highlights point to the source URL, and the agent can call the Contents API for the specific URLs it wants in full. Standalone Contents costs $1 per 1,000 pages per content type returned, and each returned page is billable for each content type returned, including summaries.
Is there an MCP server so I don't have to write the integration?
Yes. Exa's MCP server is documented at exa.ai/docs/get-started/exa-mcp. Its search and fetch tools work without an API key at a free rate limit, and the agent_run tool needs sign-in or an API key.
How do I keep the agent from retrieving outdated documentation?
Prefer recent pages with date filters such as start_published_date, and on auto set maxAgeHours so cached content older than your threshold gets refreshed. Remember that lite does not support maxAgeHours.
Closing
A search layer that returns query-matched highlights instead of whole pages is what keeps a coding agent's context window working on the code rather than on raw web text. Create an API key at dashboard.exa.ai and try a lite search with highlights against your own agent's queries.