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(bluesky): honor requested search date window (#984)

xuyua90341304f8ecb
diff --git a/changelog.d/984.fixed.md b/changelog.d/984.fixed.md
new file mode 100644
index 00000000..52b4f669
--- /dev/null
+++ b/changelog.d/984.fixed.md
@@ -0,0 +1 @@
+Authenticated Bluesky searches now send RFC3339 date-time bounds, preventing valid date windows from being rejected as malformed requests.
diff --git a/skills/last30days/scripts/lib/bluesky.py b/skills/last30days/scripts/lib/bluesky.py
index 6d07412d..8f6309d1 100644
--- a/skills/last30days/scripts/lib/bluesky.py
+++ b/skills/last30days/scripts/lib/bluesky.py
@@ -15,9 +15,8 @@ bad hygiene (no scope, can't revoke individually).
import math
import os
import re
-import sys
import time
-from datetime import datetime, timezone
+from datetime import datetime, timedelta
from typing import Any, Dict, List, Optional
from . import http, log
@@ -232,6 +231,25 @@ def _parse_date(item: Dict[str, Any]) -> Optional[str]:
return None
+def _exclusive_until_date(to_date: str) -> str:
+ """Convert the inclusive pipeline end date to an RFC3339 exclusive bound."""
+ try:
+ value = datetime.strptime(to_date, "%Y-%m-%d") + timedelta(days=1)
+ return value.strftime("%Y-%m-%dT00:00:00Z")
+ except ValueError:
+ # Keep the request usable for callers that pass a provider-specific date value.
+ return to_date
+
+
+def _inclusive_since_date(from_date: str) -> str:
+ """Convert the inclusive pipeline start date to an RFC3339 lower bound."""
+ try:
+ return datetime.strptime(from_date, "%Y-%m-%d").strftime("%Y-%m-%dT00:00:00Z")
+ except ValueError:
+ # Keep the request usable for callers that pass a provider-specific date value.
+ return from_date
+
+
def search_bluesky(
topic: str,
from_date: str,
@@ -282,6 +300,8 @@ def search_bluesky(
"q": core_topic,
"limit": str(min(count, 100)),
"sort": "top",
+ "since": _inclusive_since_date(from_date),
+ "until": _exclusive_until_date(to_date),
}
url = f"{_resolve_search_url(config)}?{urlencode(params)}"
diff --git a/tests/test_bluesky.py b/tests/test_bluesky.py
index 1b3af9b5..17764d73 100644
--- a/tests/test_bluesky.py
+++ b/tests/test_bluesky.py
@@ -2,7 +2,8 @@
import os
import unittest
-from unittest.mock import patch, MagicMock
+from urllib.parse import parse_qs, urlparse
+from unittest.mock import patch
from lib import bluesky
@@ -192,6 +193,20 @@ class TestSearchBlueskyAuth(unittest.TestCase):
search_call = mock_request.call_args_list[1]
self.assertEqual(search_call.kwargs.get("headers", {}), {"Authorization": "Bearer tok123"})
+ @patch("lib.bluesky.http.request")
+ def test_successful_search_passes_inclusive_date_window_to_api(self, mock_request):
+ mock_request.side_effect = [
+ {"accessJwt": "tok123", "refreshJwt": "ref456"},
+ {"posts": []},
+ ]
+ config = {"BSKY_HANDLE": "user.bsky.social", "BSKY_APP_PASSWORD": "pw"}
+ bluesky.search_bluesky("test", "2026-01-01", "2026-03-09", config=config)
+
+ search_url = mock_request.call_args_list[1].args[1]
+ query = parse_qs(urlparse(search_url).query)
+ self.assertEqual(query["since"], ["2026-01-01T00:00:00Z"])
+ self.assertEqual(query["until"], ["2026-03-10T00:00:00Z"])
+
@patch("lib.bluesky.http.request")
def test_401_search_refreshes_session_with_refresh_jwt(self, mock_request):
from lib.http import HTTPError