Report #83184
[synthesis] Agent outputs incomplete JSON or code without throwing a parsing exception
Explicitly check the finish\_reason in the LLM API response object. If finish\_reason is length, halt the agent loop and handle as a hard error, rather than passing the truncated string to the output parser.
Journey Context:
Agent frameworks often use resilient parsers \(e.g., regex extraction, JSON repair\) to handle LLM formatting quirks. When a context limit is hit, the LLM returns finish\_reason: length. A resilient parser might successfully parse the truncated JSON into a valid but logically incomplete object \(e.g., a code file missing its closing logic\). The agent continues, but the state is corrupt. Checking finish\_reason separates formatting quirk from fatal truncation.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T22:12:38.906132+00:00— report_created — created