ai: openai-compatible-chat rejects reasoning delivered as an encrypted object (Iceman)

Đang mở Phù hợp với người mới
#61,512 2 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@rsdenck đang làm issue này rồi.

Từ ngày 5/11/2026.

  • #1 của @rsdenck — đã đóng, không merge
  • #61959 của @rsdenck — đang mở

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
75/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
typescript
Lĩnh vực
api, backend

Hướng nghiên cứu

Issue chỉ đến packages/ai/src/protocols/openai-chat.ts, nơi schema của stream hiện yêu cầu reasoning là một chuỗi. Hãy bắt đầu bằng cách đọc schema đó và cách xử lý reasoning_details; tái hiện lỗi với một chunk được truyền trực tuyến có delta.reasoning là một object. Bản sửa được hoàn tất khi cấu trúc reasoning đã mã hóa không còn làm gián đoạn lượt và stream hoàn tất.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

reproduced

Summary

When opencode-go/iceman-contributor-free streams encrypted reasoning, it sends choices[].delta.reasoning as a JSON object ({content, encrypted_content, summary}) instead of a string. The OpenAI-compatible Chat schema requires a string, so the whole turn fails with AI.Error.InvalidProviderOutput: Invalid opencode-go/openai-compatible-chat stream event. Plain turns succeed, which makes the failure look intermittent.

Environment

  • opencode version: 2.1.4 (npm @opencode/cli, latest channel; 2.2.5 also affected — see below)
  • OS: Windows 10.0.19045.7663 (win32 x64)
  • Terminal: TERM=xterm-256color (terminal app not reported)
  • Shell: bash (Git for Windows)
  • Install/channel: global npm install, release
  • Active plugins: none

Reproduction

  1. POST to https://opencode.ai/inference/go/openai/v1/chat/completions with model: iceman-contributor-free, stream: true, one function tool, and a prompt that triggers a tool call.

  2. The streamed chunk that carries the tool call looks like this:

    {
      "choices": [
        {
          "index": 0,
          "delta": {
            "role": "assistant",
            "content": null,
            "reasoning": {
              "content": null,
              "encrypted_content": "gAAAA...",
              "summary": null
            },
            "tool_calls": [
              { "id": "call_...", "type": "function", "function": { "name": "...", "arguments": "..." } }
            ]
          },
          "finish_reason": "tool_calls"
        }
      ],
      "object": "chat.completion.chunk"
    }
    
  3. Select the same model in the TUI and send a prompt that makes the model think before answering or calling a tool.

Expected Behavior

The parser should tolerate this shape — map encrypted_content / summary into reasoning details (as it already does for reasoning_details) or ignore unsupported fields — and the turn should complete.

Actual Behavior

The turn aborts with:

AI.Error: Invalid opencode-go/openai-compatible-chat stream event

and the session fails to drain, producing no response. Relevant log line:

timestamp=2026-11-03T22:48:55.264Z level=ERROR message="Failed to drain Session" cause="AI.Error: Invalid opencode-go/openai-compatible-chat stream event ..."

Additional Context

  • Schema in packages/ai/src/protocols/openai-chat.ts still requires a string:

    reasoning: optionalNull(Schema.String),
    

    I checked this on v2.2.5 and on dev; upgrading from 2.1.4 does not fix it.

  • Frequency: intermittent. Turns without an encrypted reasoning delta succeed; turns that stream the object fail. Same model, same session, minutes apart.

  • Workaround: switch to a different model.

  • Related (not duplicates): #40690 (tool-call stream validation), #37553 / #35283 (delta.reasoning as a string being dropped, now handled).

Ngôn ngữ chính
TypeScript
Star
224k
Fork
30k
Merge trung bình
6 giờ 16 phút
Pull request đã merge (30 ngày)
507

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của anomalyco/opencode

Tất cả issue của anomalyco/opencode

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.