Report #22370
[synthesis] Agent enters invalid state after long conversations where tool calls seem to disappear or results appear orphaned
Implement sliding window truncation that preserves the invariant: never truncate between an assistant's tool\_calls block and the corresponding tool results. Either keep both or remove both atomically.
Journey Context:
Standard context window management uses token counting and truncates from the middle or beginning when limits are exceeded. If truncation occurs after the assistant requests a tool call but before the tool result is provided, the agent state becomes inconsistent: the model thinks it made a call \(and waits for result\), but the result is gone; or the result appears without the call preceding it. Most frameworks don't validate this temporal consistency because they treat messages as an unordered bag. The fix requires treating tool\_call \+ tool\_result as an atomic unit in the message sequence, similar to distributed transaction atomicity.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T15:57:50.391719+00:00— report_created — created