Serper backend silently drops every fresh result: relative dates ("2 hours ago") parse to None
Version: 3.24.0 (confirmed still present on main @ 349ca44 / 3.25.0 — the code is byte-identical)
Backend affected: serper only (--web-backend=serper). brave and exa are fine.
Symptom: Web: 0 items (no results) on every run, with no error and no warning.
Summary
serper_search() applies a client-side date filter to results that Serper has
already filtered server-side via tbs=cdr:1,cd_min:…,cd_max:…. That client-side
filter depends on _parse_serper_date(), which only understands absolute date
formats. Google renders relative dates for recent results — "2 hours ago",
"23 hours ago", "1 day ago" — and those parse to None. Since
_in_date_range(None, …) returns False, the item is dropped.
The failure scales inversely with freshness: the newer a result is, the more
likely Google renders a relative date, so the shorter the research window, the
more results are discarded. With --days 1 it discards 100% of them.
Because the source returns successfully with zero items, the run reports
Web: 0 items (no results), which reads as "nothing was published in this
window" rather than "the retrieved results were thrown away." That made this
very hard to find — we spent several days misattributing it first to a missing
API key, then to the keyless backend.
Code path
lib/grounding.py:
# line 132
def serper_search(query, date_range, api_key, count: int = 5):
data = http.request(
"POST", "https://google.serper.dev/search",
headers={"X-API-KEY": api_key},
json_data={
"q": query,
"num": count,
# server-side date restriction — this part works
"tbs": f"cdr:1,cd_min:{_serper_date_param(date_range[0])},cd_max:{_serper_date_param(date_range[1])}",
},
timeout=15,
)
items = []
for i, r in enumerate((data.get("organic", []))[:count]):
raw_date = r.get("date") or ""
pub_date = _parse_serper_date(raw_date) # line 148
if not _in_date_range(pub_date, date_range):
continue # <-- everything is dropped here# line 206 — only absolute formats
def _parse_serper_date(raw: str) -> str | None:
if not raw:
return None
normalized = _normalize_date(raw)
if normalized:
return normalized
for fmt in ("%b %d, %Y", "%B %d, %Y", "%Y-%m-%d"):
try:
return datetime.strptime(raw.strip(), fmt).date().isoformat()
except ValueError:
continue
return None
# line 366 — an unparseable date is treated as out-of-range
def _in_date_range(pub_date: str | None, date_range: tuple[str, str]) -> bool:
if not pub_date:
return False
return date_range[0] <= pub_date <= date_range[1]The other backends are unaffected because they receive machine-readable timestamps rather than Google's rendered strings:
| backend | date field | value shape | survives the gate |
|---|---|---|---|
| brave (line 65) | page_age |
ISO 8601 | yes |
| exa (line 110) | publishedDate |
ISO 8601 | yes |
| serper (line 148) | date |
Google's rendered string | no, when relative |
Reproduction
Any run with --web-backend=serper and a valid SERPER_API_KEY. A short window
makes it total:
last30days "AI coding agents skills workflows open source" \
--as-of 2026-09-22 --days 1 --web-backend=serperObserved in Source Coverage: Web: 0 items (no results).
Isolating the gate against live Serper responses (3 subqueries, num=5 each,
window 2026-09-21..2026-09-22), using the engine's own
_serper_date_param / _parse_serper_date / _in_date_range:
organic results returned : 15
... with a `date` field: 8
... passing the gate : 0Every one of the 8 dated results carried a relative string:
date='2 hours ago' -> None dropped tech-leads-club/agent-skills: The secure, validated ...
date='17 hours ago' -> None dropped 10 tips to improve your coding agent game
date='23 hours ago' -> None dropped OpenDesign: The open-source Claude Design alternative
date='1 day ago' -> None dropped The Best Pi Coding Agent Setup for AI Agentic ...
date='16 hours ago' -> None dropped 10+ Best Open Source Codex Alternatives in 2026
...With a 30-day window one result survived — and only because it was old enough
that Google gave it an absolute date ('Sep 9, 2026').
Suggested fix
Teach _parse_serper_date() to resolve relative dates, falling back to it only
after the existing absolute formats fail. Two details that matter:
- Resolve against
date_range[1], not the process clock. The engine derives its window from--as-of; a container running UTC while the operator is in another timezone will otherwise land results a day off. Passingdate_rangeinto the parser keeps the two consistent by construction. N minutes/hours agocan't be pinned to a calendar day (there's no "now" to anchor to), but such items are by definition less than a day old, and the server-sidetbshas already excluded anything outside the window — so mapping them todate_range[1]is the closest honest approximation.
Results with no date field at all should keep being dropped; that's existing
behavior and this change shouldn't touch it.
A patch against 3.24.0 is attached. Applied locally, the same probe gives:
before: organic 15 / with date 8 / passing the gate 0
after : organic 15 / with date 8 / passing the gate 8and 14 unit cases pass, including the absolute-format cases unchanged.
Secondary observations
Not part of this report, but noticed while tracing it:
countis hardcoded to5in all four backend functions and isn't reachable from the CLI, so the web pool is small before any filtering.Web: 0 items (no results)is indistinguishable from "the backend returned nothing." A distinct outcome for "returned N results, all filtered out by the date gate" would have made this diagnosable from a single run rather than from reading the source.
Source: mvanhorn/last30days-skill