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(evaluator): warn when a stale-model judgment cache is discarded without a key

Ilia Alshanetskyfaf8782dd437
diff --git a/skills/last30days/scripts/evaluate_search_quality.py b/skills/last30days/scripts/evaluate_search_quality.py
index 5caa9540..f40bc2d7 100644
--- a/skills/last30days/scripts/evaluate_search_quality.py
+++ b/skills/last30days/scripts/evaluate_search_quality.py
@@ -282,6 +282,7 @@ def get_judgments(
) -> dict[str, int]:
cache_file = output_dir / "judgments" / f"{slug}.json"
cache_file.parent.mkdir(parents=True, exist_ok=True)
+ stale_cache = False
if cache_file.exists():
payload = json.loads(cache_file.read_text())
# The cache key is the topic slug alone, but judgments are model-
@@ -291,7 +292,17 @@ def get_judgments(
# before judge_model was recorded miss here and get refreshed once.
if payload.get("judge_model") == judge_model:
return {row["id"]: int(row["grade"]) for row in payload.get("judgments") or []}
+ stale_cache = True
if not gemini_api_key or not items:
+ if stale_cache:
+ # Discarded a different-model cache but can't re-judge. Returning {}
+ # scores every item as ungraded (zero precision@k / nDCG); say so
+ # rather than letting the run report silently wrong numbers.
+ sys.stderr.write(
+ f"[Eval] Cached judgments for {slug!r} were graded by a different "
+ f"judge model and no Gemini API key is set to re-judge; returning "
+ f"no grades (metrics for this topic will be zero).\n"
+ )
return {}
payload = call_gemini_judge(gemini_api_key, judge_model, build_judge_prompt(topic, query_type, items))
payload["judge_model"] = judge_model
diff --git a/tests/test_evaluator_v3.py b/tests/test_evaluator_v3.py
index a882f12e..25fd62f1 100644
--- a/tests/test_evaluator_v3.py
+++ b/tests/test_evaluator_v3.py
@@ -1,3 +1,5 @@
+import contextlib
+import io
import json
import os
import tempfile
@@ -162,17 +164,21 @@ class EvaluatorV3Tests(unittest.TestCase):
)
# Same slug, different model, no API key to re-judge: the stale
# grades must NOT come back — an empty result signals "re-judge
- # needed" rather than silently wrong numbers.
- result = evaluator.get_judgments(
- output_dir=output_dir,
- slug="topic",
- topic="test topic",
- query_type="general",
- items=[{"key": "a"}],
- judge_model="gemini-2.5-pro",
- gemini_api_key=None,
- )
+ # needed" rather than silently wrong numbers, and the discard is
+ # announced on stderr instead of failing silently.
+ stderr = io.StringIO()
+ with contextlib.redirect_stderr(stderr):
+ result = evaluator.get_judgments(
+ output_dir=output_dir,
+ slug="topic",
+ topic="test topic",
+ query_type="general",
+ items=[{"key": "a"}],
+ judge_model="gemini-2.5-pro",
+ gemini_api_key=None,
+ )
self.assertEqual({}, result)
+ self.assertIn("different", stderr.getvalue())
def test_create_eval_env_and_run_last30days(self):
credential_env = {