Skip to main content

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:

What counts as a “failed result”?

The curator detects errors by pattern matching:
  • [ERROR] markers
  • Error: 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:
Messages below the threshold are either dropped or compressed to one-line summaries. Messages containing entities mentioned in the current query are always preserved.

Parameters

Clean-Room Mode

Instead of filtering the full conversation, build a purpose-specific context:
Clean-room context includes:
  1. System prompt
  2. Memory context
  3. Messages containing entities from the current query
  4. Last N recent messages

Standalone Usage

Events