Skip to content

Tolerate trailing data in LLM JSON responses - #34

Merged
sadacca merged 2 commits into
mainfrom
claude/eval-chain-sensitivity-mu4kop
Jun 24, 2026
Merged

Tolerate trailing data in LLM JSON responses#34
sadacca merged 2 commits into
mainfrom
claude/eval-chain-sensitivity-mu4kop

Conversation

@sadacca

@sadacca sadacca commented Jun 24, 2026

Copy link
Copy Markdown
Owner

Pass 4 (and any call) failed with "Extra data: line N column 1" when a model returned a complete JSON value followed by extra content — a second object, a trailing note, or a stray fence — which json.loads rejects. Gemini's judge calls request responseMimeType=application/json, so the response had no fences and went straight to json.loads with no recovery path. At temperature 0 the bad output is deterministic, so all retries reproduced it and the article was dropped.

Add a shared _parse_json_response() used by both the Gemini and OpenAI-compatible callers: strip code fences, skip leading prose to the first '{'/'[', and use json.JSONDecoder().raw_decode() so bytes after the first complete value are ignored. Genuinely malformed output still raises JSONDecodeError so the existing retry loop is unaffected.

Claude-Session: https://claude.ai/code/session_01669jmknuhhZY3vBqwpDWvF

claude added 2 commits June 24, 2026 11:25
Pass 4 (and any call) failed with "Extra data: line N column 1" when a model
returned a complete JSON value followed by extra content — a second object, a
trailing note, or a stray fence — which json.loads rejects. Gemini's judge
calls request responseMimeType=application/json, so the response had no fences
and went straight to json.loads with no recovery path. At temperature 0 the
bad output is deterministic, so all retries reproduced it and the article was
dropped.

Add a shared _parse_json_response() used by both the Gemini and
OpenAI-compatible callers: strip code fences, skip leading prose to the first
'{'/'[', and use json.JSONDecoder().raw_decode() so bytes after the first
complete value are ignored. Genuinely malformed output still raises
JSONDecodeError so the existing retry loop is unaffected.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01669jmknuhhZY3vBqwpDWvF
Pass 0 paragraph triage decided category relevance from only the first 120
chars of each paragraph, so bias signal past the opening sentence was invisible
and triage systematically under-selected. Double the preview window to 240
chars to give the triage model more of each paragraph to judge against.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01669jmknuhhZY3vBqwpDWvF
@sadacca
sadacca merged commit 8be7d5b into main Jun 24, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants