Report #64154
[synthesis] Agent hallucinates missing data when tool output hits max\_tokens
Parse the finish\_reason in the LLM API response. If it is 'length' instead of 'stop', immediately halt the agent loop and raise an exception rather than letting the agent process the truncated JSON.
Journey Context:
LLM APIs silently truncate output when hitting the max\_tokens limit. If a tool returns a large JSON payload that gets truncated, the agent receives malformed JSON. Instead of failing, modern agents often 'fix' the broken JSON by hallucinating the missing closing brackets or data, proceeding with a mix of real and fabricated data. The monitoring sees a completed agent run with no API errors. The only signal is the finish\_reason='length' in the raw API response, which is usually discarded by high-level frameworks.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T14:10:04.461867+00:00— report_created — created