**TL;DR:** The input is bigger than the model's context window. This error is not retryable; retrying the same oversized input fails the same way every time. Check for accidental duplication: the same big document appended every turn is the usual culprit in agent loops. Log message token counts per turn until you find the growth.

## The error

```text
langchain_core.exceptions.ContextOverflowError
```

## The fix

1. Summarize the conversation when it gets long. In create_agent, add SummarizationMiddleware with a token trigger so history condenses automatically.

2. Trim messages explicitly with `trim_messages` from langchain.messages / langchain-core before the call.

3. Check for accidental duplication: the same big document appended every turn is the usual culprit in agent loops. Log message token counts per turn until you find the growth.

4. Switch to a model with a larger window if the input is legitimately large.

## When to use this

- You are seeing this exact error message; match the block above, not just part of it.
- The failing call matches the scenario in the title: ContextOverflowError.
- You want the fastest verified fix before digging through logs.

## When not to use this

- Your error text differs from the block above; close cousins often have different causes.
- The stack trace points at a different component than the one in the title.
- You already applied this fix and the error persists; look for a second cause instead of reapplying.

## Compatibility

- Not pinned to a specific version; follows current ContextOverflowError behavior.