Skip to content

Commit 5a518de

Browse files
authored
agent: tests — cover per-tool-model rollups and error-tool-call grounding (#102)
Addresses both CodeRabbit nitpicks on PR #100 (additive changes to the new test file only): - test_score_run_produces_per_tool_model_rollups: two competitors, one with an explicit `id:provider/model` tool_model_key, asserting specific by_tool_model_key totals/scored/pending counts in the returned rollups and the persisted scoring-rollups.json. Adapted from CodeRabbit's template: the real rollup key is `by_tool_model_key`, not `by_tool_model`. - test_score_run_does_not_count_error_tool_calls_as_grounding_evidence: a transcript whose only tool call has is_error: True does not set grounding_evidence_present, in the scoring record or the queue entry. Refs #63.
1 parent 53749fc commit 5a518de

1 file changed

Lines changed: 69 additions & 0 deletions

File tree

tests/benchmarks/test_scoring.py

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,29 @@ def test_score_run_detects_grounding_evidence_from_tool_calls(tmp_path: Path) ->
230230
assert _read_queue(run_dir)["cells"][0]["grounding_evidence_present"] is True
231231

232232

233+
def test_score_run_does_not_count_error_tool_calls_as_grounding_evidence(
234+
tmp_path: Path,
235+
) -> None:
236+
# Companion to the happy-path case above (CodeRabbit review on PR #100):
237+
# a recorded tool call that errored is not grounding evidence -- only a
238+
# successful call with a non-empty result payload counts
239+
# (benchmarks.scoring._has_grounding_evidence).
240+
scoring = _scoring_record(competitor_id="tool-a", corpus_id="SYN-EX-001")
241+
transcript = _transcript_record(
242+
competitor_id="tool-a",
243+
corpus_id="SYN-EX-001",
244+
answer="Ungrounded candidate answer.",
245+
tool_calls=[{"tool": "search_docs", "arguments": {}, "result": None, "is_error": True}],
246+
)
247+
run_dir = _build_run_dir(tmp_path, [(scoring, transcript)])
248+
249+
_score(run_dir)
250+
251+
updated = _read_scoring(run_dir, "tool-a", "SYN-EX-001")
252+
assert updated["grounding_evidence_present"] is False
253+
assert _read_queue(run_dir)["cells"][0]["grounding_evidence_present"] is False
254+
255+
233256
# --- Per-category rollups + denominator invariance ----------------------------
234257

235258

@@ -279,6 +302,52 @@ def test_score_run_produces_per_category_rollups(tmp_path: Path) -> None:
279302
assert on_disk == rollups
280303

281304

305+
def test_score_run_produces_per_tool_model_rollups(tmp_path: Path) -> None:
306+
# Two competitors so the by_tool_model_key breakdown is meaningfully
307+
# exercised (CodeRabbit review on PR #100). tool-b carries an explicit
308+
# tool_model_key (the runner's `id:provider/model` format) to verify
309+
# rollups key on tool_model_key, not competitor_id.
310+
cells = [
311+
(
312+
_scoring_record(competitor_id="tool-a", corpus_id="SYN-EX-001"),
313+
_transcript_record(competitor_id="tool-a", corpus_id="SYN-EX-001", answer=""),
314+
),
315+
(
316+
_scoring_record(
317+
competitor_id="tool-b",
318+
corpus_id="SYN-EX-001",
319+
tool_model_key="tool-b:openai/fake-model",
320+
),
321+
_transcript_record(competitor_id="tool-b", corpus_id="SYN-EX-001", answer=""),
322+
),
323+
(
324+
_scoring_record(
325+
competitor_id="tool-b",
326+
corpus_id="SYN-EX-002",
327+
tool_model_key="tool-b:openai/fake-model",
328+
),
329+
_transcript_record(
330+
competitor_id="tool-b", corpus_id="SYN-EX-002", answer="pending answer"
331+
),
332+
),
333+
]
334+
run_dir = _build_run_dir(tmp_path, cells)
335+
336+
result = _score(run_dir)
337+
by_tool_model = result["rollups"]["by_tool_model_key"]
338+
339+
assert set(by_tool_model) == {"tool-a", "tool-b:openai/fake-model"}
340+
assert by_tool_model["tool-a"]["total_cells"] == 1
341+
assert by_tool_model["tool-a"]["scored_cells"] == 1
342+
assert by_tool_model["tool-a"]["pending_manual_scoring_cells"] == 0
343+
assert by_tool_model["tool-b:openai/fake-model"]["total_cells"] == 2
344+
assert by_tool_model["tool-b:openai/fake-model"]["scored_cells"] == 1
345+
assert by_tool_model["tool-b:openai/fake-model"]["pending_manual_scoring_cells"] == 1
346+
347+
on_disk = json.loads((run_dir / "scoring-rollups.json").read_text(encoding="utf-8"))
348+
assert on_disk["by_tool_model_key"] == by_tool_model
349+
350+
282351
def test_score_run_denominator_includes_every_scoring_file(tmp_path: Path) -> None:
283352
cells = [
284353
(

0 commit comments

Comments
 (0)