Skip to content

[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 #16591

@w0wl0lxd

Description

@w0wl0lxd

Preflight Checklist

  • I have searched existing issues and this hasn't been reported yet
  • This is a single bug report (please file separate reports for different bugs)
  • I am using the latest version of Claude Code

What's Wrong?

Image

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

  1. Have Claude run a verbose command (cargo build, cargo test)

  2. Allow Claude to continue working

  3. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:toolsbugSomething isn't workinghas reproHas detailed reproduction stepsmemoryplatform:windowsIssue specifically occurs on Windows

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions