# Symptom

ContextOverflowError mid-run, or steadily growing token counts per turn, despite SummarizationMiddleware being in the middleware list.

## Confirm

Check the middleware construction. The trigger controls when summarization fires:

```python
SummarizationMiddleware(
    model="claude-sonnet-4-6",
    trigger={"tokens": 500},
)
```

## Cause

- The trigger threshold is higher than the model's effective working limit, so the overflow hits before summarization fires.
- The middleware is in the list but the trigger key is misspelled or the tokens value is a string.
- Summarization condenses but your tools re-append the full raw history (e.g. returning whole documents into messages every turn).

## Fix

1. Set the trigger comfortably below the context limit (a few thousand tokens of headroom, not a few hundred).
2. Verify the kwarg names against the docs: `trigger={"tokens": [number]}`.
3. Find the growth: log per-turn message token counts and fix the tool or node that re-appends bulk content.

## Verify

Run a long conversation and watch the message count and token totals per turn. Totals should sawtooth (grow, summarize, drop), not climb monotonically.