[BUG] Background subagent turn produced corrupted non-text output, consuming full max_tokens budget

Status Open
Maintainer reply None cached
Activity 1 comment · opened Jul 20, 2026

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?

##Bug: background subagent turn produced corrupted non-text output, consuming full max_tokens budget

Environment

  • Claude Code CLI v2.1.215
  • Model: Sonnet 5 (claude-sonnet-5)
  • Context: local background agent (subagent_type: writer), spawned via the Agent tool with run_in_background: true
  • Session ID: 6424796d-19e1-49c5-acff-4de74c7a2f0e
  • Request ID: req_011CdDHnJPMcUypCUmqUvZuS
  • Timestamp: 2026-07-20T12:25:22.095Z

What happened
A single assistant turn from the background writer subagent returned, instead of narrative Italian prose, a very large block of characters resembling base64/opaqu
e binary data (not valid text in any expected format). The turn consumed the entire output budget for that call:

  • output_tokens: 32000
  • stop_reason: "max_tokens"
  • cache_creation_input_tokens: 61725

No readable content was produced in that turn. Retrieved via TaskOutput while the task was still marked running.

Impact

  • The full token budget for the turn was wasted on unusable output.
  • Task status/monitoring tooling (TaskOutput) surfaced this garbled blob as if it were legitimate in-progress output, making it impossible to tell from the tran

script alone whether the agent was working correctly.

  • Note: in this case the previously saved file on disk from an earlier successful turn was unaffected and remained valid — so the corruption appears to be isola

ted to this one generation turn, not a filesystem/write corruption issue. But if this had been the agent's only/final turn, the task would have failed silently or
produced garbage as the deliverable.

Reproduction
Not reliably reproducible on demand — encountered once during a long-running background writer-role subagent task. Happy to share the full raw transcript turn on
request (contains proprietary editorial content, so not attaching directly here).

What Should Happen?

Expected behavior

The model should produce valid text output, or the turn should fail/error clearly rather than silently emitting a max-length block of non-text data.

Error Messages/Logs

Steps to Reproduce

no

Claude Model

Sonnet (default)

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

CLI v2.1.215

Platform

Other

Operating System

Other Linux

Terminal/Shell

Other

Additional Information

_No response_

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗