Skip to content

opencode-go/muse-spark-1.2: frequent 'upstream stream ended mid tool call without a terminal signal — possible truncation' in streaming tool calls (Codex App via ocx, Pi direct OK) #2156

Description

@fede-oss

Client or integration

Codex App (also reproduced via Pi coding-agent 0.83.0 when routed through OpenCodex proxy)

Area

Provider adapter

Summary

muse-spark-1.2 via opencode-go (adapter: openai-chat, baseUrl: https://opencode.ai/zen/go/v1) fails frequently in streaming tool-call turns with:

upstream stream ended mid tool call without a terminal signal — possible truncation

Source is src/adapters/openai-chat.ts:1718-1726:

const sawFinish = finishReason !== undefined;
if (!sawFinish && pendingToolCalls.length > 0) {
  yield { type: "error", message: "upstream stream ended mid tool call without a terminal signal — possible truncation" };
}

The upstream SSE emits response.created / tool deltas but closes without finish_reason, [DONE], or response.completed. The model is reasoning-heavy and the turn is truncated mid-JSON, leaving pending tool calls un-finalized. Same model via Pi direct to opencode-go (no ocx) is fine — this isolates the failure to the ocx streaming proxy layer, matching anomalyco/opencode#40888 matrix (stream:true + tools fails, stream:false + tools works).

Expected: streaming tool request should produce a complete terminal sequence or a structured retryable error, or automatically fallback to buffered mode like the opencode#40888 workaround (stream:false + reframe as SSE).

Reproduction

  1. ocx start --port 10100 (default, opencodex 2.26.0)
  2. Pi/Codex config:
    {
      "defaultProvider": "opencode-go",
      "defaultModel": "muse-spark-1.2-contributor",
      "defaultThinkingLevel": "xhigh"
    }
  3. Run a session that triggers a tool-heavy turn (e.g., read/write/edit batch, ~14k thinking tokens). No manual abort.
  4. Observe request log: turn emits thinking then 1-3 tool calls, last tool args truncated mid-token (cd ~/code/zosmaai/z-like), then proxy yields:
    [openai-chat] stream-truncated { finishReason: null, hadUsage: false, pendingToolCalls: 2 }
    error: upstream stream ended mid tool call without a terminal signal — possible truncation
    
  5. Reproduction matrix (same as anomalyco/opencode#40888 for gpt-5.6-luna through same opencode Go endpoint):
    • stream:true + tools → fails with upstream stream ended mid tool call...
    • stream:false + tools → works (buffered, reframed as SSE)
    • stream:true + no tools → works
  6. Frequency via Codex App → ocxopencode-go/muse-spark-1.2: ~30-50% of tool turns with xhigh. Pi direct (no ocx) not observed. Other models via same proxy (opencode-go/kimi-k2.7-code, qwen3.8-max) rarely hit it.

Why this model hits it a lot:

  • Reasoning budget vs output cap: muse-spark-1.2 defaults to extended thinking (budgetTokens: min(16000, limit.output/2)). opencode Go caps OUTPUT_TOKEN_MAX=32000 (see opencode#18108). Turns that spend 13-16k thinking + a 30-40KB write JSON hit finishReason: length mid-tool-call. See opencode#18108 repros: reasoning ~130k, output 32000, finish: "length", text_len=0.
  • Known bridge shape: zosmaai/zosma-cowork#329 (mimo-v2.5 via opencode-go → 3 bash pending running) and opencode#26170 (finishReason: "other" with 0 output) show same orphaned-running-tool pattern behind opencode-go.

Version

2.26.0

Operating system

macOS 15.7.9 (Build 24G830), Darwin 24.6.0 arm64

Provider and model

opencode-go / muse-spark-1.2 (Pi alias muse-spark-1.2-contributor, PI_REASONING_LEVEL=xhigh, adapter openai-chat, baseUrl: https://opencode.ai/zen/go/v1, authMode: key)

Logs or error output

[openai-chat] stream-truncated { finishReason: null, hadUsage: false, pendingToolCalls: 2 }
error: upstream stream ended mid tool call without a terminal signal — possible truncation

No finish_reason, no [DONE], 2 pending tool calls (last JSON truncated mid-key). Same as opencode#40888 observed response.created then HTTP 502 / stream termination during tool call.

Screenshots and supporting files

No screenshots — error is in proxy log / SSE stream. Can provide curl SSE capture or ocx --debug trace on request.

Redacted configuration

{
  "port": 10100,
  "providers": {
    "opencode-go": {
      "adapter": "openai-chat",
      "baseUrl": "https://opencode.ai/zen/go/v1",
      "authMode": "key"
    }
  }
}

Catalog entry (~/.opencodex/catalog-backup.json):

{ "slug": "muse-spark-1.2", "provider": "opencode-go" }

Related upstream reports (same error family):

  • anomalyco/opencode#40888 — exact same string, stream:false workaround works
  • anomalyco/opencode#18108finishReason: length doom loop, OUTPUT_TOKEN_MAX=32000
  • anomalyco/opencode#26170 / #26177 / #13102 — truncated tool variants
  • zosmaai/zosma-cowork#329mimo-v2.5 via opencode-go orphaned running
  • can1357/oh-my-pi#5600 / earendil-works/pi#4433 / pi#6019 / pi#6133

Checks

  • I searched existing issues and documentation.
  • I removed secrets, tokens, account details, request credentials, and personal data.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcliCLI, config inject, packaging flagsneeds-infoWaiting on reporter for a concrete spec or reproductionproviderProvider adapters, OpenAI-compat presets, upstream API quirksstreamingSSE, WebSocket, terminal stream framestoolstool_calls, MCP, web-search / sidecar tools

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions