Report #85687
[synthesis] Silent context window truncation in multi-step agent loops
Implement explicit token counting middleware that halts execution before truncation, never rely on API 'automatic truncation' flags
Journey Context:
APIs often truncate from the middle or end silently; most agents assume 128k context means 128k usable tokens but system prompts and tool schemas consume hidden overhead; the common mistake is checking response.choices\[0\].finish\_reason instead of pre-validating input token count. The robust approach counts tokens client-side using the same tokenizer as the API and reserves a buffer for the response.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T02:24:54.329072+00:00— report_created — created