[BUG] Model reading from Task Output for background tasks like `cargo build` or `cargo test` bypasses token output limit and uses entire session context in one read
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
<img width="403" height="118" alt="Image" src="https://github.com/user-attachments/assets/b775eb43-7910-42ae-ae14-3c48daa7522c" />
When Claude reads from Task Output of wordy/long tasks, it uses the entire available token budget to try and fit it, instead of limiting the amount of tokens to "BASH_MAX_OUTPUT_LENGTH" value, in this case "BASH_MAX_OUTPUT_LENGTH": "15000"
Claude correctly attempted to run tail -100 on the /tasks/bc7f68e.output file before reading this Task output, but oddly decided to read the full output after already getting that.
What Should Happen?
Claude should limit reads of background tasks to the proper configured amount, and not be able to read such large amounts of output from background files.
Error Messages/Logs
Steps to Reproduce
- Have Claude run a verbose command (
cargo build,cargo test)
- Allow Claude to continue working
- Claude will read the Task Output eventually to check status, resulting in the entire output being piped to the models context window.
Claude Model
Sonnet (default)
Is this a regression?
Yes, this worked in a previous version
Last Working Version
_No response_
Claude Code Version
2.0.76
Platform
Other
Operating System
Windows
Terminal/Shell
WSL (Windows Subsystem for Linux)
Additional Information
_No response_
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗