GroundednessJudge silently scores infra/API errors (negative max_tokens crash) as hard fails

Abierto
#25 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
52/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Tranquilo
Stack tecnológico
python
Área
ai, testing-qa

Línea de trabajo

Empieza en evaluator/judge.py, en GroundednessJudge.judge() y en los bloques de excepción análogos de ExactMatchJudge; después, sigue las llamadas a través de evaluate_domain y TurnScorer. Revisa cómo se representan los errores de los jueces en los metadatos de cada turno y en los agregados del diálogo; estará terminado cuando los fallos de la API se puedan distinguir de las puntuaciones reales y la segunda explicación del error incluya el texto de la excepción.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Describe the bug

GroundednessJudge.judge() (and ExactMatchJudge's equivalent block) in evaluator/judge.py wrap the judge LLM call in a bare except Exception as e: return JudgeOutput(score=0.0, explanation=f"Judge Error {e}.") (confirmed on main at lines 95-96 and 307-308). Any API-level failure to invoke the judge — not just a genuine "this answer is ungrounded" verdict — is silently converted into a hard score=0.0.

Concretely: GroundednessJudge.judge() concatenates the last N_TOOL_CALLS_PER_TURN (20) tool responses plus the full predicted answer and sends that to the judge model with no truncation/length check against the judge model's context window. When the predicted-answer/tool-response transcript is large, the underlying langchain_openai client auto-computes max_tokens = context_window - prompt_tokens, which can go deeply negative, and the provider returns a 400. That exception is caught and scored as a hard groundedness FAIL, indistinguishable from an actual ungrounded answer.

We hit this while scoring a 300-task capability_4 (multiturn) run: 24/300 dialogues (8%) came back with groundedness_score: 0.0 and a score_explanation.groundedness string starting with "Judge Error Error code: 400 - {'error': {'message': 'max_tokens must be at least 1, got -36646.', ...}}." — i.e. the judge never actually rendered a groundedness verdict for these, but they count as full dialogue failures in the final scored output.

Separately, the second occurrence of this pattern (around line 307-308) has its own bug: explanation="Judge Error {e}." is missing the f prefix, so {e} is a literal string rather than the actual exception — that occurrence never surfaces the real error message.

To Reproduce

  1. Run a capability_multiturn (capability_4) evaluation where at least one predicted answer + its last-20-tool-responses is large enough to overflow the groundedness judge model's context window (happens naturally on agents that produce very long tool-call transcripts, e.g. a step-cap/runaway condition on the agent side).
  2. Score it with the standard scoring pipeline (evaluate_domain → TurnScorer → GroundednessJudge.judge()).
  3. Inspect the output dialogues for details.per_turn[*].metadata.score_explanation.groundedness containing "Judge Error".

Expected behavior

An API/infra-level failure to invoke the judge should not be indistinguishable from a genuine "ungrounded" verdict. Either:

  • surface it as an inconclusive/skipped judge result (excluded from the dialogue aggregate), or
  • defensively bound the judge's input (truncate the concatenated tool-responses/answer) before invoking, so this class of error doesn't occur in the first place, with a bounded retry as a fallback.

Also, fix the missing f prefix on the second except block's explanation="Judge Error {e}." so the real exception text is actually captured.

Screenshots / logs

Judge Error Error code: 400 - {'error': {'message': 'max_tokens must be at least 1, got -36646.', 'type': 'BadRequestError', 'param': None, 'code': 400}}.
Judge Error Error code: 400 - {'error': {'message': 'max_tokens must be at least 1, got -44982.', 'type': 'BadRequestError', 'param': None, 'code': 400}}.
Judge Error Error code: 400 - {'error': {'message': 'max_tokens must be at least 1, got -14856.', 'type': 'BadRequestError', 'param': None, 'code': 400}}.

Additional context

Found via cuga-project/cuga-eval, which vendors a copy of this evaluator package under benchmarks/m3/evaluator/ (kept in sync with this repo per that project's own sync tooling); companion issue filed there: cuga-project/cuga-eval#143. The bare-except pattern is present in both GroundednessJudge.judge() and the analogous block later in the same file (~line 307) — worth fixing both together.

Lenguaje dominante
Python
Estrellas
79
Forks
23
Merge medio
2 d 7 h
PR fusionados (30 d)
3

Preparar el entorno

  • Incluye un Dockerfile o un archivo de Docker Compose
  • Sin plantilla de pull request
  • Sin guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de IBM/vakra

Todos los issues de IBM/vakra

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.