Overview
Context pollution is the #1 production failure mode. Old/failed messages accumulate, causing agents to drift toward “plausible-but-wrong” outputs. The ContextCurator automatically cleans conversation context before each LLM call.Quick Start
Failed Result Handling
Tool calls fail. Those error messages stay in context and confuse the model. The curator handles them:| Strategy | Behavior |
|---|---|
"remove" | Remove failed results entirely (keep last N) |
"deprioritize" | Prefix with [PREVIOUS ERROR - may not be relevant] |
"summarize" | Compress to one-line summary |
What counts as a “failed result”?
The curator detects errors by pattern matching:[ERROR]markersError:prefixes- HTTP 4xx/5xx status codes
timeout,ECONNREFUSED,Permission denied- Stack traces
Relevance Decay
Messages far back in the conversation become less relevant. The curator assigns a weight based on turn distance:Parameters
| Parameter | Default | Description |
|---|---|---|
halfLifeTurns | 10 | Turns until weight halves |
minWeight | 0.1 | Floor weight (below this → consider dropping) |
Clean-Room Mode
Instead of filtering the full conversation, build a purpose-specific context:- System prompt
- Memory context
- Messages containing entities from the current query
- Last N recent messages
Standalone Usage
Events
| Event | Payload |
|---|---|
context.curated | { runId, originalCount, curatedCount, failedRemoved } |