Vol. VI · Context & Memory · VI.2
Compaction and Errors
Factor 9: compact errors into the window. The general rule: every observation should be the smallest string that still lets the model choose the next correct action.
5 min read
Doctrine
- Tool failures become short, structured error objects, not 200-line traces.
- Success payloads get schema-trimmed. Do not return the entire API envelope.
- When the window is full, summarize with an LLM call that is itself evaluated for loss.
Errors are context too
A model that sees 'PermissionError: /etc/passwd' can recover. A model that sees nothing, or a novel, cannot. Compaction is not deletion; it is information-preserving compression with an audit trail in traces (Langfuse).
Anti-patterns
- Retrying the same failed call with the same giant error appended each time.
- Silent truncation of the goal while keeping HTML dumps.