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(planner): keep explicitly requested available sources (#1274)

Jay Hemnani142fb819d1cb
diff --git a/changelog.d/+planner-keep-requested-sources.fixed.md b/changelog.d/+planner-keep-requested-sources.fixed.md
new file mode 100644
index 00000000..a5652dee
--- /dev/null
+++ b/changelog.d/+planner-keep-requested-sources.fixed.md
@@ -0,0 +1 @@
+Sources named in `--search` are no longer dropped by intent routing at default and deep depth (for example, Polymarket on a topic classified as a concept or how-to).
diff --git a/skills/last30days/scripts/lib/planner.py b/skills/last30days/scripts/lib/planner.py
index de03832f..44ce62d9 100644
--- a/skills/last30days/scripts/lib/planner.py
+++ b/skills/last30days/scripts/lib/planner.py
@@ -621,6 +621,11 @@ def _trim_subqueries_for_depth(
# Operator-supplied --plan is a contract: keep per-subquery sources.
if depth != "quick" and not honor_plan_sources:
expanded_sources = _default_sources_for_intent(intent, available_sources)
+ # Explicit --search sources are a user override: intent routing must not drop them.
+ expanded_sources += [
+ source for source in available_sources
+ if source in (requested_sources or []) and source not in expanded_sources
+ ]
return [
schema.SubQuery(
label=subquery.label,
diff --git a/tests/test_planner_v3.py b/tests/test_planner_v3.py
index 838bda22..cab3d946 100644
--- a/tests/test_planner_v3.py
+++ b/tests/test_planner_v3.py
@@ -433,6 +433,28 @@ class PlannerV3Tests(unittest.TestCase):
self.assertNotIn("polymarket", all_sources,
f"polymarket should be excluded from {expected_intent}")
+ def test_explicit_requested_sources_survive_intent_routing(self):
+ """--search sources are a user override at default/deep depth too."""
+ for topic, requested, expected_intent in [
+ ("will the fed cut rates in december", ["hackernews", "polymarket"], "concept"),
+ ("how to deploy on Fly.io", ["reddit", "youtube", "polymarket", "stocktwits"], "how_to"),
+ ]:
+ for depth in ("default", "deep"):
+ with self.subTest(topic=topic, depth=depth):
+ plan = planner.plan_query(
+ topic=topic,
+ available_sources=requested,
+ requested_sources=requested,
+ depth=depth,
+ provider=None,
+ model=None,
+ )
+ self.assertEqual(expected_intent, plan.intent)
+ all_sources = set()
+ for subquery in plan.subqueries:
+ all_sources.update(subquery.sources)
+ self.assertEqual(set(requested), all_sources)
+
def test_opinion_includes_polymarket(self):
"""Polymarket should not be excluded from opinion intent plans."""
plan = planner.plan_query(