strix icon indicating copy to clipboard operation
strix copied to clipboard

[BUG] Running strix on a large repo crashed with a ContextWindowExceededError

Open mhspektr opened this issue 5 months ago • 5 comments

Describe the bug Running strix a large repo crashed with a ContextWindowExceededError (1,023,797 tokens > 1,000,000 max). The agent ran semgrep on the mounted repo and received back more than a million lines of JSON as a tool result. That blob was stored verbatim in the SQLite session by the Agents SDK, then serialized into the next API request — blowing the context window.

Two compounding problems made this worse than it needed to be:

  1. Wrong recovery path: ContextWindowExceededError has status_code=400, which matched _INPUT_REJECTION_CODES in _run_cycle. The image-stripping recovery path was tried (and failed, since there are no images to strip), burning retries before falling through to the correct "failed" handling.
  2. Silent TUI failure: The exception was caught by except Exception as e in scan_target and stored in self._scan_error — the TUI kept running silently with no in-app indication. The traceback only appeared after the user exited.

To Reproduce Steps to reproduce the behavior:

  1. run strix on a large mono repo with more than a million lines of code

Expected behavior Strix should not just crash silently in TUI mode and should try to remedy the context window size problem by processing the result in chunks across multiple agents.

System Information:

  • OS: MacOS Tahoe 26.5.1
  • Strix Version or Commit: 11e5d1c2b3dde00740e26c6ef2bc336cb6912a2e
  • Python Version: 3.12.13
  • LLM Used: Claude Sonnet 4.6

mhspektr avatar Jun 19 '26 09:06 mhspektr

I have a fix for this. Should I submit it as three self-contained, stacked PRs or as a single PR?

mhspektr avatar Jun 19 '26 20:06 mhspektr

Thanks @mhspektr! Looking into this issue now. Would be great if you open it as a single PR

0xallam avatar Jun 19 '26 20:06 0xallam

@0xallam The new PR is a continuation of the https://github.com/usestrix/strix/pull/577 PR, so only these commits are "new":

  • c91e4ca - fix: bypass image-strip recovery for ContextWindowExceededError
  • 4bc1430 - fix: show scan error as TUI toast before exit
  • 2f1bb90 - fix: remove timeout=0 from scan error toast — was causing instant dismissal
  • 5aa61c5 - feat: truncate oversized exec_command output to prevent context overflow
  • eac81f8 - feat(core): MapReduce LLM compression for large exec_command outputs
  • 0640e5c - fix(core): backstop single-chunk overflow; add helper tests

mhspektr avatar Jun 22 '26 05:06 mhspektr

@0xallam hi. can you accept the current proposed PR?

mhspektr avatar Jul 22 '26 05:07 mhspektr

Should be fixed now in https://github.com/usestrix/strix/pull/882

0xallam avatar Jul 27 '26 11:07 0xallam