Skip to content

[BUG]: One malformed judge response makes a trial unscoreable and collapses its whole arm #70

Closed

Description

@genkey6

What happened?

A single unparseable judge response makes a trial unscoreable, and one
unscoreable trial withholds the entire arm's aggregate — even when the rest of
that arm scored cleanly.

judge_behavior_check already handles unparseable output: it retries once with
an explicit machine-readable-output reminder, then salvages complete entries
from a truncated array.

# src/skillevaluator/tier3/harbor/templates/eval.py:3515-3521
attempts = [(content or "", parsed)]
retry_error = None
if score is None:
    # One retry max, with an explicit machine-readable-output reminder.
    retry_content, retry_error = call_public_llm(
        prompt + _BEHAVIOR_RETRY_REMINDER, max_tokens=BEHAVIOR_JUDGE_MAX_TOKENS
    )

judge_accuracy and _judge_goal_accuracy_custom have neither. One malformed
response ends the metric immediately:

# src/skillevaluator/tier3/harbor/templates/eval.py:3318-3323 (judge_accuracy)
content, error = call_public_llm(prompt)
if error:
    return _judge_error(f"LLM judge error: {error}")
parsed = extract_json(content) if content else None
if not isinstance(parsed, dict):
    return _judge_error("Judge response was not a valid JSON object")

Nothing below the judge retries either: _call_anthropic (eval.py:1405-1433) is
raw urllib rather than the Anthropic SDK, and the model-fallback loop in
_call_public_llm_with_provenance fires only on model-access HTTP errors
(_should_try_fallback, eval.py:1138-1145). An HTTP 200 with unparseable content
is never retried anywhere.

_judge_error marks the metric status: "error" (eval.py:1080-1085); main()
then sets evaluation_status: failed and writes the deliberately-incomplete
sentinel (write_reward_outputs(result, 0.0) + SystemExit(1),
eval.py:3811-3824), so the collector — correctly, per the design introduced after
the base-URL judge failures in #55 — refuses to score the trial.

Expected: a recoverable formatting failure is retried the way
judge_behavior_check retries it.

Actual: the metric errors on first attempt, and the consequences cascade.

Observed impact

A 4-case run (--agents claude-code, claude-opus-5 as both agent and judge,
baseline enabled, 8 trials, zero agent runtime failures) lost 2 with-skill
trials:

run-finished: failed - Unscoreable reward in tech-writing-001__Lmi47iy:
  Required judge evaluation failed: accuracy: Judge response was not a valid JSON object
Scored attempt coverage is 2/4
Missing scored attempts for cases: tech-writing-001, tech-writing-003

Both unscoreable trials had valid scores for all five other metrics, and every
metric that differed from baseline favored the with-skill trial:

metric 001 with-skill 001 baseline
security 1.00 1.00
skill_execution 1.00 0.50
skill_efficiency 1.00 0.50
behavior_check 0.50 0.25
goal_accuracy 0.00 0.00
accuracy judge error 0.00

Any coverage shortfall marks the arm's execution failed and the collector
withholds the arm aggregate entirely (with_scores = {},
collector.py:2815-2818). So one malformed judge response collapsed the entire
with-skill column to NO SCORE against a fully scored baseline, even though two
of its four trials scored cleanly (num_trials_with: 2). Eight successful agent
executions produced no comparison. There is no supported rescore path — the
only recourse is a full re-run, agents included.

Why the raw judge output is not attached

It is not retained anywhere. _judge_error keeps only a truncated reason string;
the trial directory holds test-stdout.txt (ERROR: Required LLM judging failed for: accuracy), the reward files, and trial.log. The unparseable text is
discarded at the point of failure, which also means this class of failure cannot
be diagnosed after the fact.

A likely mechanism worth checking

judge_accuracy and _judge_goal_accuracy_custom call at the default
max_tokens=1024 (eval.py:1535, 3318, 3445). judge_behavior_check was raised
to BEHAVIOR_JUDGE_MAX_TOKENS = 4096 with a comment documenting this exact
failure mode:

the old 1024 cap was observed live to truncate behavior_check output to EMPTY
content

(eval.py:3473-3477)

The accuracy prompt also invites prose before the JSON — "For each criterion
write: YES or NO with a brief reason. Then compute score = count(YES) / 5" —
while demanding "Respond with ONLY a JSON object" (eval.py:3302-3306). Prose
plus a 1024-token cap plausibly truncates the JSON, which is precisely what
extract_json would fail on.

I cannot confirm this post hoc, because the response was not retained. Both
observations point the same way.

Reproduction steps

Intermittent by nature. The identical case (tech-writing-001, identical
prompt) with the same provider and judge model scored accuracy: 0.8 cleanly in
a 1-case run ten minutes before the same case's accuracy judge returned non-JSON,
so the trigger is judge output variance rather than dataset content.

  1. skillevaluator create-eval-dataset ./my-skill --full
  2. skillevaluator tier3 evaluate ./my-skill --agents claude-code --env-mode docker --harbor-keep-jobs
  3. If any accuracy judge call returns unparseable content, that trial becomes
    unscoreable and its whole arm reports NO SCORE. Inspect
    _harbor-jobs/<job>/<trial>/verifier/skill_evaluator_reward.json for
    "accuracy": null alongside populated skill_execution / skill_efficiency.

Suggested fix

Primary — retry parity. Extract the call → validate → one retry with a
machine-readable reminder → re-validate loop into a shared helper, parameterized
by a per-judge validator (accuracy: dict plus _valid_accuracy_criteria /
_finite_score; goal: dict plus a bool achieved; behavior:
_behavior_payload_score).

Two things do not generalize and should stay where they are. The salvage pass
(eval.py:3527-3549) is coupled to behavior_check's results-array shape through
_salvage_behavior_results and _behavior_payload_score(..., allow_partial=True).
And provenance differs: _judge_goal_accuracy_custom uses
_call_public_llm_with_provenance and threads provenance into every
_judge_error and into the success payload (eval.py:3445-3468), while
judge_accuracy uses plain call_public_llm — the helper needs to carry
provenance or accept the call function, or goal_accuracy's diagnostics degrade
silently.

Also worth folding in: per-judge max_tokens, raising accuracy and goal to
the 4096 already justified at eval.py:3473-3477; and retaining the unparseable
text on failure so the next report can name the cause.

Reporting, not scoring. The computed metrics already survive in
skill_evaluator_reward.json and trial_failures — the gap is that the rendered
report shows only NO SCORE. Surfacing that per-metric detail in the failure
report would help without making the trial scoreable. I am specifically not
proposing to score partial trials: the sentinel and the coverage gate both exist
to prevent survivorship bias, and scoring only the trials whose judges happened
to succeed would skew arm averages.

I am happy to open a PR for the retry parity and max_tokens parts.

SkillEvaluator version or commit

0.2.0, commit e70f0e3.

Environment

  • Python 3.13 (uv tool install)
  • macOS 26.5.1 (Darwin 25.5.0), arm64
  • Docker via colima; results directory under $HOME
  • Provider: SKILL_EVAL_LLM_PROVIDER=anthropic, agent claude-code, judge and agent both claude-opus-5

Related: #55 — the unscoreable sentinel introduced after it works as designed
here; this issue is about retry parity, not the sentinel.

Before submitting

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions