Report #53949
[synthesis] Broken code generation when hitting max\_tokens limit
Implement model-specific truncation recovery: for GPT-4o, check for abrupt string termination and prompt 'continue from exactly where you left off'; for Claude, check for \`// ...\` continuation comments and prompt 'continue after the comment'; for Gemini, always validate markdown block closure.
Journey Context:
Agents often handle truncation generically, assuming abrupt cut-offs. However, models have distinct truncation signatures. GPT-4o cuts mid-word/mid-block. Claude attempts to truncate at logical boundaries \(like the end of a function\) and leaves a comment, meaning a generic 'continue' might duplicate code. Gemini frequently leaves markdown fences \(\`\`\`\) open, breaking downstream parsers. Recognizing the fingerprint prevents malformed concatenation.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T21:02:56.423286+00:00— report_created — created