[BUG] BASH_MAX_OUTPUT_LENGTH ignored after v2.1.2 — large outputs persisted to disk regardless of setting

Resolved 💬 3 comments Opened Jan 13, 2026 by AlexParamonov Closed Feb 27, 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?

The BASH_MAX_OUTPUT_LENGTH environment variable is ignored after v2.1.2.

I have BASH_MAX_OUTPUT_LENGTH=150000 configured, which should allow outputs up to 150,000 characters to be returned fully inline. Instead, outputs as small as ~30-50KB are being persisted to disk. Claude only sees a small preview and loses everything after the first ~2KB.

A 50KB output is well under the 150K limit — it should be returned completely, not persisted to disk.

Problems caused by this regression:

  1. Breaks existing workflows — tools built around BASH_MAX_OUTPUT_LENGTH=150000 stopped working without warning
  2. Loses critical data — Claude only sees preview, loses all content at the end of structured outputs
  3. Wastes tokens — preview is included in context, then Claude must Read the full file anyway
  4. Adds latency — requires follow-up Read tool calls instead of single inline response
  5. Read tool has its own limits — lines over 2000 characters are truncated, breaking single-line JSON

What Should Happen?

With BASH_MAX_OUTPUT_LENGTH=150000:

  • Outputs under 150,000 characters should be returned fully inline — no truncation, no persistence to disk
  • Only outputs exceeding 150K should trigger any special handling

A 50KB output is 50,000 characters — one third of the 150K limit. It should be returned completely.

Error Messages/Logs

When running a bash command that returns ~50KB output:


Output too large (50.2KB). Full output saved to: /home/user/.claude/projects/.../tool-results/toolu_xxx.txt
Preview (first 2KB):
{"output": [...beginning of output only...]


50KB is NOT "too large" when `BASH_MAX_OUTPUT_LENGTH=150000` is configured.

Steps to Reproduce

  1. Configure settings.json:

``json
{
"env": {
"BASH_MAX_OUTPUT_LENGTH": "150000"
}
}
``

  1. Restart Claude Code to apply settings
  1. Run any bash command that returns 30-50KB of output:

``bash
my-tool --verbose # returns ~50KB structured JSON
``

  1. Expected: Full 50KB output returned inline (well under 150K limit)
  1. Actual: Output persisted to disk, Claude sees only ~2KB preview

Claude Model

Not sure / Multiple models

Is this a regression?

Yes, this worked in a previous version

Last Working Version

2.1.1

Claude Code Version

2.1.6

Platform

Anthropic API

Operating System

Ubuntu/Debian Linux

Terminal/Shell

Non-interactive/CI environment

Additional Information

Why This Matters: Self-Contained Tool Responses

This is not just about output size. The issue is self-contained tool responses — structured JSON that includes data, metadata, and instructions for Claude to operate autonomously.

When Claude only sees a preview, it loses all the metadata at the end of the JSON that tells it what to do next.

---

Example 1: Custom Test Runner

Command: my-test-runner --suite integration

Returns ~50KB JSON:

{
  "output": [...verbose test output with stack traces...],
  "summary": {"passed": 47, "failed": 2, "skipped": 3},
  "failed_tests": ["test_auth_timeout", "test_payment_validation"],
  "failure_details": {
    "test_auth_timeout": "Connection refused on port 5432",
    "test_payment_validation": "AssertionError: expected 200, got 422"
  },
  "rerun_command": "my-test-runner -k 'auth_timeout or payment_validation' -v",
  "tokens_used": 18500,
  "tokens_remaining": 81500,
  "warnings": ["Database container may need restart"],
  "suggestions": [
    "Check if postgres service is running",
    "Review payment API schema changes"
  ],
  "instructions": "Analyze failures above. Use failure_details for quick diagnosis. Run rerun_command after fixing."
}

With current bug: Claude sees only preview of output, loses summary, failed_tests, failure_details, rerun_command, warnings, suggestions, instructions.

Expected: Claude sees full JSON, understands what failed, follows instructions, tracks token budget.

---

Example 2: API Data Wrapper

Command: api-tool fetch --endpoint /users --limit 500

Returns ~40KB JSON:

{
  "data": [
    {"id": 1, "name": "Alice", "email": "alice@example.com", "role": "admin", ...},
    {"id": 2, "name": "Bob", "email": "bob@example.com", "role": "user", ...},
    ...hundreds more records...
  ],
  "metadata": {
    "total_records": 5000,
    "returned": 500,
    "offset": 0
  },
  "has_more": true,
  "next_command": "api-tool fetch --endpoint /users --limit 500 --offset 500",
  "rate_limit": {
    "remaining": 95,
    "reset_at": "2026-01-13T15:30:00Z"
  },
  "instructions": "Process the data above. If you need more records, use next_command. Watch rate_limit.remaining."
}

With current bug: Claude sees only beginning of data array, loses metadata, has_more, next_command, rate_limit, instructions.

Expected: Claude sees full response, knows there's more data, knows the next command, respects rate limits.

---

Example 3: Build/Deploy Tool

Command: build-tool deploy --env staging

Returns ~35KB JSON:

{
  "logs": [
    "[10:15:01] Installing dependencies...",
    "[10:15:45] Running type checks...",
    "[10:16:02] Building application...",
    "[10:16:30] Optimizing assets...",
    "[10:17:15] Deploying to staging...",
    ...hundreds more log lines...
  ],
  "status": "success",
  "duration_seconds": 180,
  "artifacts": {
    "bundle": "/dist/app.js (245KB)",
    "styles": "/dist/app.css (18KB)",
    "source_map": "/dist/app.js.map (890KB)"
  },
  "deployment": {
    "url": "https://staging.example.com",
    "version": "2.1.0-beta.3",
    "commit": "abc123f"
  },
  "next_steps": [
    "Run smoke tests: test-tool smoke --env staging",
    "Check deployment: curl https://staging.example.com/health",
    "When verified, deploy to production: build-tool deploy --env production"
  ],
  "warnings": [
    "Bundle size increased by 12KB from previous build",
    "Deprecated API usage detected in src/legacy.js"
  ]
}

With current bug: Claude sees only logs, loses status, artifacts, deployment, next_steps, warnings.

Expected: Claude sees full response, knows deployment succeeded, knows the URL, follows next steps.

---

Current Workaround

Locked installation to v2.1.1 with auto-updates disabled. This is not sustainable.

Proposed Fix

Simplest fix: Make BASH_MAX_OUTPUT_LENGTH control when disk persistence kicks in.

If BASH_MAX_OUTPUT_LENGTH=150000, outputs under 150K should be fully inline. Only outputs exceeding 150K should be persisted to disk.

Related Issues

| Issue | Relevance |
|-------|-----------|
| #805 | Original feature request that introduced disk persistence in v2.1.2 |
| #12054 | Context overflow from large outputs — problem v2.1.2 aimed to solve |
| #11155 | Memory issues with large bash outputs — another problem v2.1.2 addressed |
| #2638 | Request for configurable MCP tool response truncation limits |
| #12297 | Request for configurable truncation strategy |
| #3964 | Similar pattern: BASH_DEFAULT_TIMEOUT_MS env var ignored |

Note

The disk persistence feature (#805) is valuable for truly large outputs (compiler dumps, massive logs). This report is about respecting BASH_MAX_OUTPUT_LENGTH — if a user configures 150K, outputs under that limit should be fully inline.

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗