anomalyco / anomalyco/opencode

shell tool returns "(no output)" when a single line exceeds the byte limit

Open
#42,277 1 comment 0 reactions 1 assignee View on GitHub

@jlongster is already working on this.

Since Aug 13, 2026.

Dominant language
TypeScript
Stars
209k
Forks
27.5k
PR merge metrics
PR metrics pending

Description

Description

When a command prints a single line larger than tool_output.max_bytes (default 50 KB) and the output ends with a newline, the shell tool hands the model a truncation banner followed by (no output) — the whole body is dropped. The same content without the trailing newline returns the expected 50 KB tail.

Cause: tail() in packages/opencode/src/tool/shell.ts:236-250 walks the lines backwards and byte-slices the last line when nothing else fits, guarded by out.length === 0. split("\n") appends an empty sentinel for the trailing newline; the sentinel costs 0 bytes but is unshifted into out first, so that guard is never true for output ending in a newline and the byte-slice fallback is unreachable. bytes === 0 is the check that was intended.

The existing truncates output exceeding byte limit test misses it because its generator writes the bytes without a trailing newline and only asserts the banner, not the body.

Not #40728 (that one is about the spill file on disk — the spill file is complete here), and not #36795 / #35511 (intermittent capture races — this is deterministic).

Disclosure: found and reproduced with AI assistance; I reviewed and verified every claim locally.

Plugins

No response

OpenCode version

dev @ cc4b456 (v1.18.18)

Steps to reproduce
  1. Make a file that is one 80 KB line ending with a newline:
bun -e 'Bun.write("big.txt","a".repeat(80000)+"\n")'
  1. Ask the agent to run cat big.txt.

Expected: the last 50 KB of the line. Actual, 191 characters in total:

...output truncated...

Full output saved to: /…/tool-output/tool_xxx

(no output)

Commands that hit this in practice: cat on a minified bundle or a single-line JSON/lockfile, curl, jq -c, base64, docker inspect.

Screenshot and/or share link

No response

Operating System

macOS 15

Terminal

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.