opencode icon indicating copy to clipboard operation
opencode copied to clipboard

[Bug] JSON Parse Error with Zhipu GLM-4.7: Stream chunks are concatenated incorrectly

Open yangshenlong opened this issue 5 days ago • 7 comments

Description

Description: I encountered a JSON Parse Error when using the Zhipu GLM-4.7 model. It seems like the stream parser fails to handle the boundary between two data chunks correctly, leading to invalid JSON.

The Error: The error message shows that the end of the previous message and the start of the next data: chunk are stuck together without proper separation.

Error Log / Evidence:

AI_JSONParseError: JSON parsing failed: Text: ... "role":"assistant"data: {"id": ... Error message: JSON Parse error: Expected '}'

As seen in the log, the string "role":"assistant" is immediately followed by data:, missing the closing brace } and likely a newline character.

Environment:

Model: Zhipu GLM-4.7 (configured via zhipu/glm-4.7)

Plugin: OMO / OpenCode

Image

Plugins

Z.ai/GLM-4.7 ; OhMyOpencode

OpenCode version

1.0.152

Steps to reproduce

  1. Configure the OMO plugin to use Zhipu GLM-4.7 as the default model for the 'Sisyphus' agent (or set it in the model configuration).
  2. Open the OMO interface and select the 'Sisyphus' mode.
  3. Input a task to trigger the agent (e.g., "Analyze this project" or "Write a simple snake game").
  4. Wait for the model to start streaming the response.
  5. The AI_JSONParseError occurs immediately when the model returns a response, interrupting the stream.

Screenshot and/or share link

No response

Operating System

window11

Terminal

WindowsTerminal in Trae

yangshenlong avatar Jan 10 '26 19:01 yangshenlong