From 92ca29953c83870588fae060af82e67fa6e00a6c Mon Sep 17 00:00:00 2001 From: kenobijon Date: Mon, 9 Nov 2026 00:12:02 -0800 Subject: [PATCH 1/2] Score a task limit reached mid tool loop as not attempted An agent that exhausts a task's own message, token or turn limit while still calling tools never answered. Inspect ends the sample on the tool-call output, the completion gate leaves it unscored as an unknown completion status, and the host treated it as a grader failure that stops the whole competition run. Settle it as a not-attempted zero instead. Deadlines and operator stops keep their existing handling. Co-Authored-By: Claude Opus 5.5 --- .../yugos/src/yugos/inspect_engine/measure.py | 16 +++++++++++--- packages/yugos/tests/test_inspect_measure.py | 22 ++++++++++++++++++- 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/packages/yugos/src/yugos/inspect_engine/measure.py b/packages/yugos/src/yugos/inspect_engine/measure.py index 0ce2519..d5325ff 100644 --- a/packages/yugos/src/yugos/inspect_engine/measure.py +++ b/packages/yugos/src/yugos/inspect_engine/measure.py @@ -26,6 +26,8 @@ # Limits that are Yugos deadlines rather than task rules; hitting one is a non-answer. _DEADLINE_LIMITS = frozenset({"time", "working", "cost"}) +# Task rules an agent can exhaust itself; stopped mid tool loop by one, it never answered. +_TASK_LIMITS = frozenset({"message", "token", "turn"}) # Text values Inspect's `value_to_float` converts; any other text is a malformed score. _SENTINELS = frozenset({CORRECT, INCORRECT, PARTIAL, NOANSWER}) _BOOLEAN_TEXT = frozenset({"yes", "no", "true", "false"}) @@ -118,12 +120,13 @@ def _finite(text: str) -> bool: def _unscored_grade( - score: Score, grader: str, *, truncated: bool, router_failed: bool + score: Score, grader: str, *, truncated: bool, unfinished: bool, router_failed: bool ) -> GradingResult | None: """The Yugos grade for a sample the scorer left unscored, as legacy grading gates it. - A router non-answer decides first: truncation is a settled zero and a - router failure or deadline has no grade. Otherwise the grader could not + A router non-answer decides first: truncation is a settled zero, a task limit + reached mid tool loop is not attempted, and a router failure or deadline has + no grade. Otherwise the grader could not establish a grade (invalid reference, grader error, unusable judgment, unknown completion status), which needs review and leaves the category incomplete. @@ -135,6 +138,10 @@ def _unscored_grade( return GradingResult( score=0.0, grader=grader, code=GradeCode.TRUNCATED, status="skipped", details=details ) + if unfinished: + return GradingResult( + score=0.0, grader=grader, code=GradeCode.NOT_ATTEMPTED, details=details + ) if router_failed: return None return GradingResult( @@ -224,6 +231,9 @@ def measure_log( score, grader, truncated=finish == "length", + unfinished=finish == "tool_calls" + and sample.limit is not None + and sample.limit.type in _TASK_LIMITS, router_failed=deadline, ) value = 0.0 diff --git a/packages/yugos/tests/test_inspect_measure.py b/packages/yugos/tests/test_inspect_measure.py index d26f919..c361ee3 100644 --- a/packages/yugos/tests/test_inspect_measure.py +++ b/packages/yugos/tests/test_inspect_measure.py @@ -5,7 +5,7 @@ pytest.importorskip("inspect_ai") -from inspect_ai.log import read_eval_log # noqa: E402 +from inspect_ai.log import EvalSampleLimit, read_eval_log # noqa: E402 from inspect_ai.scorer import Score # noqa: E402 from inspect_fakes import ScriptedRouter, exact_question, pack_task, reply, run # noqa: E402 @@ -297,6 +297,26 @@ def test_an_unscored_truncated_answer_is_the_routers_settled_zero(tmp_path): assert chat.execution_complete and chat.grades == {"q": Decimal(0)} +@pytest.mark.parametrize( + "limit,code,status", + [("message", "not_attempted", "graded"), ("operator", "needs_review", "unavailable")], +) +def test_a_task_limit_mid_tool_loop_is_not_attempted(tmp_path, limit, code, status): + # Catches an agent that spends its own message budget on tool calls voiding the run. + question = exact_question("q", "Paris") + router = ScriptedRouter({question.prompt: reply("", finish_reason="tool_calls")}) + log = rescored( + run(pack_task([question], name="pack"), router, tmp_path), + Score.unscored(reason="scoring_failed"), + ) + reached = EvalSampleLimit(type=limit, limit=20) + log = log.model_copy( + update={"samples": [s.model_copy(update={"limit": reached}) for s in log.samples]} + ) + [row] = measure_log(log, router.receipts.receipts()) + assert (row.grade.code, row.grade.status, row.grade.score) == (code, status, 0.0) + + @pytest.mark.parametrize( "score,key,match", [ From cf9cd21996b7570febabde4dd57e398707284778 Mon Sep 17 00:00:00 2001 From: kenobijon Date: Mon, 9 Nov 2026 00:45:23 -0800 Subject: [PATCH 2/2] Grade a task limit reached mid tool loop as incorrect Both codes are graded zeros; incorrect with an explicit cause matches the host's other self-exhaustion outcome (escrow_exhausted). Co-Authored-By: Claude Opus 5.5 --- packages/yugos/src/yugos/inspect_engine/measure.py | 7 +++++-- packages/yugos/tests/test_inspect_measure.py | 4 ++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/yugos/src/yugos/inspect_engine/measure.py b/packages/yugos/src/yugos/inspect_engine/measure.py index d5325ff..d8fa493 100644 --- a/packages/yugos/src/yugos/inspect_engine/measure.py +++ b/packages/yugos/src/yugos/inspect_engine/measure.py @@ -125,7 +125,7 @@ def _unscored_grade( """The Yugos grade for a sample the scorer left unscored, as legacy grading gates it. A router non-answer decides first: truncation is a settled zero, a task limit - reached mid tool loop is not attempted, and a router failure or deadline has + reached mid tool loop is incorrect, and a router failure or deadline has no grade. Otherwise the grader could not establish a grade (invalid reference, grader error, unusable judgment, unknown completion status), which needs review and leaves the category @@ -140,7 +140,10 @@ def _unscored_grade( ) if unfinished: return GradingResult( - score=0.0, grader=grader, code=GradeCode.NOT_ATTEMPTED, details=details + score=0.0, + grader=grader, + code=GradeCode.INCORRECT, + details={**details, "cause": "task_limit_mid_tool_loop"}, ) if router_failed: return None diff --git a/packages/yugos/tests/test_inspect_measure.py b/packages/yugos/tests/test_inspect_measure.py index c361ee3..1b7c006 100644 --- a/packages/yugos/tests/test_inspect_measure.py +++ b/packages/yugos/tests/test_inspect_measure.py @@ -299,9 +299,9 @@ def test_an_unscored_truncated_answer_is_the_routers_settled_zero(tmp_path): @pytest.mark.parametrize( "limit,code,status", - [("message", "not_attempted", "graded"), ("operator", "needs_review", "unavailable")], + [("message", "incorrect", "graded"), ("operator", "needs_review", "unavailable")], ) -def test_a_task_limit_mid_tool_loop_is_not_attempted(tmp_path, limit, code, status): +def test_a_task_limit_mid_tool_loop_is_incorrect(tmp_path, limit, code, status): # Catches an agent that spends its own message budget on tool calls voiding the run. question = exact_question("q", "Paris") router = ScriptedRouter({question.prompt: reply("", finish_reason="tool_calls")})