Skip to content

[Bug]: OpenCode skills return zero in provider cache — pipe buffer truncates opencode debug skill output at 64KB #7807

Description

@jemini-pro

Before submitting

  • I searched existing issues and did not find a duplicate.
  • I included enough detail to reproduce or investigate the problem.

Area

apps/server

Steps to reproduce

  1. Install opencode v1.18.20 and T3 Code v0.0.34-nightly.20260821.1151 on macOS arm64
  2. Add 15+ skills to ~/.config/opencode/skills/ (each with SKILL.md frontmatter)
  3. Start T3 server (t3 serve)
  4. Wait for provider snapshot refresh
  5. Inspect ~/.t3/caches/opencode.jsonskills array is empty

To confirm the pipe truncation directly:

# File redirect — full output (138140 bytes)
opencode debug skill > /tmp/skills.json 2>/dev/null && wc -c /tmp/skills.json
# 138140

# Pipe — truncated at 64KB
opencode debug skill 2>/dev/null | wc -c
# 65536

# PTY — full output
script -q /dev/null opencode debug skill 2>/dev/null | wc -c
# 138302

Expected behavior

T3's OpenCode provider cache should list all discovered skills, same as Claude and Codex providers do. Skills should appear in the composer $ picker.

Actual behavior

T3's OpenCode provider cache reports skills: [] and slashCommands: []. Skills are invisible in the composer. Skills with model invocation disabled cannot be discovered or invoked.

Impact

Major degradation or frequent failure

Version or commit

T3 Code v0.0.34-nightly.20260821.1151, OpenCode v1.18.20 (also reproduced on v1.18.18)

Environment

macOS 26.6.2, Apple Silicon arm64. opencode binary is a Bun-compiled Mach-O executable. 26 skills on disk at ~/.config/opencode/skills/. Pipe output: 65536 bytes (truncated from 138140).

Logs or stack traces

~/.t3/caches/opencode.json after refresh:
{
  "displayName": "OpenCode",
  "enabled": true,
  "installed": true,
  "version": "1.18.20",
  "status": "ready",
  "skills": [],
  "slashCommands": [],
  ...
}

Root cause: opencode debug skill produces ~138KB of JSON. When T3 spawns it as a child process without a PTY, stdout is a pipe. The opencode binary (Bun-compiled) does not flush its write buffer properly to non-TTY stdout, so the pipe receives exactly 65536 bytes (64KB) and the rest is lost. The truncated JSON fails to parse in parseSkillsCliOutput, which silently returns []:

function parseSkillsCliOutput(stdout) {
    const result = decodeOpenCodeSkillsCliOutputExit(stdout);
    return isSuccess$1(result) ? result.value : [];
}

The models (opencode models --verbose) and agents (opencode agent list) commands work fine because their output stays under 64KB.

Workaround

Patch runSkillsCli in bin.mjs to redirect output to a temp file instead of relying on pipe stdout:

const runSkillsCli = () => runOpenCodeCommand({
    binaryPath: "sh",
    args: ["-c", `${input.binaryPath} debug skill > /tmp/.t3_oc_skills_${process.pid}.json && cat /tmp/.t3_oc_skills_${process.pid}.json && rm -f /tmp/.t3_oc_skills_${process.pid}.json`],
    ...commandContext
}).pipe(exit);

This patch is lost on npm install -g t3@nightly. PR #7572 (filesystem-based skill discovery) would fix this properly by reading SKILL.md files directly.

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions