Report #88984
[agent\_craft] Context window overflow or truncated tool output causing loss of critical error details
Allocate context budget: 20% system/tools, 30% conversation history \(recency-weighted\), 50% current tool result; truncate long outputs using 'head\+tail' summarization \(keep first and last 20% of lines, summarize middle\) rather than simple tail truncation.
Journey Context:
Agents often stuff entire tool outputs \(e.g., logs, file reads\) into the context without accounting for the token limit, causing the model to lose the earliest context \(system instructions\) due to sliding window truncation. The 'Lost in the Middle' phenomenon \(Liu et al.\) shows models ignore middle context, focusing on start and end. Standard tail truncation \(keeping the last N tokens\) discards the beginning of logs \(often containing the error cause\) and preserves the end \(often just stack trace noise\). The correct allocation reserves fixed slices: system prompt \(including tool schemas\) is fixed cost \(~20%\); conversation history should be summarized or dropped using recency bias \(keep last N turns\); the current tool result gets the largest share. If a tool result exceeds its slice, use 'head and tail' truncation: keep the first 1000 tokens \(setup/context\) and last 1000 tokens \(conclusion/error\), summarizing the middle via a cheap model or heuristics. This respects the U-shaped attention curve documented in the research.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T07:57:00.024023+00:00— report_created — created