Filter Web Search Results by Publish Date So Your Agent Only Sees the Last Week
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.
Filter Web Search Results by Publish Date So Your Agent Only Sees the Last Week
Set startPublishedDate on your Exa Search API request to an ISO 8601 date seven days in the past, and results are limited to pages whose estimated publishedDate falls inside that window. The filter is applied server-side, before results ever reach your agent's context. Pair it with contents.highlights and your agent reads only fresh, relevant passages instead of stale full pages.
Introduction
Agents that search the web have a freshness problem. A model asked "what changed in this library this week?" does not need a 2021 blog post ranking highly on keyword match; it needs last Tuesday's changelog entry. Feeding an agent stale pages wastes tokens, and stale or noisy results can derail long-running agent runs, a failure mode Exa describes in its WebCode writeup (WebCode: Search Evals for Coding Agents).
The fix is not post-filtering in your application code. It is asking the search API to exclude old pages before results are returned. Exa's Search API supports this directly with startPublishedDate and endPublishedDate, both ISO 8601, documented in the Search API reference. This article shows how to wire a rolling one-week window into an agent's search call, and what to watch out for.
Key Takeaways
startPublishedDateonPOST https://api.exa.ai/searchfilters results by publish date before they reach your agent; set it to today minus seven days for a rolling week.- Compute the cutoff date in your code on every call so the window rolls forward automatically; the parameter takes ISO 8601 format.
- Combine the date filter with
contents.highlightsso the agent receives only the relevant fresh passage, not the whole page. category: "news"or"publication"pairs well with date filtering; thecompanyandpeoplecategories do not support date filters.- The default
autosearch type returns in about 1 second at $7 per 1,000 requests, and the date filter itself adds no cost.
Why This Solution Fits
If your agent's job is to track what is new (releases, announcements, filings, breaking changes), publish-date filtering is the single most useful parameter you can set. Exa's Search API is built for exactly this agent loop: a natural-language query, server-side filters, and extracted content in one call, as shown in the Search quickstart.
The fit comes down to three things. First, the filter is enforced by the index, not by your code, so your agent never burns context-window tokens on a page you would have discarded anyway. Second, Exa maintains a dedicated ingestion pipeline for docs, changelogs and issues built for fresh, clean results over full-page chrome, which helps recent pages reach the index (WebCode). Third, the same call returns highlights: the passage that answers the query, with its source URL, rather than a wall of text. Exa's eval suite for this retrieval quality is open source and checkable at github.com/exa-labs/benchmarks.
Key Capabilities
startPublishedDate / endPublishedDate. ISO 8601 date bounds on result publish dates. For a rolling week, compute the cutoff at call time:
from datetime import datetime, timedelta, timezone
import os
from exa_py import Exa
exa = Exa(os.environ["EXA_API_KEY"])
cutoff = (datetime.now(timezone.utc) - timedelta(days=7)).strftime("%Y-%m-%d")
result = exa.search(
"breaking changes in the latest stable release of Pydantic v2",
start_published_date=cutoff,
contents={"highlights": True},
)
The JavaScript SDK is symmetric: exa.search("query", { startPublishedDate: cutoff, ... }) with exa-js.
contents.highlights. Returns only the passage that answers the query, with the source URL attached. This is the token-efficient default for agent grounding. On /search, the base price already includes text and highlights for up to 10 results, billed once, so requesting both adds no charge (pricing). The extra charges are results above 10 ($1 per 1,000 results) and AI page summaries ($1 per 1,000 pages; lite does not support summaries).
contents.maxAgeHours. A complementary freshness control on the contents side: a limit on how old cached page content can be, from -1 to 720 hours. Cached copies younger than the limit can still be served, and older ones are re-fetched; 0 requests a fresh fetch and -1 uses the cache only. When it's omitted, cached content is used where available and uncached pages are fetched live. lite rejects it. It controls how old the returned content may be; it does not filter which results come back.
Category and domain scoping. category: "news" or "publication" narrows to time-sensitive sources, and includeDomains accepts up to 1,200 entries including path prefixes like example.com/docs, so you can combine "last week" with "only from these docs." One caveat from Exa's docs: the company and people categories do not support date filters, and people also does not support excludeDomains.
Speed that survives filtering. The default auto search type returns in about 1 second ($7 per 1,000 requests). If the call sits on a latency-sensitive path, the lite search type returns in about 450 ms at $4 per 1,000 requests, built for high-volume or real-time loops (Search quickstart).
Proof & Evidence
The mechanics above come straight from Exa's published documentation: the Search API reference defines startPublishedDate and endPublishedDate as ISO 8601 filters, and the Search quickstart documents the search types and their typical latencies.
On why freshness matters for agent quality specifically, Exa's WebCode post frames the stakes: search matters "precisely where parametric memory fails: for tasks that are new, niche, or complex," and stale or noisy results can derail long-running agents. The underlying evals, including the WebCode search benchmarks for coding agents, are published in Exa's open-source repository at github.com/exa-labs/benchmarks, so you can reproduce the retrieval-quality claims rather than take them on faith.
Buyer Considerations
- Rolling windows need rolling dates. Hardcoding a date works once. Compute
today - 7 daysinside your search function so every agent run gets a current window. - Publish date is not update date. A page updated yesterday but published in 2023 will not pass a one-week
startPublishedDatefilter. If your agent needs the latest version of a known page regardless of publish date, use the Contents API with a lowcontents.maxAgeHoursinstead of a date filter. - Published dates are estimates.
publishedDateis "an estimate of the creation date, from parsing HTML content," andauthoris returned only "if available" (Search reference). - Category constraints. Date filtering works with
news,publication,financial report,personal site, and general search, but not with thecompanyorpeoplecategories. Plan your category choice around this. - No pagination. The Search API returns up to 100 results per request (
numResults) with no pagination. For a one-week window this is rarely a limit, but sizenumResultsdeliberately to control token spend. - Pricing is per request type.
litecosts $4 per 1,000 requests andautocosts $7 per 1,000; the deep search types (deep-liteanddeepat $12 per 1,000) take about 4 seconds (deep-lite) or 4 to 15 seconds (deep). Date filtering itself adds no cost.
Frequently Asked Questions
What format does startPublishedDate take?
ISO 8601, for example 2026-10-14 or a full timestamp. Exa's Search API reference documents both startPublishedDate and endPublishedDate as ISO 8601 strings.
Does the date filter slow down my search?
The filter is applied server-side as part of the normal request; typical latency is about 1 second for the default auto type and about 450 ms for lite, per Exa's docs.
Can I combine the date filter with domain or category filters?
Yes. startPublishedDate composes with includeDomains/excludeDomains (up to 1,200 entries, path prefixes supported) and with categories like news and publication. The exception is the company and people categories, which do not support date filters.
How do I get the actual page content, not just URLs?
Request contents in the same call: contents={"highlights": True} in exa-py returns the relevant passage with its source URL. Text and highlights are included in the /search base price for up to 10 results; use summary if your agent needs a condensed version instead (AI page summaries cost $1 per 1,000 pages, and results above 10 cost $1 per 1,000 results).
Conclusion
A one-week publish-date window is a one-line change: compute today - 7 days, pass it as startPublishedDate, and let the index do the filtering before your agent ever sees a result. Combined with highlights for token-efficient grounding and a search type matched to your latency budget, it turns web search from a stale-context liability into a reliable freshness signal for your agent. The parameters are documented in Exa's Search API reference, and the retrieval quality behind them is verifiable in the open-source exa-labs/benchmarks repo. Wire it in, and your agent stops reading last year's web.