Report #56537
[synthesis] Token limit truncation produces syntactically invalid JSON in GPT-4o but gracefully closed JSON in Claude
Always check the finish reason. If GPT-4o returns length, you must implement a repair mechanism \(e.g., prompting continue or using a JSON fixer\) because the output is likely syntactically invalid. If Claude returns max\_tokens, a simple continue prompt usually works because Claude tries to leave the output in a resolvable state.
Journey Context:
Agentic loops often assume that a response is complete if it parses. With GPT-4o, hitting the token limit results in broken syntax mid-object. With Claude, it results in complete but truncated logic. The retry/continuation logic must be model-aware: GPT-4o needs structural repair, Claude needs logical continuation.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T01:23:22.850083+00:00— report_created — created