feat: Add honesty warning when results aren't from last 30 days
Adds ⚠️ LIMITED RECENT DATA warning when: - Fewer than 5 items are confirmed from the date range - Tells Claude to be transparent with user about data freshness Example output for obscure topic (June Oven): "Only 4 item(s) confirmed from 2025-12-26 to 2026-01-25. Results below may include older/evergreen content." Popular topics (clawdbot, nano banana) don't show the warning. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -14,6 +14,26 @@ def ensure_output_dir():
|
|||||||
OUTPUT_DIR.mkdir(parents=True, exist_ok=True)
|
OUTPUT_DIR.mkdir(parents=True, exist_ok=True)
|
||||||
|
|
||||||
|
|
||||||
|
def _assess_data_freshness(report: schema.Report) -> dict:
|
||||||
|
"""Assess how much data is actually from the last 30 days."""
|
||||||
|
reddit_recent = sum(1 for r in report.reddit if r.date and r.date >= report.range_from)
|
||||||
|
x_recent = sum(1 for x in report.x if x.date and x.date >= report.range_from)
|
||||||
|
web_recent = sum(1 for w in report.web if w.date and w.date >= report.range_from)
|
||||||
|
|
||||||
|
total_recent = reddit_recent + x_recent + web_recent
|
||||||
|
total_items = len(report.reddit) + len(report.x) + len(report.web)
|
||||||
|
|
||||||
|
return {
|
||||||
|
"reddit_recent": reddit_recent,
|
||||||
|
"x_recent": x_recent,
|
||||||
|
"web_recent": web_recent,
|
||||||
|
"total_recent": total_recent,
|
||||||
|
"total_items": total_items,
|
||||||
|
"is_sparse": total_recent < 5,
|
||||||
|
"mostly_evergreen": total_items > 0 and total_recent < total_items * 0.3,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
def render_compact(report: schema.Report, limit: int = 15, missing_keys: str = "none") -> str:
|
def render_compact(report: schema.Report, limit: int = 15, missing_keys: str = "none") -> str:
|
||||||
"""Render compact output for Claude to synthesize.
|
"""Render compact output for Claude to synthesize.
|
||||||
|
|
||||||
@@ -31,6 +51,14 @@ def render_compact(report: schema.Report, limit: int = 15, missing_keys: str = "
|
|||||||
lines.append(f"## Research Results: {report.topic}")
|
lines.append(f"## Research Results: {report.topic}")
|
||||||
lines.append("")
|
lines.append("")
|
||||||
|
|
||||||
|
# Assess data freshness and add honesty warning if needed
|
||||||
|
freshness = _assess_data_freshness(report)
|
||||||
|
if freshness["is_sparse"]:
|
||||||
|
lines.append("**⚠️ LIMITED RECENT DATA** - Few discussions from the last 30 days.")
|
||||||
|
lines.append(f"Only {freshness['total_recent']} item(s) confirmed from {report.range_from} to {report.range_to}.")
|
||||||
|
lines.append("Results below may include older/evergreen content. Be transparent with the user about this.")
|
||||||
|
lines.append("")
|
||||||
|
|
||||||
# Web-only mode banner (when no API keys)
|
# Web-only mode banner (when no API keys)
|
||||||
if report.mode == "web-only":
|
if report.mode == "web-only":
|
||||||
lines.append("**🌐 WEB SEARCH MODE** - Claude will search blogs, docs & news")
|
lines.append("**🌐 WEB SEARCH MODE** - Claude will search blogs, docs & news")
|
||||||
|
|||||||
Reference in New Issue
Block a user