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: preserve qualifying evidence representatives

terry-li-hma6712f3cbf97
diff --git a/skills/last30days/scripts/lib/render.py b/skills/last30days/scripts/lib/render.py
index d9b0a89a..08fb94db 100644
--- a/skills/last30days/scripts/lib/render.py
+++ b/skills/last30days/scripts/lib/render.py
@@ -334,8 +334,9 @@ def _qualifying_representative_ids(
candidate_by_id: dict[str, schema.Candidate],
*,
limit: int | None = None,
+ fallback_limit: int = 1,
) -> list[str]:
- """Keep qualifying MMR representatives, or promote qualifying members."""
+ """Keep qualifying MMR representatives, or promote a conservative fallback."""
representative_ids = [
candidate_id
for candidate_id in cluster.representative_ids
@@ -348,7 +349,7 @@ def _qualifying_representative_ids(
for candidate_id in cluster.candidate_ids
if candidate_id in candidate_by_id
and _best_take_relevance_ok(candidate_by_id[candidate_id])
- ]
+ ][:fallback_limit]
return representative_ids[:limit] if limit is not None else representative_ids
@@ -381,7 +382,6 @@ def _render_ranked_clusters(
representative_ids = _qualifying_representative_ids(
cluster,
candidate_by_id,
- limit=1,
)
for rep_index, candidate_id in enumerate(representative_ids, start=1):
candidate = candidate_by_id.get(candidate_id)
@@ -1365,7 +1365,6 @@ def _render_entity_evidence_block(
representative_ids = _qualifying_representative_ids(
cluster,
candidate_by_id,
- limit=1,
)
for rep_index, candidate_id in enumerate(representative_ids, start=1):
candidate = candidate_by_id.get(candidate_id)
diff --git a/tests/test_render_v3.py b/tests/test_render_v3.py
index f63fd64c..ced532dc 100644
--- a/tests/test_render_v3.py
+++ b/tests/test_render_v3.py
@@ -188,6 +188,27 @@ class RenderV3Tests(unittest.TestCase):
self.assertIn("### 1. Grounded result", text)
self.assertIn("Solid nonrepresentative evidence", text)
+ def test_compact_and_comparison_preserve_all_qualifying_representatives(self):
+ report = sample_report()
+ second_representative = copy.deepcopy(report.ranked_candidates[0])
+ second_representative.candidate_id = "c2"
+ second_representative.title = "Second qualifying representative"
+ second_representative.snippet = "Independent supporting evidence."
+ report.ranked_candidates.append(second_representative)
+ report.clusters[0].candidate_ids.append("c2")
+ report.clusters[0].representative_ids.append("c2")
+
+ renderers = {
+ "compact": render.render_compact,
+ "comparison": lambda value: render.render_comparison_multi(
+ [("Example", value)]
+ ),
+ }
+ for name, renderer in renderers.items():
+ with self.subTest(mode=name):
+ text = renderer(report)
+ self.assertIn("Second qualifying representative", text)
+
def test_all_report_modes_promote_qualifying_nonrepresentative(self):
renderers = {
"comparison": lambda report: render.render_comparison_multi(