openclaw - ✅(Solved) Fix claude-cli live session: hardcoded 256KB stdout buffer causes spurious "Claude CLI stdout buffer exceeded limit." failures [1 pull requests, 1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#71793Fetched 2026-04-26 05:08:16
View on GitHub
Comments
1
Participants
2
Timeline
3
Reactions
0
Author
Timeline (top)
closed ×1commented ×1cross-referenced ×1

Since 2026.4.22 (warm stdio sessions for claude-cli, #69679), embedded agents using claude-cli provider intermittently fail with:

Embedded agent failed before reply: Claude CLI stdout buffer exceeded limit.

The error is non-recoverable for the current session (user has to /new) and surfaces to channel users as the generic ⚠️ Something went wrong while processing your request. Please try again, or use /new to start a fresh session.

Root cause: the live-session stdout reader has hardcoded character limits with no config knob.

Error Message

The error is non-recoverable for the current session (user has to /new) and surfaces to channel users as the generic ⚠️ Something went wrong while processing your request. Please try again, or use /new to start a fresh session. 2026-04-25T18:57:58 WARN model-fallback/decision reason=format status=400 2026-04-25T18:57:58 ERROR Embedded agent failed before reply: 3. Improve the channel-facing error: include the underlying reason (or a /diagnostics hint) instead of the generic "Something went wrong", so users don't have to dig through gateway logs.

Root Cause

Root cause: the live-session stdout reader has hardcoded character limits with no config knob.

Fix Action

Fix / Workaround

Workaround for users on 2026.4.22+

Downgrade to 2026.4.21 (no warm stdio sessions, no buffer) — confirmed clean. Trade-off: lose stdio session warm-up and other 4.22+ improvements.

PR fix notes

PR #71897: fix(agents): allow large Claude live JSONL lines

Description (problem / solution / changelog)

Fixes the Claude CLI live-session stdout cap that aborts large stream-json turns before WebChat, Telegram, or MCP-heavy replies can complete.

Fixes #71793 Fixes #71080 Fixes #70766

Changes:

  • add regression coverage for a single Claude live JSONL result line over 256 KiB
  • use the existing 2 MiB per-turn raw limit for pending JSONL lines instead of a separate 256 KiB stdout buffer cap

Verified:

  • pnpm test src/agents/cli-runner.spawn.test.ts -t 'accepts Claude live stream-json lines larger than 256 KiB'
  • pnpm test src/agents/cli-runner.spawn.test.ts
  • pnpm check:changed

Changed files

  • CHANGELOG.md (modified, +1/-0)
  • src/agents/cli-runner.spawn.test.ts (modified, +44/-0)
  • src/agents/cli-runner/claude-live-session.ts (modified, +4/-4)

Code Example

Embedded agent failed before reply: Claude CLI stdout buffer exceeded limit.

---

2026-04-25T18:57:58 WARN model-fallback/decision  reason=format status=400
  errorPreview="Claude CLI stdout buffer exceeded limit."
  errorHash=sha256:b2802736e694
2026-04-25T18:57:58 ERROR Embedded agent failed before reply:
  Claude CLI stdout buffer exceeded limit.

---

// dist/execute.runtime-ix6AkkxA.js
const CLAUDE_LIVE_MAX_STDOUT_BUFFER_CHARS = 256 * 1024;   // 256 KB
const CLAUDE_LIVE_MAX_STDERR_CHARS         = 64  * 1024;
const CLAUDE_LIVE_MAX_TURN_RAW_CHARS       = 2   * 1024 * 1024;
const CLAUDE_LIVE_MAX_TURN_LINES           = 5000;

if (session.stdoutBuffer.length > CLAUDE_LIVE_MAX_STDOUT_BUFFER_CHARS) {
  closeLiveSession(session, "abort",
    createOutputLimitError(session, "Claude CLI stdout buffer exceeded limit."));
  return;
}
RAW_BUFFERClick to expand / collapse

Summary

Since 2026.4.22 (warm stdio sessions for claude-cli, #69679), embedded agents using claude-cli provider intermittently fail with:

Embedded agent failed before reply: Claude CLI stdout buffer exceeded limit.

The error is non-recoverable for the current session (user has to /new) and surfaces to channel users as the generic ⚠️ Something went wrong while processing your request. Please try again, or use /new to start a fresh session.

Root cause: the live-session stdout reader has hardcoded character limits with no config knob.

Affected versions

  • 2026.4.22, 2026.4.23, 2026.4.24 — confirmed by inspecting tarballs.
  • 2026.4.21 and earlier — not affected (the live-session reader did not exist).

Repro

Any embedded claude-cli turn whose stdout produces a single chunk/line longer than 256 KB before a newline triggers the abort. In practice this fires when:

  • A tool result returned to the CLI is large (web fetches, big file reads, screenshots-in-prompt, large sessions_history results).
  • A long assistant message is streamed in a single chunk.

In my case it fired 3 times in 7 minutes (turns of 101s, 77s, 119s before abort), all with the same errorHash sha256:b2802736e694. Same hash repeated across days.

Evidence

From the gateway log:

2026-04-25T18:57:58 WARN model-fallback/decision  reason=format status=400
  errorPreview="Claude CLI stdout buffer exceeded limit."
  errorHash=sha256:b2802736e694
2026-04-25T18:57:58 ERROR Embedded agent failed before reply:
  Claude CLI stdout buffer exceeded limit.

Source (in 2026.4.24 dist):

// dist/execute.runtime-ix6AkkxA.js
const CLAUDE_LIVE_MAX_STDOUT_BUFFER_CHARS = 256 * 1024;   // 256 KB
const CLAUDE_LIVE_MAX_STDERR_CHARS         = 64  * 1024;
const CLAUDE_LIVE_MAX_TURN_RAW_CHARS       = 2   * 1024 * 1024;
const CLAUDE_LIVE_MAX_TURN_LINES           = 5000;

if (session.stdoutBuffer.length > CLAUDE_LIVE_MAX_STDOUT_BUFFER_CHARS) {
  closeLiveSession(session, "abort",
    createOutputLimitError(session, "Claude CLI stdout buffer exceeded limit."));
  return;
}

There is no path in openclaw.json to override these — they are module-level constants.

Why 256 KB is too low for the stdout buffer

The buffer holds bytes received between newlines. Claude CLI's JSONL stream emits one line per event, but tool_use/tool_result payloads (especially media, file contents, or large search results) can easily exceed 256 KB in a single line before the \n arrives. Hitting the limit aborts the entire turn even though the line is well-formed JSONL that would parse fine.

Suggested fix

  1. Bump defaults — at minimum match CLAUDE_LIVE_MAX_TURN_RAW_CHARS (2 MB) for stdout, since a single JSONL line can legitimately approach turn-level size. Suggested:
    • STDOUT_BUFFER: 2 MB (or 4 MB)
    • STDERR: 256 KB
  2. Make all four constants configurable via agents.cli.claudeLive.{stdoutBufferBytes,stderrBytes,turnRawBytes,turnLines} so operators can tune without forking dist.
  3. Improve the channel-facing error: include the underlying reason (or a /diagnostics hint) instead of the generic "Something went wrong", so users don't have to dig through gateway logs.

Happy to send a PR if useful.

Workaround for users on 2026.4.22+

Downgrade to 2026.4.21 (no warm stdio sessions, no buffer) — confirmed clean. Trade-off: lose stdio session warm-up and other 4.22+ improvements.

Environment

  • openclaw 2026.4.24 (ed28607)
  • macOS 26.4.1 / arm64 / node v25.8.2
  • claude-cli provider, claude-opus-4-7 (also reproduced on claude-sonnet-4-6)
  • Telegram channel

extent analysis

TL;DR

Increase the CLAUDE_LIVE_MAX_STDOUT_BUFFER_CHARS limit to at least 2 MB to prevent the Claude CLI stdout buffer from exceeding the limit.

Guidance

  • Identify the version of openclaw being used and check if it's one of the affected versions (2026.4.22, 2026.4.23, 2026.4.24).
  • Consider downgrading to 2026.4.21 as a temporary workaround, but note that this will lose stdio session warm-up and other improvements.
  • To mitigate the issue, ensure that tool results and assistant messages are formatted to avoid single chunks/lines longer than 256 KB before a newline.
  • Monitor gateway logs for error messages indicating the stdout buffer limit has been exceeded.

Example

No code snippet is provided as the issue is related to configuration and constants.

Notes

The suggested fix involves bumping the defaults for the stdout buffer and making the constants configurable via openclaw.json. However, this may require a PR and may not be immediately available.

Recommendation

Apply the workaround by downgrading to 2026.4.21 until a fixed version is available, as this is a confirmed clean version without the buffer limit issue.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - ✅(Solved) Fix claude-cli live session: hardcoded 256KB stdout buffer causes spurious "Claude CLI stdout buffer exceeded limit." failures [1 pull requests, 1 comments, 2 participants]