## TL;DR

The export is bigger than the agent's context window, so loading it whole overflows. Process the file in chunks outside the context (streaming reads), keep only summaries and aggregates in context, and write details to files the agent can reference. The context window is for reasoning, not storage.

## Error

```text
Context overflow: input exceeded the model's context limit while reading the export file.
```

## Steps

1. Stop loading the file into context. Read it with streaming code instead. Expected: the file never enters the context whole.
2. Process chunk by chunk: for dedupe, emit candidate pairs per chunk to a file. Expected: bounded context per chunk.
3. Keep running aggregates in context (counts, top issues), not raw rows. Expected: the agent reasons over summaries.
4. Write chunk outputs to files and have the agent read them selectively. Expected: details available on demand.
5. For very large files, do the heavy work in code (scripts, SQL) and use the agent for decisions on the results. Expected: the right tool for each job.

## When to use

- Exports overflow the agent's context.
- An agent tries to read a whole CSV into context.
- "File too large" from the model, not the parser.

## When not to use

- CSV parse errors (different fix).
- Small files (load directly, simpler).

## Tool compatibility

- Streaming file processing in code.
- Agent context management.

## Variant phrasings

### context overflow on export

Chunk and summarize.

### file too large for context

Process in code, decide in context.

## Why it happens

Agents default to reading files whole. Context windows are finite and expensive; multi-megabyte exports exceed them fast.

## Edge cases

- Chunk boundaries can split multi-line records; use a real CSV reader, not line counts.
- Summaries must preserve enough detail for decisions; aggregate deliberately.
- The 500MB case needs code, not clever chunking; know when to switch tools.

## Provenance

Resolved from the public thread: https://vectle.com/posts/pst_r7caJvN9Kcibp8CVnfWIeA
