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(github): bound keyword searches by the window end date (#1304)

Jay Hemnani18c54f76c4c2
diff --git a/changelog.d/+github-keyword-window-end.fixed.md b/changelog.d/+github-keyword-window-end.fixed.md
new file mode 100644
index 00000000..f4bc6d05
--- /dev/null
+++ b/changelog.d/+github-keyword-window-end.fixed.md
@@ -0,0 +1 @@
+GitHub keyword searches now stop at the research window end, so an `--as-of` run no longer spends its result slots on issues created after the window and then drops them.
diff --git a/skills/last30days/scripts/lib/github.py b/skills/last30days/scripts/lib/github.py
index f8495809..1eef281e 100644
--- a/skills/last30days/scripts/lib/github.py
+++ b/skills/last30days/scripts/lib/github.py
@@ -169,7 +169,7 @@ def _compute_relevance(
# GitHub search qualifiers the planner sometimes writes straight into the topic
# string (e.g. "open source AI stars:>1000 created:>2025-03-20"). They must not
# reach the query builder in `search_github`: it appends its own
-# `created:>{from_date}`, and when two `created:` qualifiers collide GitHub
+# `created:{from_date}..{to_date}`, and when two `created:` qualifiers collide GitHub
# honours the FIRST and silently ignores ours. The API then returns
# out-of-window items that `parse_github_response`'s date filter drops
# wholesale — a source that fetches results and reports zero (issue #949).
@@ -301,7 +301,7 @@ def search_github(
_log(f"Searching for '{core}' (raw: '{topic}', since {from_date}, count={count})")
# Build search query with date filter
- base_q = f"{core} created:>{from_date}"
+ base_q = f"{core} created:{from_date}..{to_date}"
def _search(qualifier: Optional[str]) -> Optional[Dict[str, Any]]:
q = f"{base_q} {qualifier}" if qualifier else base_q
diff --git a/tests/test_github.py b/tests/test_github.py
index 6f7101ff..3eed05a8 100644
--- a/tests/test_github.py
+++ b/tests/test_github.py
@@ -148,6 +148,16 @@ class TestSearchGithub(unittest.TestCase):
self.assertEqual(item["engagement"]["comments"], 12)
self.assertFalse(item["metadata"]["is_pr"])
+ @patch.object(github, "_fetch_json", return_value={"items": []})
+ @patch.object(github, "_resolve_token", return_value="test-token")
+ def test_search_is_bounded_by_window_end(self, mock_token, mock_fetch):
+ """An --as-of window must not fetch issues created after its end date."""
+ github.search_github("react", "2026-05-31", "2026-06-30")
+ self.assertTrue(mock_fetch.call_args_list)
+ for call in mock_fetch.call_args_list:
+ q = urllib.parse.parse_qs(urllib.parse.urlparse(call.args[0]).query)["q"][0]
+ self.assertIn("created:2026-05-31..2026-06-30", q)
+
@patch.object(github, "_fetch_json", return_value=None)
@patch.object(github, "_resolve_token", return_value="test-token")
def test_rate_limit_returns_empty_envelope(self, mock_token, mock_fetch):
@@ -729,7 +739,7 @@ class TestSearchGithubQualifiers(unittest.TestCase):
# rather than against a single exact string.
self.assertEqual(len(queries), 2)
for q in queries:
- self.assertTrue(q.startswith("open source ai created:>2026-07-01"))
+ self.assertTrue(q.startswith("open source ai created:2026-07-01..2026-07-31"))
self.assertEqual(q.count("created:"), 1)
self.assertNotIn("stars:", q)
self.assertEqual(
@@ -839,7 +849,7 @@ class TestSearchGithubQualifiers(unittest.TestCase):
)
q = self._query(captured["url"])
self.assertEqual(q.count("created:"), 1)
- self.assertIn("created:>2026-07-01", q)
+ self.assertIn("created:2026-07-01..2026-07-31", q)
self.assertNotIn("created:>2025-03-20", q)
@patch.object(github, "_resolve_token", return_value="test-token")
@@ -876,9 +886,9 @@ class TestSearchGithubQualifiers(unittest.TestCase):
queries = [self._query(u) for u in captured["urls"]]
self.assertEqual(len(queries), 2)
for q in queries:
- self.assertTrue(q.startswith("open source ai created:>2026-07-01"))
+ self.assertTrue(q.startswith("open source ai created:2026-07-01..2026-07-31"))
self.assertEqual(q.count("created:"), 1)
- self.assertIn("created:>2026-07-01", q)
+ self.assertIn("created:2026-07-01..2026-07-31", q)
self.assertNotIn("created:>2025-03-20", q)
self.assertIn("open source", q)
self.assertIn("ai", q)
diff --git a/tests/test_github_window.py b/tests/test_github_window.py
new file mode 100644
index 00000000..82a8f57c
--- /dev/null
+++ b/tests/test_github_window.py
@@ -0,0 +1,65 @@
+"""Historical-window regressions through GitHub search and normalization."""
+
+from urllib.parse import parse_qs, urlparse
+from unittest.mock import patch
+
+import pytest
+
+from lib import github
+
+
[email protected]("depth, count", [("quick", 15), ("default", 30), ("deep", 60)])
[email protected]("token", [None, "test-token"])
+def test_search_preserves_both_window_bounds_in_every_query(depth, count, token):
+ with patch.object(github, "_resolve_token", return_value=token), patch.object(
+ github, "_fetch_json", return_value={"items": []}, autospec=True
+ ) as fetch:
+ github.search_github(
+ "react created:>2025-01-01", "2024-02-01", "2024-02-29", depth=depth
+ )
+
+ expected_qualifiers = ["is:issue", "is:pull-request"] if token else [None]
+ assert fetch.call_count == len(expected_qualifiers)
+ for call, qualifier in zip(fetch.call_args_list, expected_qualifiers):
+ params = parse_qs(urlparse(call.args[0]).query)
+ expected_query = "react created:2024-02-01..2024-02-29"
+ if qualifier:
+ expected_query += f" {qualifier}"
+ assert params["q"] == [expected_query]
+ expected_count = count if token else 10
+ assert params["per_page"] == [str(expected_count)]
+ assert params["sort"] == ["reactions"]
+ assert params["order"] == ["desc"]
+ assert call.kwargs["token"] == token
+
+
[email protected]("token", [None, "test-token"])
+def test_search_and_parse_include_full_boundary_days_and_exclude_adjacent_days(token):
+ timestamps = [
+ "2024-01-31T23:59:59Z",
+ "2024-02-01T00:00:00Z",
+ "2024-02-29T23:59:59Z",
+ "2024-03-01T00:00:00Z",
+ ]
+ raw_items = [
+ {
+ "id": index,
+ "html_url": f"https://github.com/example/react/issues/{index}",
+ "title": f"React issue {index}",
+ "created_at": timestamp,
+ "reactions": {"total_count": index},
+ }
+ for index, timestamp in enumerate(timestamps, start=1)
+ ]
+ with patch.object(github, "_resolve_token", return_value=token), patch.object(
+ github, "_fetch_json", return_value={"items": raw_items}, autospec=True
+ ):
+ response = github.search_github("react", "2024-02-01", "2024-02-29")
+
+ items = github.parse_github_response(response)
+
+ assert {item["url"] for item in items} == {
+ "https://github.com/example/react/issues/2",
+ "https://github.com/example/react/issues/3",
+ }
+ assert {item["date"] for item in items} == {"2024-02-01", "2024-02-29"}