fix: Simplify Reddit prompt and increase search volume
OpenAI's web_search doesn't reliably find recent Reddit content. Strategy change: request MORE threads and let server-side date filtering handle it. Changes: - Increased depth config (20-30 → 30-50 default) - Simplified prompt to search broadly and include all matches - Let server-side date filter remove old content - Removed aggressive pre-filtering that was limiting results Tradeoff: Some topics have more X coverage than Reddit due to web_search limitations. This is acceptable. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -16,54 +16,54 @@ def _log_error(msg: str):
|
|||||||
OPENAI_RESPONSES_URL = "https://api.openai.com/v1/responses"
|
OPENAI_RESPONSES_URL = "https://api.openai.com/v1/responses"
|
||||||
|
|
||||||
# Depth configurations: (min, max) threads to request
|
# Depth configurations: (min, max) threads to request
|
||||||
|
# Request MORE than needed since many get filtered by date
|
||||||
DEPTH_CONFIG = {
|
DEPTH_CONFIG = {
|
||||||
"quick": (8, 12),
|
"quick": (15, 25),
|
||||||
"default": (20, 30),
|
"default": (30, 50),
|
||||||
"deep": (50, 70),
|
"deep": (70, 100),
|
||||||
}
|
}
|
||||||
|
|
||||||
REDDIT_SEARCH_PROMPT = """Find RECENT Reddit discussion threads about: {topic}
|
REDDIT_SEARCH_PROMPT = """Find Reddit discussion threads about: {topic}
|
||||||
|
|
||||||
STEP 1: EXTRACT THE CORE SUBJECT
|
STEP 1: EXTRACT THE CORE SUBJECT
|
||||||
Strip qualifiers and get the MAIN NOUN/PRODUCT/TOPIC:
|
Get the MAIN NOUN/PRODUCT/TOPIC:
|
||||||
- "best nano banana prompting practices" → "nano banana"
|
- "best nano banana prompting practices" → "nano banana"
|
||||||
- "killer features of clawdbot" → "clawdbot"
|
- "killer features of clawdbot" → "clawdbot"
|
||||||
- "top Claude Code skills" → "Claude Code skills"
|
- "top Claude Code skills" → "Claude Code"
|
||||||
DO NOT search for "best", "top", "tips", "practices" - just the core subject.
|
DO NOT include "best", "top", "tips", "practices", "features" in your search.
|
||||||
|
|
||||||
STEP 2: SEARCH FOR RECENT CONTENT (CRITICAL)
|
STEP 2: SEARCH BROADLY
|
||||||
You MUST search with date filters to find recent threads:
|
Search for the core subject:
|
||||||
1. "[core subject] site:reddit.com after:{from_date}"
|
1. "[core subject] site:reddit.com"
|
||||||
2. "reddit [core subject] 2026" or "reddit [core subject] January 2026"
|
2. "reddit [core subject]"
|
||||||
3. "[core subject] site:reddit.com/r/"
|
3. "[core subject] reddit"
|
||||||
|
|
||||||
The goal is threads from {from_date} to {to_date}. Older threads are NOT useful.
|
Return as many relevant threads as you find. We filter by date server-side.
|
||||||
|
|
||||||
STEP 3: VALIDATE DATES
|
STEP 3: INCLUDE ALL MATCHES
|
||||||
Before including a thread, verify its date is AFTER {from_date}.
|
- Include ALL threads about the core subject
|
||||||
If you cannot determine the date, set date to null.
|
- Set date to "YYYY-MM-DD" if you can determine it, otherwise null
|
||||||
EXCLUDE threads you know are older than {from_date}.
|
- We verify dates and filter old content server-side
|
||||||
|
- DO NOT pre-filter aggressively - include anything relevant
|
||||||
|
|
||||||
REQUIRED URL FORMAT: Must contain "/r/" AND "/comments/"
|
REQUIRED: URLs must contain "/r/" AND "/comments/"
|
||||||
REJECT: developers.reddit.com, business.reddit.com, reddit.com/user/
|
REJECT: developers.reddit.com, business.reddit.com
|
||||||
|
|
||||||
Find {min_items}-{max_items} RECENT discussion threads (from last 30 days).
|
Find {min_items}-{max_items} threads. Return MORE rather than fewer.
|
||||||
|
|
||||||
Return JSON:
|
Return JSON:
|
||||||
{{
|
{{
|
||||||
"items": [
|
"items": [
|
||||||
{{
|
{{
|
||||||
"title": "Thread title",
|
"title": "Thread title",
|
||||||
"url": "https://www.reddit.com/r/subreddit/comments/xyz/title/",
|
"url": "https://www.reddit.com/r/sub/comments/xyz/title/",
|
||||||
"subreddit": "subreddit_name",
|
"subreddit": "subreddit_name",
|
||||||
"date": "YYYY-MM-DD or null",
|
"date": "YYYY-MM-DD or null",
|
||||||
"why_relevant": "How this relates to {topic}",
|
"why_relevant": "Why relevant",
|
||||||
"relevance": 0.85
|
"relevance": 0.85
|
||||||
}}
|
}}
|
||||||
]
|
]
|
||||||
}}
|
}}"""
|
||||||
|
|
||||||
IMPORTANT: Only return threads from the last 30 days. Old threads will be filtered out anyway."""
|
|
||||||
|
|
||||||
|
|
||||||
def search_reddit(
|
def search_reddit(
|
||||||
|
|||||||
Reference in New Issue
Block a user