Skip to content

debug skill: stdout is truncated when piped (exits before draining), still on 1.18.30 and 1.19.5 #64635

Closed as not planned

Description

@xxchan

opencode debug skill still truncates stdout when piped on 1.18.30 and 1.19.5. This reproduces the failure in #26399, which was closed by the stale bot with a request to open a new issue if it persists.

Linux x64, genuine npm opencode-ai installs, isolated HOME/XDG directories, empty working directory, no credentials or model request. One synthetic user skill has a 512 KiB body. Each version was tested three times with stdout piped and three times with stdout redirected to a regular file descriptor; the same command and fixture were used.

Version Capture Bytes in every sample Exit Stderr bytes JSON
1.18.30 pipe 65,536 0 0 invalid
1.18.30 regular file 541,936 0 0 valid, 2 entries
1.19.5 pipe 131,072 0 0 invalid
1.19.5 regular file 541,936 0 0 valid, 2 entries

The native skill command writes the serialized catalog to stdout; the process can exit before a large pipe write has drained. Redirecting stdout to an already-open regular file and reading it after process completion preserves the full result. This makes a successful exit insufficient for consumers that capture stdout through a pipe.

Reproduction: install either version into a private prefix and run the script below with the absolute binary path (python3 v1-stdout.py /path/to/opencode). The script creates and removes its own synthetic fixture, executes three pipe/file pairs, and reports only sizes, exit status and JSON validity. No skill text or credentials are printed. Expected: both forms return the same complete JSON catalog.

OAR is adding a temporary regular-file capture workaround. Please identify the v1 release that drains this output before exiting so consumers can remove that workaround after rerunning the same comparison.

<details><summary>v1-stdout.py</summary>

"""Compare v1 debug skill pipe and file output without publishing skill content."""
import json
import os
from pathlib import Path
import subprocess
import sys
import tempfile


def observation(completed, output):
    try:
        parsed = json.loads(output)
        shape = {"validJson": True, "items": len(parsed) if isinstance(parsed, list) else None}
    except (ValueError, UnicodeDecodeError):
        shape = {"validJson": False, "items": None}
    return {"exitCode": completed.returncode, "stdoutBytes": len(output),
            "stderrBytes": len(completed.stderr), **shape}


binary = str(Path(sys.argv[1]).resolve())
with tempfile.TemporaryDirectory(prefix="oar-opencode-pipe-") as temporary:
    root = Path(temporary)
    home, cwd = root / "home", root / "empty"
    home.mkdir()
    cwd.mkdir()
    skill = home / ".agents/skills/large/SKILL.md"
    skill.parent.mkdir(parents=True)
    skill.write_text("---\nname: large\ndescription: Synthetic output-size fixture\n---\n" + "x" * (512 * 1024))
    env = {key: os.environ[key] for key in ("PATH", "SystemRoot", "TEMP", "TMP") if key in os.environ}
    env.update(HOME=str(home), USERPROFILE=str(home), XDG_CONFIG_HOME=str(root / "config"),
               XDG_DATA_HOME=str(root / "data"), XDG_CACHE_HOME=str(root / "cache"),
               XDG_STATE_HOME=str(root / "state"), OPENCODE_DISABLE_AUTOUPDATE="true",
               OPENCODE_DISABLE_MODELS_FETCH="true", NO_COLOR="1")
    version = subprocess.run([binary, "--version"], cwd=cwd, env=env, stdin=subprocess.DEVNULL,
                             capture_output=True, check=True, timeout=30).stdout.decode().strip()
    rows = []
    for attempt in range(3):
        piped = subprocess.run([binary, "debug", "skill"], cwd=cwd, env=env,
                               stdin=subprocess.DEVNULL, capture_output=True, timeout=30)
        with tempfile.TemporaryFile() as output:
            filed = subprocess.run([binary, "debug", "skill"], cwd=cwd, env=env,
                                   stdin=subprocess.DEVNULL, stdout=output, stderr=subprocess.PIPE, timeout=30)
            output.seek(0)
            rows.append({"attempt": attempt + 1, "pipe": observation(piped, piped.stdout),
                         "file": observation(filed, output.read())})
    print(json.dumps({"version": version, "platform": sys.platform, "bodyBytes": 512 * 1024,
                      "credentialEnvironmentInherited": False, "samples": rows}, indent=2))

</details>


Agent Cindy wrote this for @xxchan through Stamp (grant cgr_0a427a0749428a5c521774a30edf08b7)

Activity

  1. opencodejr commented on Nov 18, 2026

    @opencodejr
    Contributor

    Thanks for the detailed comparison and the self-contained script.

    Both versions you tested (1.18.30 and 1.19.5, npm opencode-ai) are OpenCode v1, which only gets critical fixes. Your setup already has a workaround: the full output comes through when stdout goes to a regular file. So this is unlikely to be fixed in a v1 release, and I can't point you to a v1 release that drains the output before exiting.

    We recommend moving to v2: npm uninstall -g opencode-ai, then npm install -g @opencode/cli (other install options: https://opencode.ai/docs/, migration notes: https://opencode.ai/docs/migrate-v1/). In the v2 CLI code I read, I did not find a debug skill command, so I can't say whether v2 behaves differently for this exact command.

    Related issues:

    I'm closing this issue now. If you think this is critical, or you see the same truncation on a 2.x version, reply here and the issue will reopen.

  2. added
    area/cli
    type/bug
    version/v1
    on Nov 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/cliplatform/linuxtype/bugversion/v1

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions