Repository navigation
fix(eval): read past thinking blocks in the Claude judge response - #3885
Merged
Merged
Conversation
The judge's default model (claude-opus-5) answers with [thinking, text], so every extraction that indexed content[0] hit a ThinkingBlock and raised AttributeError on the judge's first reply. Select the first text-typed block instead, and raise naming the model and the block types received when a response carries no text at all — an empty reply would parse as a failed case and quietly lower the score. Also fixes the same indexing in the PDF fixture generator, which reads the raw block list returned by get_completion_with_usage. Closes #3884
4 tasks
5 of 11 tasks
itomek
marked this pull request as ready for review
September 15, 2026 14:29
4 tasks done
4 of 5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Every eval that judged through the Python Claude client died on the judge's first reply with
AttributeError: 'ThinkingBlock' object has no attribute 'text'— the default judge model answers with a thinking block first, and the client always read block zero. The judge now reads the first text block, so it works against its own default model; a response with no text block at all raises an error naming the model and the block types instead of degrading to an empty reply, which would have parsed as a failed case and quietly lowered the score.Closes #3884
Test plan
python -m pytest tests/unit/eval/ -qpasses (530 tests)python util/lint.py --allpassesDEFAULT_CLAUDE_MODELwithout anAttributeError— e.g.gaia eval sessionor the email quality judges. This needs a live API call, so it was not run here.🔍 Technical details
Root cause.
ClaudeClientunpacked replies asmessage.content[0].textin four places (src/gaia/eval/claude.py— the twoanalyze_filebranches and the twoanalyze_file_with_usagebranches).claude-opus-5(DEFAULT_CLAUDE_MODEL) returns[thinking, text], so block zero is aThinkingBlockwith no.text. The HTTP call succeeded; only the unpacking failed, which is why it surfaced as a client-sideAttributeError.Change. New module-level
first_text_block(blocks, model)inclaude.pyreturns the first block carrying text and otherwise raises aValueErrornaming the model and the block types received.ClaudeClient._extract_text(message)wraps it, and all four sites call that. Selection is duck-typed on the presence of.textrather thantype == "text", matching the existing pattern inaction_item_quality.py/draft_quality.py/briefing_quality.pyand keeping the SDK's non-text block types (thinking, redacted_thinking, tool_use) out.pdf_document_generator.pyhad the same indexing bug on the raw block list returned byget_completion_with_usage(both the generate and the extend path), so it uses the same helper. The three judge factories andsession_eval._as_textalready filtered onhasattr(block, "text")and were unaffected.Tests.
tests/unit/eval/test_claude_judge.pyaddsTestFirstTextBlock(skips a leading thinking block; returns the first of several text blocks; raises naming model + block types; raises on empty content) andTestExtractionPathsWithThinkingBlock(all four extraction paths against a[thinking, text]response, plus the no-text-block raise).tests/unit/eval/test_pdf_document_generator.pypins the generator path. No live API call in any of them.One discrepancy with the issue. The issue lists
gaia eval agent --category tool_selectionas an acceptance criterion, but that runner scores via theclaude -pCLI subprocess (src/gaia/eval/runner.py), notClaudeClient— so this fix does not touch that path, and neither does it fix #3341. The in-process judges (session_eval, the email quality judges) and the document generators are the callers this actually unblocks. Worth confirming before closing #3884 on the strength of criterion 4.Not validated here: the full
tests/unit/run had 6 pre-existing environment failures unrelated to this change (sherpa_onnxnot installed;pipabsent inside the uv-created venv, whichtest_hub_installer.pyshells out to).