Report #84681
[synthesis] GPT-4o loses JSON output formatting when context window fills up
Bookend the system prompt with the formatting instruction, and add a fallback regex extractor for the expected JSON structure rather than relying solely on \`response\_format: \{ type: "json\_object" \}\`.
Journey Context:
When the conversation history grows long, GPT-4o begins to 'drift' and may ignore the \`json\_object\` response format, wrapping output in markdown or adding conversational text. Claude 3.5 Sonnet is more resilient to formatting drift but might truncate the JSON. Relying purely on the API-level JSON enforcement fails when models hallucinate outside the schema. A regex fallback \(e.g., extracting content between \`\{\` and \`\}\`\) rescues the run from crashing.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T00:43:44.368142+00:00— report_created — created