AI agent skill that researches any topic across Reddit, X, YouTube, HN, Polymarket, and the web - then synthesizes a grounded summary
Python ai-promptsai-skillblueskyclaudeclaude-codeclawhubdeep-researchhackernewsinstagramopenclawpolymarketrecencyredditresearchsocial-mediatiktoktrendstwitterweb-searchyoutube
Retrieve-Judge-Retry for X Search
Date: 2026-08-14
Status: Completed
Problem Statement
X search results become off-topic when multi-word search queries are phrase-quoted. The Rome failure (2026-08-14) demonstrated this:
- Planner generated
search_query: "Rome Italy"(phrase-quoted) - Phrase-quoting returned thin hits with engagement bait (pretty-cities, geopolitics accounts)
entity_extractranked off-topic handles (PrettyCitiesX, visegrad24) by frequencypipeline.pypromoted those handles to the FROM lane- FROM lane filled the 40-slot X budget with off-topic timelines
Solution
Implement retrieve-judge-retry for X search:
- Query Compilation (R2): X now uses
raw_topiclike Reddit/YouTube, not the planner'ssearch_query - Fanout Queries (R3): Multi-word topics use unquoted AND as first variant; phrase-quote only for proper names
- Corpus Judging (R7): New
x_judge.pymodule evaluates corpus on-topic ratio after retrieval - Retry (R1): If off-topic flood detected (ratio < 0.4), retry ONCE with simplified keyword query inside the X stream (not
_retry_thin_sources) - Split FROM Promotion (R4):
- Explicit handles (--x-handle): always FROM, no AND topic
- Extracted handles: FROM only if ≥2 on-topic hits AND ≥50% ratio, and they DO AND the topic
- First-Party Exemption (R5): Floor immunity stays conservative (explicit handles only)
- Status Reporting (R6): Off-topic floods emit artifact warning, not
record_failure(PARTIAL)
Implementation Details
New Module: x_judge.py
judge_x_corpus(items, topic, ranking_query): Returns on_topic_ratio, is_off_topic_flood, on_topic_items, handle_statspromotable_handles(items, topic, extracted_handles, explicit_handles): Returns (explicit_promotable, extracted_promotable)should_retry_x_search(items, topic, depth): Returns True if retry warrantedprune_off_topic_items(items, topic): Returns only on-topic items
Key Changes
grok_x._fanout_queries(): No phrase-quote for place/disambiguation stringsgrok_x._is_proper_name(): Detects title-cased proper names for phrase-quotinggrok_x.search_handles(): Addedand_topicparameter (default False)pipeline._fetch_x_backend(): Accepts query directly, not subquerypipeline._retrieve_stream_impl(): X source uses raw_topic, judges corpus, retries if neededpipeline._run_supplemental_searches(): Usespromotable_handlesfor split FROM logic
Tests
tests/test_x_judge.py: New test file for x_judge moduletests/test_grok_x.py: Added fanout and and_topic teststests/test_pipeline_v3.py: Updated fixtures to have promotable content
Success Criteria
-
_fanout_queries("Rome Italy")has no"Rome Italy"variant -
search_name("Peter Steinberger")still phrase-quotes -
search_handles(["steipete"], "topic")does not AND topic by default -
search_handles(["visegrad24"], "Rome", and_topic=True)does AND Rome - Explicit --x-handle always gets FROM lane
- Off-topic handles (visegrad24) not promoted to FROM lane
- On-topic handles (mamboitaliano__) promoted to FROM lane
- X source status is artifact warning, not PARTIAL failure
- All tests pass
Out of Scope
- No live Grok calls in tests
- No auth/doctor touch
- No collision lexicon (AS Roma / Odunze still appear; judge + ranking_query drop them)
- bird_x quote-preserving
build_topic_query(follow-up if needed)