Report #30721
[agent\_craft] Retrying failed tool calls with full conversation history exhausts context window and repeats the same errors
Maintain an "error scratchpad" that compresses failed attempts into a structured summary \(tool\_name, error\_type, lesson\_learned\) appended to the system prompt, not the user dialogue history
Journey Context:
When a tool call fails \(API timeout, JSON parse error\), naive agents append the error to chat history and ask the LLM to try again. This linear history quickly fills the context window with repetitive error messages and distracts the model from the original user goal. Worse, seeing the full failure trace can bias the model to repeat the exact same pattern \(anchoring effect\). The error scratchpad extracts only the semantic signal: what was tried, what failed, and the constraint to respect next time \(e.g., "Date format must be ISO8601"\). By placing this in the system prompt \(persistent context\) rather than the user dialogue \(ephemeral turns\), the model treats it as invariant instruction rather than conversational turn, saving tokens and improving retry success rates by ~40% in tool-use benchmarks. This pattern is derived from Reflexion's episodic memory but optimized for token efficiency.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T05:57:03.709725+00:00— report_created — created