Skip to content

Bug: Incomplete JSON stream in OpenCode using gpt-5.3-codex (Unterminated string) #20599

Closed as not planned

Description

@deretame

Description

Description / 问题描述

[CN] 在使用 OpenCode 配合 gpt-5.3-codex 模型时,偶尔会遇到 JSON 解析失败的情况。
[EN] Occasional JSON parsing failures occur when using OpenCode with the gpt-5.3-codex model.

[CN] 报错信息显示为 JSON Parse error: Unterminated string,通常发生在模型尝试调用工具(Tools)或解析复杂上下文时。
[EN] The error message JSON Parse error: Unterminated string appears, typically when the model attempts tool-calls or processes complex contexts.


Actual Behavior / 实际现象

  1. [CN] AI 响应中途停止,界面弹出原始日志。
    [EN] AI response stops mid-way, and raw logs are displayed on the UI.
  2. [CN] 日志显示 JSON 在传输过程中被截断(例如在 tools 定义部分)。
    [EN] Logs show the JSON payload is truncated during streaming (e.g., within the tools definition).

Environment / 环境

  • Model: gpt-5.3-codex
  • Platform: OpenCode-web

Repository / 项目仓库

  • Link: https://github.com/deretame/async_uv
  • Context: This is an open-source project. The issue occurs frequently when Codex tries to index or analyze the root directory of this repository.
    (这是一个开源项目。当 Codex 尝试索引或分析该仓库的根目录时,此问题频繁发生。)
// --- [LOG START: METADATA RETAINED] ---
{
  "type": "response.created",
  "response": {
    "id": "resp_029c556764108ed40169cddc15a8b481919f76008087e8f49a",
    "model": "gpt-5.3-codex",
    "status": "in_progress",
    "parallel_tool_calls": true,
    "safety_identifier": "user-p1NpZeckCsXyN2GZOfJyhtLI",
    "tools": [
      {
        "type": "function",
        "name": "question",
        "description": "Use this tool when you need to ask the user questions..."
        // ... (full schema for 'question' retained)
      },
      {
        "type": "function",
        "name": "bash",
        "description": "Executes a given bash command in a persistent shell session...",
        "parameters": {
          "type": "object",
          "properties": {
            "command": { "type": "string" },
            "workdir": { "default": "/home/windy/pack/async_uv" }
          }
        }
      },
      
      // --- [STRATEGIC TRUNCATION: 15+ TOOLS REMOVED TO FIT 64KB LIMIT] ---
      
      {
        "type": "function",
        "name": "context7_query-docs",
        "description": "Retrieves and queries up-to-date documentation..."
      }
    ]
  }
}

// --- [CRITICAL ERROR AT THE END OF STREAM] ---
// JSON parsing failed: Text: {"type":"response
// Error message: JSON Parse error: Unterminated string

Plugins

none

OpenCode version

1.3.13 web

Steps to reproduce

## Steps to Reproduce / 复现步骤

[EN] This issue occurs frequently (intermittently) during normal usage.
[CN] 此问题在日常使用中非常高频(且具有一定的随机性)。

  1. Open a project with many files (e.g., my async_uv workspace).
    打开一个包含较多文件的项目(例如我的 async_uv 工作区)。
  2. Upload an image or provide a complex prompt that triggers Codex tool-calls (e.g., "Analyze this image").
    上传一张图片或输入复杂的指令,触发 Codex 的工具调用逻辑(例如:“解析这张图”)。
  3. Wait for the streaming response.
    等待流式响应输出。
  4. Result: The response often halts mid-stream, popping up the JSON Parse error.
    结果: 响应经常在传输中途断开,并弹出 JSON 解析错误。

Screenshot and/or share link

https://opncd.ai/share/IgyV5Okb

Operating System

PRETTY_NAME="Debian GNU/Linux 13 (trixie)" NAME="Debian GNU/Linux" VERSION_ID="13" VERSION="13 (trixie)" VERSION_CODENAME=trixie DEBIAN_VERSION_FULL=13.4 ID=debian HOME_URL="https://www.debian.org/" SUPPORT_URL="https://www.debian.org/support" BUG_REPORT_URL="https://bugs.debian.org/"

Terminal

Windows Terminal, wsl2, fish

Activity

  1. github-actions commented on Apr 2, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    Please review the above issues to see if your problem is already being tracked, and consider adding your findings there if so.

  2. Seraphtai commented on Apr 2, 2026

    @Seraphtai

    +1

  3. removed
    bugSomething isn't working
    webRelates to opencode on web / desktop
    on May 3, 2026
  4. EnderLiquid commented on May 9, 2026

    @EnderLiquid

    I reproduced this issue across all three terminal environments within Windows Terminal — PowerShell 5.1, PowerShell 7, and Git Bash — while using OpenCode version 1.14.41's TUI and calling the gpt-5.3-codex / gpt-5.4 models via the OpenAI Responses API format.

    I created a branch based on 1.14.41, merged PR #24289 , built and tested it locally, but the issue was not mitigated.

  5. menardorama commented on May 10, 2026

    @menardorama

    I reproduced this issue across all three terminal environments within Windows Terminal — PowerShell 5.1, PowerShell 7, and Git Bash — while using OpenCode version 1.14.41's TUI and calling the gpt-5.3-codex / gpt-5.4 models via the OpenAI Responses API format.

    I created a branch based on 1.14.41, merged PR #24289 , built and tested it locally, but the issue was not mitigated.

    FYI I just tested my PR against got-5.3 codex and it works without any errors

  6. github-actions commented on Jul 10, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

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

Metadata

Metadata

Assignees

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