Fix stack 04: consistent finish_reason for structured/empty/truncated results#28
Merged
Merged
Conversation
12424d5 to
1168cb4
Compare
f47fda4 to
f088d0f
Compare
1168cb4 to
cb1c5be
Compare
b7e38ae to
cb1c5be
Compare
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.
Stacked review-fix PR 4/N (base:
review-fixes/03-events).The same vendor condition produced opposite verdicts across adapters (REVIEW.md §1.1, §1.2, §1.3). Unified:
output_schema→failedeverywhere. Claude previously fell through tofinish_reason="done"withparsed_output=None, reporting a schema failure as success. Shared message via_common.structured_output_unsatisfied_error.failedeverywhere (no output AND no tool calls AND no structured output), via_common.empty_completion_error. Codex previously failed on any empty output even after real tool work; now only when nothing usable came back. Claude/Antigravity previously succeeded on empty; now fail.MAX_TOKENS→max_tokens,SAFETY/RECITATION→failed) instead of reporting truncated/blocked responses as success. (ASSUMES VENDOR BEHAVIOR: probesfinish_reason/stop_reasonon the response and candidates.)structured_output()only when a schema was requested, instead of unconditionally fabricatingparsed_output(or crashing if the SDK errors when unconfigured).Tests for each behavior across all three adapters. Full suite 158 passed / 12 skipped; ruff + mypy strict clean.
Re-review amendment. The shared structured-output failure message now claims exactly what is checked — JSON-parseability, not schema conformance (schema validation stays with the vendor SDK and the caller).
Also: added a test pinning that a SAFETY (or any unrecognized) Antigravity stop reason surfaces as
finish_reason="failed"with the reason in the error, never as silent success — the unknown-reason branch was previously untested.Round 2 (re-review follow-up)
inProgressstatus — or any future unknown status — now fail closed asfinish_reason="failed"with a surfaced error, instead of reading as success with partial output. Tests added for both cases.