Skip to content

AI agent skill that researches any topic across Reddit, X, YouTube, HN, Polymarket, and the web - then synthesizes a grounded summary

fix(arxiv): honor as-of end dates in the recency cutoff (#1295)

Andrew Barnes0ca1ad0cf497
diff --git a/changelog.d/+arxiv-as-of-window.fixed.md b/changelog.d/+arxiv-as-of-window.fixed.md
new file mode 100644
index 00000000..97ef376f
--- /dev/null
+++ b/changelog.d/+arxiv-as-of-window.fixed.md
@@ -0,0 +1 @@
+arXiv no longer returns papers published after the end of an `--as-of` window, and its one-year recency cutoff is now measured from that end date, so historical reports keep in-window papers instead of citing later ones.
diff --git a/skills/last30days/scripts/lib/arxiv.py b/skills/last30days/scripts/lib/arxiv.py
index 082547b8..32ddd4b4 100644
--- a/skills/last30days/scripts/lib/arxiv.py
+++ b/skills/last30days/scripts/lib/arxiv.py
@@ -24,7 +24,7 @@ from __future__ import annotations
import json
import shutil
-from datetime import datetime, timezone
+from datetime import date, datetime, time, timezone
from typing import Any, Dict, List, Optional
from . import log, subproc
@@ -256,18 +256,25 @@ def parse_arxiv_response(
response: Dict[str, Any],
query: str = "",
today: Optional[datetime] = None,
+ to_date: Optional[str] = None,
) -> List[Dict[str, Any]]:
"""Parse an arXiv envelope into normalized item dicts.
Applies the recency cutoff (drops entries older than ``RECENCY_DAYS`` and
entries with an unparseable date) and computes a token-overlap relevance
hint. Returns dicts ready for ``normalize._normalize_arxiv``.
+
+ ``to_date`` (the report window's inclusive end, e.g. from ``--as-of``)
+ anchors the cutoff at that day and drops papers published after it.
"""
raw = response.get("results") if isinstance(response, dict) else None
if not isinstance(raw, list):
return []
now = today or _today()
+ end_date = date.fromisoformat(to_date) if to_date else None
+ if end_date is not None:
+ now = min(now, datetime.combine(end_date, time.max, tzinfo=timezone.utc))
items: List[Dict[str, Any]] = []
for i, entry in enumerate(raw):
if not isinstance(entry, dict):
@@ -279,6 +286,8 @@ def parse_arxiv_response(
if published is None:
# No usable date -> cannot honor the recency contract; drop.
continue
+ if end_date is not None and published.date() > end_date:
+ continue
age_days = (now - published).days
# Allow a one-day grace on the future side: a paper announced later in
# the same UTC day yields age_days == -1 (timedelta.days floors toward
diff --git a/skills/last30days/scripts/lib/pipeline.py b/skills/last30days/scripts/lib/pipeline.py
index 584c3f12..d2f4b616 100644
--- a/skills/last30days/scripts/lib/pipeline.py
+++ b/skills/last30days/scripts/lib/pipeline.py
@@ -6116,7 +6116,7 @@ def _retrieve_stream_impl(
# search_query, so off-topic narrowing does not let weak matches through.
relevance_topic = raw_topic or topic or subquery.search_query
return (
- arxiv.parse_arxiv_response(result, query=relevance_topic),
+ arxiv.parse_arxiv_response(result, query=relevance_topic, to_date=to_date),
_result_outcome_artifact(source, result),
)
if source == "techmeme":
diff --git a/tests/test_arxiv_source.py b/tests/test_arxiv_source.py
index 8efed231..c2a3222e 100644
--- a/tests/test_arxiv_source.py
+++ b/tests/test_arxiv_source.py
@@ -162,6 +162,47 @@ def test_same_day_future_timestamp_is_kept():
assert len(items) == 1
+def test_as_of_window_anchors_recency_and_drops_later_papers(monkeypatch):
+ # An --as-of run ends the window in the past. The adapter must judge
+ # recency from that end date, not from the real clock: a paper published
+ # after the window cannot appear, and one from just inside it must not be
+ # dropped as "older than a year" relative to today.
+ from lib import pipeline, schema
+
+ entries = [
+ _entry("Window paper", "2025-05-20T12:00:00Z"),
+ _entry("End day paper", "2025-06-01T23:30:00Z"),
+ _entry("Later paper", "2025-06-02T00:30:00Z"),
+ _entry("Much later paper", "2026-01-15T12:00:00Z"),
+ ]
+ monkeypatch.setattr(
+ arxiv, "search_arxiv", lambda *_args, **_kwargs: {"results": entries}
+ )
+ subquery = schema.SubQuery(
+ label="primary",
+ search_query="paper",
+ ranking_query="paper",
+ sources=["arxiv"],
+ )
+
+ items, _ = pipeline._retrieve_stream_impl(
+ topic="paper",
+ subquery=subquery,
+ source="arxiv",
+ config={},
+ depth="quick",
+ date_range=("2025-05-02", "2025-06-01"),
+ runtime=schema.ProviderRuntime(
+ reasoning_provider="none",
+ planner_model="none",
+ rerank_model="none",
+ ),
+ mock=False,
+ )
+
+ assert [item["title"] for item in items] == ["Window paper", "End day paper"]
+
+
class _Proc:
def __init__(self, rc, out, err=""):
self.returncode, self.stdout, self.stderr = rc, out, err