One research request grew to 261,834 tokens and failed against a 128,000-token model limit. The context did not become large in one prompt. Replayed tool results accumulated across checkpoints.

INC-002 exposed three missing controls: no hard token budget, no message cap, and no pruning policy for old tool observations. Large search and file results were also inserted without compression.

A practical prevention stack

  1. Set a maximum context-token budget on every graph.
  2. Cap messages and replayable tool results.
  3. Compress observations before model re-entry.
  4. Check the budget after every node, not only before invocation.
  5. Test a long multi-tool request with realistic result sizes.

The important metric is context size at each boundary. A final failure log is too late to explain where growth started.

Run a heuristic review with:

prevention-scanner scan . --format json 

Then confirm the result with a test that simulates 50 or more tool calls and asserts the context remains bounded.

Read the full INC-002 incident.

AI #Agents #LangGraph #LLMOps