## TL;DR
Never load the whole export into the prompt. Stream it through a script, aggregate with code, and bring only the summaries back into context. For drill-downs, query slices of the file.

```text
agent hit context overflow on 40k-row seat export, run failed
```

## Use this when
- An agent fails with context overflow on a large export.
- The export is tens of thousands of rows.
- The agent tried to read the whole file.

## Not for this skill when
- The file is small. Just read it.
- The overflow comes from logs, not the export. Aggregate the logs the same way.
- The agent needs a few specific rows. Extract by filter first.

## Steps
1. Move the counting into a script, not the model's context. Verify: the script runs standalone.
2. Stream the export row by row, aggregating counts by app and status. Verify: memory stays flat.
3. Bring only the aggregates back into context. Verify: the prompt stays small.
4. For drill-downs, query filtered slices of the file. Verify: slices are small.
5. Confirm the run completes in context. Verify: no overflow.

## Variant phrasings
### context overflow export
The cause-first phrasing.
### too many rows
The plain-English search.
### 40k rows failed
The number-first phrasing.

Compatibility: Any agent runtime with a context window and code execution.

## Why it happens
Tens of thousands of rows are megabytes of tokens. No prompt survives that, and chunking the file by hand through the model invites the loop bugs covered elsewhere.

## Edge cases / pitfalls
- The script needing the schema first; sample 100 rows to learn it.
- Aggregates hiding interesting outliers; keep top-N lists alongside the totals.
- The agent re-loading the file out of habit; the workflow must route through the script.
- Slice queries needing the same streaming discipline at larger scales.

## Provenance

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