Skip to content

ACP: running shell output is no longer streamed on in_progress tool_call_update (regression from v1.18) #62173

Open

Description

@cameronalizadeh-distyl

Description

Since v2.0.0 an ACP client no longer receives a running shell command's output while it runs. tool_call_update with status: "in_progress" carries no content; the output arrives only on the completed update. Through v1.18.15 the in-progress updates carried the output so far, so clients could render a live terminal.

Where it went (read at the tags):

  • v1.18.15: the shell tool published its output so far on every chunk (packages/opencode/src/tool/shell.ts, ctx.metadata({ metadata: { output } }), ~L515), and the ACP bridge put that text into the running update as content (packages/opencode/src/acp/tool.ts, runningToolUpdate).
  • v2.0.30 and v2.2.5: live shell output moved into the core Shell service, which captures stdout/stderr to a file and serves it by cursor (packages/core/src/shell.ts, the shell.output route in packages/server/src/handlers/shell.ts), which the TUI polls; the shell plugin's only mid-run progress is { shellID } (packages/core/src/tool/plugin/shell.ts); and the ACP bridge's runningToolUpdate (packages/cli/src/acp/tool.ts) has no content parameter at all, with translate.ts storing session.tool.progress metadata and sending a bare running update. The bridge references neither the Shell service nor that route.

So the 2.0 rewrite moved live output to a service only the TUI consumes, and the new ACP bridge was never attached to it. Fix shape: have the bridge subscribe to the Shell service's output for a running shell call (or have the shell plugin report output in its progress metadata again) and carry it as content on the running update, which serves every ACP client.

Plugins

None

OpenCode version

v2.0.30 (also present in v2.2.5 by source)

Steps to reproduce

  1. Start opencode acp from any ACP client (a stdio JSON-RPC client; we drive it from an agent service).
  2. Prompt: Run this and report the output: for i in 1 2 3 4 5; do echo line $i; sleep 1; done
  3. Watch session/update notifications. Actual: tool_call pending, one tool_call_update in_progress without content, then completed with all five lines about five seconds later. Expected (v1.18.15 behavior): in_progress updates carrying content with line 1, line 1\nline 2, … as the command prints.

Operating System

Linux (containers), macOS 26 for the local check

Terminal

n/a (ACP client)

Activity

  1. opencodejr commented on Nov 5, 2026

    @opencodejr
    Contributor

    Thanks for the detailed report and for tracing it through the code. I reproduced this on v2.0.30 and on the latest dev (32ab1f3).

    I drove opencode acp over stdio with a mock model that runs for i in 1 2 3 4 5; do echo line $i; sleep 1; done through the shell tool. The client received tool_call pending, then tool_call_update with status: "in_progress" and no content, and about five seconds later completed with all five lines at once. No output came through while the command ran.

    This matches your reading of the code. runningToolUpdate in packages/cli/src/acp/tool.ts never sets content, and the shell tool in packages/core/src/tool/plugin/shell.ts only reports { shellID } while it runs, so a fix probably has to change both.

    The script below reproduces it without provider credentials: it starts a local mock model and a small ACP client.

    Reproduction script (repro.sh)
    #!/usr/bin/env bash
    # Reproduces #62173: ACP in_progress tool_call_update for a running shell command carries no output.
    # Needs bun and `opencode` (v2) on PATH. Uses a local mock OpenAI-compatible model; no credentials needed.
    set -euo pipefail
    W=$(mktemp -d); mkdir -p "$W/proj"; cd "$W"
    cat > mock.ts <<'EOF'
    // Minimal OpenAI-compatible streaming mock: first turn calls the shell tool, second turn answers.
    const CMD = "for i in 1 2 3 4 5; do echo line $i; sleep 1; done"
    Bun.serve({
      port: 4011,
      async fetch(req) {
        const body: any = await req.json().catch(() => ({}))
        const tools: string[] = (body.tools ?? []).map((t: any) => t.function?.name)
        const toolName = tools.find((n) => n === "shell" || n === "bash") ?? tools[0]
        const hasResult = (body.messages ?? []).some((m: any) => m.role === "tool")
        const id = "c1"
        const chunk = (delta: any, finish: string | null = null) =>
          `data: ${JSON.stringify({ id, object: "chat.completion.chunk", created: 0, model: "m", choices: [{ index: 0, delta, finish_reason: finish }] })}\n\n`
        let out = ""
        if (!hasResult) {
          out += chunk({ role: "assistant", tool_calls: [{ index: 0, id: "call_1", type: "function", function: { name: toolName, arguments: JSON.stringify({ command: CMD, description: "print lines" }) } }] })
          out += chunk({}, "tool_calls")
        } else {
          out += chunk({ role: "assistant", content: "Done." })
          out += chunk({}, "stop")
        }
        out += "data: [DONE]\n\n"
        return new Response(out, { headers: { "content-type": "text/event-stream" } })
      },
    })
    EOF
    cat > acp-client.ts <<'EOF'
    // Drives `opencode acp` over stdio and prints every tool_call / tool_call_update with timestamps.
    // Usage: bun acp-client.ts <project dir> [opencode command...]   (default command: opencode)
    // Requires mock.ts running on :4011 and the project's opencode.json pointing at it.
    const dir = process.argv[2] ?? process.cwd()
    const cmd = process.argv.length > 3 ? process.argv.slice(3) : ["opencode"]
    const proc = Bun.spawn([...cmd, "acp"], { cwd: dir, stdin: "pipe", stdout: "pipe", stderr: "inherit" })
    let nextId = 1
    const pending = new Map<number, (v: any) => void>()
    const t0 = Date.now()
    const send = (method: string, params: any) =>
      new Promise<any>((resolve) => {
        const id = nextId++
        pending.set(id, resolve)
        proc.stdin.write(JSON.stringify({ jsonrpc: "2.0", id, method, params }) + "\n")
        proc.stdin.flush()
      })
    ;(async () => {
      let buf = ""
      for await (const chunk of proc.stdout) {
        buf += new TextDecoder().decode(chunk)
        let i
        while ((i = buf.indexOf("\n")) >= 0) {
          const line = buf.slice(0, i)
          buf = buf.slice(i + 1)
          if (!line.trim()) continue
          const msg = JSON.parse(line)
          if (msg.id !== undefined && pending.has(msg.id)) {
            pending.get(msg.id)!(msg)
            pending.delete(msg.id)
          } else if (msg.method === "session/request_permission") {
            const opt = msg.params.options.find((o: any) => o.kind.startsWith("allow")) ?? msg.params.options[0]
            proc.stdin.write(JSON.stringify({ jsonrpc: "2.0", id: msg.id, result: { outcome: { outcome: "selected", optionId: opt.optionId } } }) + "\n")
          } else if (msg.method === "session/update") {
            const u = msg.params.update
            if (u.sessionUpdate === "tool_call" || u.sessionUpdate === "tool_call_update")
              console.log(`[+${((Date.now() - t0) / 1000).toFixed(1)}s] ${u.sessionUpdate} status=${u.status} content=${JSON.stringify(u.content ?? null)}`)
          }
        }
      }
    })()
    await send("initialize", { protocolVersion: 1, clientCapabilities: {} })
    const s = await send("session/new", { cwd: dir, mcpServers: [] })
    if (s.error) { console.log(JSON.stringify(s.error)); process.exit(1) }
    const r = await send("session/prompt", {
      sessionId: s.result.sessionId,
      prompt: [{ type: "text", text: "Run this and report the output: for i in 1 2 3 4 5; do echo line $i; sleep 1; done" }],
    })
    console.log("prompt result:", JSON.stringify(r.result ?? r.error))
    proc.kill()
    process.exit(0)
    EOF
    cat > proj/opencode.json <<'EOF'
    {
      "model": "mock/m",
      "permission": "allow",
      "provider": {
        "mock": {
          "npm": "@ai-sdk/openai-compatible",
          "name": "Mock",
          "options": { "baseURL": "http://127.0.0.1:4011/v1", "apiKey": "x" },
          "models": { "m": { "name": "m", "tool_call": true } }
        }
      }
    }
    EOF
    (cd proj && git init -q)
    bun mock.ts & MOCK=$!; trap "kill $MOCK" EXIT; sleep 1
    timeout 60 bun acp-client.ts "$W/proj" "${@:-opencode}"

    Run it: bash repro.sh

  2. jimmyallinai commented on Nov 5, 2026

    @jimmyallinai
    Contributor

    I'm picking this up. Plan: first reproduce with the mock-model ACP setup from the report (no provider credentials needed), then fix both halves — have the shell tool publish its output so far while it runs, as v1.18 did via metadata, and carry that text as content on the running tool_call_update in packages/cli/src/acp/tool.ts. I'll add a regression test driving opencode acp over stdio asserting an in-progress update carries the partial output before completion, and run the adjacent ACP/shell tests plus typecheck before opening a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions