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: reject low-confidence general evidence

terry-li-hm5901a0b51aec
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 2315262a..476b5178 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
+### Fixed
+
+- General reports no longer promote unanchored fallback entity misses, zero-score clusters, or comments attached only to rejected evidence into synthesis.
+
## [3.18.0] - 2026-07-21
### Changed
diff --git a/skills/last30days/SKILL.md b/skills/last30days/SKILL.md
index 3ad75725..e6b34fbc 100644
--- a/skills/last30days/SKILL.md
+++ b/skills/last30days/SKILL.md
@@ -161,6 +161,8 @@ These LAWs dominate every other rule in this file. If you find yourself about to
**LAW 6 - NO RAW RANKED EVIDENCE CLUSTERS IN BODY.** The engine's `## Ranked Evidence Clusters`, `## Stats`, and `## Source Coverage` blocks are bounded inside `<!-- EVIDENCE FOR SYNTHESIS -->` / `<!-- END EVIDENCE FOR SYNTHESIS -->` comments in the `--emit compact` / `--emit md` stdout. They are raw evidence for YOU to read, not output to emit. Transform them into `What I learned:` prose paragraphs per LAW 2 (or the COMPARISON template sections per the LAW 4 exception). If your response contains the literal string `### 1.` followed by a score tuple like `(score N, M items, sources: ...)`, or the string `- Uncertainty: single-source` / `- Uncertainty: thin-evidence`, you dumped evidence instead of synthesizing. STOP and regenerate.
+**GENERAL nothing-solid floor.** If the `## Ranked Evidence Clusters` block says `Nothing solid this window`, the engine found items but every visible cluster failed the positive, non-entity-miss relevance floor. Treat that community evidence as absent: do not infer findings from its stats, quote its comments, or satisfy LAW 9 from rejected candidates. Build the `What I learned:` body only from supported Step 2 web supplements, if any, and say plainly that recent community evidence was insufficient without narrating engine mechanics. If the supplements are also insufficient, an honest short no-finding answer is the result; retain the engine footer and invitation.
+
**Per-run source outcomes (doctor-aligned):** Read `## Partial Coverage` and `Report.source_status` before synthesizing. `no-results` means the source completed cleanly with zero matches. `partial`, `rate-limited`, `auth-failed`, `unreachable`, `timeout`, `schema-drift`, `skipped-unconfigured`, and `error` mean the run did not establish that the source was quiet. Never write "nothing on X/Reddit/YouTube" for those states; qualify the conclusion as partial coverage and rely only on evidence that was actually returned. The engine footer carries the user-visible outcome and `doctor` pointer, so do not invent a repair prescription in prose. Plain `doctor` predicts configuration health before a run; `source_status` reports what happened during this run, and `doctor --postmortem` reads that same `source_status` from the last run's cache to report what actually broke after the fact.
**Observed LAW 6 violation (2026-04-19, Hermes Agent Use Cases disaster):** two consecutive `/last30days Hermes Agent (Actual) Use Cases` runs returned the raw `## Ranked Evidence Clusters` block verbatim as user output, with 8 cluster entries carrying `(score N, M items, sources: ...)` tuples and `- Uncertainty: single-source` lines. Root cause: the prior canonical-boundary text said "Pass through the lines ABOVE this boundary verbatim," which the model scoped broadly to include the scratchpad. The current boundary text and this LAW 6 scope pass-through to the PASS-THROUGH FOOTER block only. A third run on the same topic framed as "Hermes Workflows" produced the correct `What I learned:` prose synthesis, which is the shape every run must produce.
@@ -1670,7 +1672,7 @@ Read the research output carefully. Pay attention to:
**ANTI-PATTERN TO AVOID**: If user asks about "clawdbot skills" and research returns ClawdBot content (self-hosted AI agent), do NOT synthesize this as "Claude Code skills" just because both involve "skills". Read what the research actually says.
-**FUN CONTENT (see LAW 9): the EVIDENCE block's `## Top Community Comments` section (always present when 2+ comments exist) and any `## Best Takes` section are the voice of the people - weave at least 2 of the funniest/cleverest VERBATIM quotes into your synthesis.** A 1,338-upvote comment that says "Where's the limewire link" tells you more about the cultural moment than a news article. Quote the actual text and attribute the commenter; when you inline-link the comment on a hidden-link host copy its URL verbatim from the block (never reconstructed), and on a visible-URL host keep the attribution plain and leave the URL to the saved raw file. Don't put fun content in a separate section - mix it into the narrative where it fits naturally. This is what makes the report feel alive rather than like a news summary. Do NOT wait for a `## Best Takes` section - it is often empty; `## Top Community Comments` is the always-on source.
+**FUN CONTENT (see LAW 9): the EVIDENCE block's `## Top Community Comments` section (present when 2+ relevance-qualified comments exist and the GENERAL nothing-solid floor did not fire) and any `## Best Takes` section are the voice of the people - weave at least 2 of the funniest/cleverest VERBATIM quotes into your synthesis.** A 1,338-upvote comment that says "Where's the limewire link" tells you more about the cultural moment than a news article. Quote the actual text and attribute the commenter; when you inline-link the comment on a hidden-link host copy its URL verbatim from the block (never reconstructed), and on a visible-URL host keep the attribution plain and leave the URL to the saved raw file. Don't put fun content in a separate section - mix it into the narrative where it fits naturally. This is what makes the report feel alive rather than like a news summary. Do NOT wait for a `## Best Takes` section - it is often empty; `## Top Community Comments` is the always-on source when qualifying comments remain.
**ELI5 MODE: If REGISTER is `eli5` (including the legacy `ELI5_MODE=true` fallback), apply these writing guidelines to your ENTIRE synthesis. Otherwise skip this block completely and write normally.**
diff --git a/skills/last30days/scripts/lib/pipeline.py b/skills/last30days/scripts/lib/pipeline.py
index 92cd9b68..ac81ccf5 100644
--- a/skills/last30days/scripts/lib/pipeline.py
+++ b/skills/last30days/scripts/lib/pipeline.py
@@ -2410,6 +2410,8 @@ def run(
shortlist_size=settings["rerank_limit"],
resolved_handles=resolved_handles,
)
+ ranked_public = rerank.prune_fallback_entity_misses(ranked_public, topic=topic)
+ ranked_private = rerank.prune_fallback_entity_misses(ranked_private, topic=topic)
ranked_candidates = sorted(
[*ranked_public, *ranked_private],
key=lambda candidate: (
diff --git a/skills/last30days/scripts/lib/render.py b/skills/last30days/scripts/lib/render.py
index 0d107311..d0f74910 100644
--- a/skills/last30days/scripts/lib/render.py
+++ b/skills/last30days/scripts/lib/render.py
@@ -337,7 +337,16 @@ def _render_ranked_clusters(
candidate_by_id = {
candidate.candidate_id: candidate for candidate in report.ranked_candidates
}
- for index, cluster in enumerate(clusters, start=1):
+ solid_clusters = _clusters_clearing_relevance_floor(report, clusters)
+ if clusters and not solid_clusters:
+ lines.extend([
+ "**Nothing solid this window.**",
+ "",
+ "No recent evidence cluster cleared the relevance floor. "
+ "Do not infer findings or quote community comments from this run.",
+ "",
+ ])
+ for index, cluster in enumerate(solid_clusters, start=1):
lines.append(
f"### {index}. {cluster.title} "
f"(score {cluster.score:.0f}, {len(cluster.candidate_ids)} "
@@ -355,6 +364,47 @@ def _render_ranked_clusters(
return lines
+def _clusters_clearing_relevance_floor(
+ report: schema.Report,
+ clusters: list[schema.Cluster],
+) -> list[schema.Cluster]:
+ """Return visible clusters with positive, non-entity-miss evidence.
+
+ A zero-score cluster is diagnostic retrieval residue rather than evidence.
+ Likewise, a positive cluster whose known representatives are all explicitly
+ entity-miss-demoted must not be promoted by engagement into the synthesis.
+ Missing representative records are not treated as a miss: score remains the
+ only signal available in that defensive edge case.
+ """
+ candidate_by_id = {
+ candidate.candidate_id: candidate for candidate in report.ranked_candidates
+ }
+ solid: list[schema.Cluster] = []
+ for cluster in clusters:
+ if cluster.score <= 0:
+ continue
+ representatives = [
+ candidate_by_id[candidate_id]
+ for candidate_id in cluster.representative_ids
+ if candidate_id in candidate_by_id
+ ]
+ if representatives and all(
+ "entity-miss" in (candidate.explanation or "").lower()
+ for candidate in representatives
+ ):
+ continue
+ solid.append(cluster)
+ return solid
+
+
+def _visible_clusters_fail_relevance_floor(
+ report: schema.Report,
+ clusters: list[schema.Cluster],
+) -> bool:
+ """Whether a non-empty visible cluster set contains no usable evidence."""
+ return bool(clusters) and not _clusters_clearing_relevance_floor(report, clusters)
+
+
def _render_corpus_section(report: schema.Report, limit: int = 8) -> list[str]:
"""Render private local evidence in one removable, clearly badged block."""
candidates = [
@@ -473,35 +523,44 @@ def _render_registered_sections(
) -> list[str]:
"""Render one audience preset's ordered, budgeted evidence sections."""
- best_takes = _render_best_takes(
- report.ranked_candidates,
- limit=audience.budget_for("best_takes", int(fun_params["limit"])),
- threshold=float(fun_params["threshold"]),
- vote_weight=float(fun_params.get("vote_weight", 18.0)),
- # The preset's source emphasis must reach the lead section's own
- # ranking: a creator register surfaces TikTok/IG/YouTube takes ahead
- # of equally-rated HN or GitHub ones.
- source_weight=(audience.emphasis_for if audience.emphasis_weights else None),
- )
- if not best_takes:
- best_takes = ["## Best Takes", "", "- No qualifying takes surfaced in this run."]
-
- top_comments = _render_top_comments(
+ visible_clusters = _clusters_for_register(report, audience, cluster_limit)
+ no_solid_evidence = _visible_clusters_fail_relevance_floor(
report,
- limit=audience.budget_for("top_comments", 8),
+ visible_clusters,
)
- if not top_comments:
- top_comments = [
- "## Top Community Comments",
- "",
- "- No qualifying community comments surfaced in this run.",
- ]
+ if no_solid_evidence:
+ best_takes: list[str] = []
+ top_comments: list[str] = []
+ else:
+ best_takes = _render_best_takes(
+ report.ranked_candidates,
+ limit=audience.budget_for("best_takes", int(fun_params["limit"])),
+ threshold=float(fun_params["threshold"]),
+ vote_weight=float(fun_params.get("vote_weight", 18.0)),
+ # The preset's source emphasis must reach the lead section's own
+ # ranking: a creator register surfaces TikTok/IG/YouTube takes ahead
+ # of equally-rated HN or GitHub ones.
+ source_weight=(audience.emphasis_for if audience.emphasis_weights else None),
+ )
+ if not best_takes:
+ best_takes = ["## Best Takes", "", "- No qualifying takes surfaced in this run."]
+
+ top_comments = _render_top_comments(
+ report,
+ limit=audience.budget_for("top_comments", 8),
+ )
+ if not top_comments:
+ top_comments = [
+ "## Top Community Comments",
+ "",
+ "- No qualifying community comments surfaced in this run.",
+ ]
sections = {
- "hiring_signals": _render_hiring_signals(report),
+ "hiring_signals": [] if no_solid_evidence else _render_hiring_signals(report),
"clusters": _render_ranked_clusters(
report,
- _clusters_for_register(report, audience, cluster_limit),
+ visible_clusters,
),
"stats": _render_stats(report),
"best_takes": best_takes,
@@ -582,7 +641,16 @@ def render_compact(
# block below) vs "synthesize from" (this block).
lines.append("<!-- EVIDENCE FOR SYNTHESIS: read this, do not emit verbatim. Transform into `What I learned:` prose per LAW 2. -->")
lines.append("")
- hiring_block = _render_hiring_signals(evidence_report)
+ visible_clusters = evidence_report.clusters[:cluster_limit]
+ no_solid_evidence = _visible_clusters_fail_relevance_floor(
+ evidence_report,
+ visible_clusters,
+ )
+ hiring_block = (
+ []
+ if no_solid_evidence
+ else _render_hiring_signals(evidence_report)
+ )
if hiring_block and audience.name in {"default", "eli5"}:
lines.extend(hiring_block)
lines.append("")
@@ -590,21 +658,22 @@ def render_compact(
if audience.name in {"default", "eli5"}:
# Keep this legacy assembly byte-for-byte stable. ELI5 has always been
# a synthesis-only voice change, so it intentionally takes this path.
- lines.extend(_render_ranked_clusters(evidence_report, evidence_report.clusters[:cluster_limit]))
+ lines.extend(_render_ranked_clusters(evidence_report, visible_clusters))
lines.extend(_render_stats(evidence_report))
- best_takes = _render_best_takes(
- evidence_report.ranked_candidates,
- limit=fun_params["limit"],
- threshold=fun_params["threshold"],
- vote_weight=fun_params.get("vote_weight", 18.0),
- )
- if best_takes:
- lines.extend([""] + best_takes)
+ if not no_solid_evidence:
+ best_takes = _render_best_takes(
+ evidence_report.ranked_candidates,
+ limit=fun_params["limit"],
+ threshold=fun_params["threshold"],
+ vote_weight=fun_params.get("vote_weight", 18.0),
+ )
+ if best_takes:
+ lines.extend([""] + best_takes)
- top_comments = _render_top_comments(evidence_report)
- if top_comments:
- lines.extend([""] + top_comments)
+ top_comments = _render_top_comments(evidence_report)
+ if top_comments:
+ lines.extend([""] + top_comments)
outcome_note = _render_source_outcome_note(report)
if outcome_note:
@@ -2723,6 +2792,8 @@ def _render_top_comments(report, limit: int = 8) -> list[str]:
seen: set[str] = set()
scored: list[tuple[float, schema.Candidate, schema.SourceItem, dict, str]] = []
for cand in report.ranked_candidates:
+ if not _best_take_relevance_ok(cand):
+ continue
for item in cand.source_items:
# Pass min_score=0 here: the cross-platform list deliberately does
# NOT gate on the per-platform absolute floor, because a less-watched
diff --git a/skills/last30days/scripts/lib/rerank.py b/skills/last30days/scripts/lib/rerank.py
index 1e8473fe..255bb299 100644
--- a/skills/last30days/scripts/lib/rerank.py
+++ b/skills/last30days/scripts/lib/rerank.py
@@ -7,7 +7,7 @@ import math
import re
from datetime import datetime
-from . import http, providers, schema, signals
+from . import http, providers, relevance, schema, signals
# Penalty applied when a candidate does not mention the primary entity
@@ -19,6 +19,13 @@ from . import http, providers, schema, signals
# Hermes content.
ENTITY_MISS_PENALTY = 25.0
+# A fallback entity miss is hidden from synthesized evidence only when it also
+# lacks every stable raw-topic anchor. Explicitly scoped sources such as GitHub
+# project mode carry a high local-relevance floor and therefore escape this
+# visibility gate even when their short title omits the user's wording.
+FALLBACK_ENTITY_MISS_CONFIDENCE_ESCAPE = 0.5
+_FALLBACK_ENTITY_MISS_EXPLANATION = "fallback-local-score (entity-miss demotion)"
+
# Small additive credit for a post authored by one of the run's resolved
# handles (see rerank_candidates / _fallback_tuple). Deliberately small: the
# goal is to stop *burying* first-party posts, not to auto-win the ranking on
@@ -662,6 +669,36 @@ def _primary_entity(topic: str) -> str:
return stripped
+def prune_fallback_entity_misses(
+ candidates: list[schema.Candidate],
+ *,
+ topic: str,
+) -> list[schema.Candidate]:
+ """Hide unanchored, low-confidence fallback misses from visible evidence.
+
+ Broad recommendation queries can be misread as one long primary entity,
+ causing every fallback candidate to receive the entity-miss marker. The
+ marker alone is therefore not a safe filter. A candidate is removed only
+ when it also has no lexical overlap with the stable raw topic and lacks a
+ strong local-relevance signal from an explicitly scoped retrieval path.
+ Source items remain in the report's diagnostic source dump.
+ """
+ if not topic:
+ return candidates
+
+ kept: list[schema.Candidate] = []
+ for candidate in candidates:
+ if candidate.explanation != _FALLBACK_ENTITY_MISS_EXPLANATION:
+ kept.append(candidate)
+ continue
+ if candidate.local_relevance >= FALLBACK_ENTITY_MISS_CONFIDENCE_ESCAPE:
+ kept.append(candidate)
+ continue
+ if relevance.token_overlap_relevance(topic, _candidate_haystack(candidate)) > 0.0:
+ kept.append(candidate)
+ return kept
+
+
#: Secondary entity-miss penalty applied directly to final_score (not just
#: rerank_score). The -25 on rerank_score composes to only -15 on final_score
#: via the 0.60 weight, which engagement bonus partially offsets on
diff --git a/tests/test_render_v3.py b/tests/test_render_v3.py
index 6665f533..4486e39e 100644
--- a/tests/test_render_v3.py
+++ b/tests/test_render_v3.py
@@ -115,6 +115,52 @@ class RenderV3Tests(unittest.TestCase):
text = render.render_compact(report)
self.assertIn("## Source Errors", text)
+ def test_failed_x_bookmark_workflow_query_emits_no_solid_floor(self):
+ """Regression: generic token overlap must not turn all-zero X noise
+ into findings or quotable comments for a compound workflow query."""
+ report = sample_report()
+ report.topic = (
+ "AI-assisted X bookmark triage, knowledge capture, "
+ "and safe engagement automation"
+ )
+ report.query_plan.raw_topic = report.topic
+ report.clusters[0].score = 0
+ report.ranked_candidates[0].final_score = 0
+ report.ranked_candidates[0].explanation = (
+ "fallback-local-score (entity-miss demotion)"
+ )
+ report.ranked_candidates[0].source_items[0].metadata["top_comments"] = [
+ {
+ "excerpt": "An unrelated but highly voted comment one.",
+ "score": 500,
+ },
+ {
+ "excerpt": "An unrelated but highly voted comment two.",
+ "score": 400,
+ },
+ ]
+
+ text = render.render_compact(report)
+
+ self.assertIn("**Nothing solid this window.**", text)
+ self.assertNotIn("### 1. Grounded result", text)
+ self.assertNotIn("## Top Community Comments", text)
+ self.assertIn("## Stats", text)
+ self.assertIn("All agents reported back!", text)
+
+ def test_positive_cluster_with_only_entity_miss_representatives_is_rejected(self):
+ report = sample_report()
+ report.clusters[0].score = 30
+ report.ranked_candidates[0].final_score = 30
+ report.ranked_candidates[0].explanation = (
+ "fallback-local-score (entity-miss demotion)"
+ )
+
+ text = render.render_compact(report)
+
+ self.assertIn("**Nothing solid this window.**", text)
+ self.assertNotIn("### 1. Grounded result", text)
+
class OutputEnvelopeTests(unittest.TestCase):
"""LAW 6 envelope comments: scope "pass through verbatim" unambiguously.
@@ -1034,6 +1080,30 @@ class TestRenderTopCommentsBlock(unittest.TestCase):
block = text.split("## Top Community Comments", 1)[1]
self.assertIn("TurkiYe", block)
+ def test_excludes_comments_from_entity_miss_candidate_in_mixed_report(self):
+ missed = self._cand(
+ "missed",
+ "reddit",
+ 5000,
+ "viral but unrelated entity-miss comment",
+ )
+ missed.final_score = 0
+ missed.explanation = "fallback-local-score (entity-miss demotion)"
+ report = self._report(
+ [
+ missed,
+ self._cand("good-a", "reddit", 100, "first relevant comment here"),
+ self._cand("good-b", "reddit", 90, "second relevant comment here"),
+ ],
+ representative_ids=["good-a"],
+ )
+
+ block = "\n".join(render._render_top_comments(report))
+
+ self.assertNotIn("viral but unrelated", block)
+ self.assertIn("first relevant comment", block)
+ self.assertIn("second relevant comment", block)
+
def test_block_inside_evidence_envelope(self):
report = self._report(
[self._cand("a", "reddit", 500, "first funny line here"),
diff --git a/tests/test_rerank_v3.py b/tests/test_rerank_v3.py
index 175b5605..6080e10c 100644
--- a/tests/test_rerank_v3.py
+++ b/tests/test_rerank_v3.py
@@ -277,6 +277,89 @@ class EntityGroundingTests(unittest.TestCase):
self.assertNotIn("Primary entity grounding", prompt)
+class FallbackVisibilityTests(unittest.TestCase):
+ """Only low-confidence fallback entity misses with no raw-topic anchor are
+ hidden from synthesized evidence; adjacent and explicitly scoped evidence
+ remains available."""
+
+ topic = (
+ "best durable execution architecture for AI coding agents and "
+ "alternatives to Temporal"
+ )
+
+ def _candidate(
+ self,
+ *,
+ title: str,
+ snippet: str,
+ local_relevance: float,
+ explanation: str,
+ source: str = "youtube",
+ ) -> schema.Candidate:
+ candidate = schema.Candidate(
+ candidate_id=f"{source}-{title[:18]}",
+ item_id="i1",
+ source=source,
+ title=title,
+ url="https://example.com/item",
+ snippet=snippet,
+ subquery_labels=["primary"],
+ native_ranks={f"primary:{source}": 1},
+ local_relevance=local_relevance,
+ freshness=80,
+ engagement=50,
+ source_quality=0.7,
+ rrf_score=0.02,
+ )
+ candidate.explanation = explanation
+ candidate.final_score = 14.0
+ return candidate
+
+ def test_prunes_only_unanchored_low_confidence_fallback_entity_miss(self):
+ starship = self._candidate(
+ title=(
+ "Everyone Mocked the Boy, Until He Awakened a Starship System "
+ "and Built a Powerful Fleet From Scrap!"
+ ),
+ snippet=(
+ "A simulation assessment projected a meteorite shattering the "
+ "ship's hull while classmates laughed."
+ ),
+ local_relevance=0.38,
+ explanation="fallback-local-score (entity-miss demotion)",
+ )
+ adjacent = self._candidate(
+ title="Fable AI coding workflow exhausts weekly API limits",
+ snippet="The system spawns up to 40 subagents simultaneously for execution.",
+ local_relevance=0.31,
+ explanation="fallback-local-score (entity-miss demotion)",
+ source="digg",
+ )
+ scoped_project = self._candidate(
+ title="hatchet-dev/hatchet",
+ snippet="Project repository",
+ local_relevance=0.8,
+ explanation="fallback-local-score (entity-miss demotion)",
+ source="github",
+ )
+ ordinary_fallback = self._candidate(
+ title="Unrelated wording",
+ snippet="No raw topic terms here",
+ local_relevance=0.2,
+ explanation="fallback-local-score",
+ )
+
+ kept = rerank.prune_fallback_entity_misses(
+ [starship, adjacent, scoped_project, ordinary_fallback],
+ topic=self.topic,
+ )
+
+ self.assertNotIn(starship, kept)
+ self.assertIn(adjacent, kept)
+ self.assertIn(scoped_project, kept)
+ self.assertIn(ordinary_fallback, kept)
+
+
class ExpandedHaystackTests(unittest.TestCase):
"""Unit 3: Entity-grounding haystack covers transcript snippets,
transcript highlights, top comments, and comment insights - not