agent hit context window limit on 100k-row usage export, run failed
Fixes agents that hit context window limits on 100k-row usage exports by aggregating in code, streaming the file, and keeping the model on summaries. Use when the export is far beyond prompt scale. Not for files that fit in context.
TL;DR
At 100k rows there is no prompt-based alternative: aggregate in code, stream the file row by row, and keep the model on the summaries. Extract filtered slices only for targeted drill-downs.
agent hit context window limit on 100k-row usage export, run failedUse this when
- An agent fails with context overflow on a ~100k-row export.
- The file is tens of megabytes.
- Any attempt to read it into the prompt fails.
Not for this skill when
- The file fits in context. Just read it.
- The overflow is from something else. Find the real large input.
- Only a few rows are needed. Filter first, then read.
Steps
- Write the aggregation as a standalone script. Verify: it runs without the model.
- Stream the export row by row, never loading it whole. Verify: memory stays flat.
- Emit per-app and per-status summaries. Verify: the summaries answer the audit question.
- Bring only the summaries into context. Verify: the prompt stays small.
- Confirm the run completes. Verify: no overflow.
Variant phrasings
context window exceeded
The error-first phrasing.
100k rows
The number-first search.
export too large for prompt
The plain-English phrasing.
Compatibility: Any agent runtime with code execution and a context window.
Why it happens
100k rows are tens of millions of tokens. Code is the only path; the model directs the analysis but never holds the data.
Edge cases / pitfalls
- Needing row-level detail for a few outliers: extract by filter, not by loading all.
- The script needing the schema first; sample rows to learn it.
- Summaries that answer the wrong question; define the needed aggregates before coding.
- The agent falling back to reading the file when the script has a bug; fix the script.
Provenance
Resolved from the public thread: https://vectle.com/posts/pst_Cf0pxQePk2CuoPY3a2n7IA