## TL;DR
Summarise in layers instead of loading everything: 2000 test results cannot fit in one prompt, so aggregate results by model and status first, pass only failures and counts to the agent, and fetch detail per model on demand. The raw results are mostly passes nobody needs to read. A rollup keeps every failure visible while reducing the prompt to a fraction of the full artifact.

```text
context overflow failure agent couldnt fit run results for 2000 tests in prompt error
```

## Use this when
- The check or run fails with this symptom: a context overflow when an agent cannot fit run results for 2000 tests in its prompt.
- You are working on an agent workflow summarising large dbt test runs or data quality results and the failure repeats on the same data or configuration.
- You need the failing rows, rule, or stage isolated before changing thresholds or code.

## Not for this skill when
- A small run whose full results fit comfortably, where layering adds steps without benefit.
- The error text names a different tool, stage, or root cause. Match the verbatim error first and use that skill.

## Steps
1. Compute counts by status and by model from the results file with a script. Verify: a compact rollup exists before any prompt is built
2. Build the agent input from the rollup plus the full detail of failing tests only. Verify: the input fits the context with room for the response
3. Let the agent request detail for a specific model when its summary needs it. Verify: requested detail arrives as a separate small input
4. Produce the final summary from the rollup and the investigated failures. Verify: every failure is covered and pass counts are stated
5. Save the rollup with the run artifacts. Verify: the next run diffs rollups instead of reparsing everything

## Variant phrasings
### context overflow run results 2000 tests prompt agent
The shorter phrasing focused on the named failure.
### agent couldnt fit test results context failure
The symptom phrasing a searcher tries next.
### large test results summarise rollup fix
The variant naming the failing stage or tool directly.

Compatibility: dbt run_results and data quality result files, agent summarisation workflows

## Why it happens
Result files grow with project size while context does not. Agents that load artifacts whole hit the limit at exactly the scale where summaries matter most, and truncation silently drops the failures at the end of the file.

## Edge cases / pitfalls
- Truncated input is worse than a rollup because the agent cannot tell what it lost; always aggregate programmatically first.
- Keep failing test detail complete, including the compiled query reference; summaries that drop the failing rows slow the fix.

## Provenance

Resolved from the public thread: https://vectle.com/posts/pst_T5x9CfYQDf3EV1mYvx-nbg
