Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Bug: reasoning_content is replayed in the request history, causing tool-call markup leakage

Đang mở Phù hợp với người mới
#56,352 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

Chưa có ai nhận issue này.

Đá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
66/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

Bắt đầu bằng cách theo dõi cách lịch sử phiên được tổng hợp thành payload yêu cầu gửi đến các nhà cung cấp, sau đó tìm nơi các tin nhắn của trợ lý giữ lại reasoning_content. Kiểm tra xem trường này có được gửi trong các yêu cầu tiếp theo hay không và đường dẫn tạo yêu cầu có kiểm thử cho các mô hình suy luận hay không. Hoàn tất khi lịch sử vẫn có thể giữ lại nội dung suy luận để hiển thị trong khi các yêu cầu lược bỏ nội dung đó, đồng thời có kiểm thử hồi quy bao quát hành vi này.

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

Mô tả

opencode persists the model's reasoning_content (chain-of-thought) in the session history and sends it back in every subsequent request. DeepSeek's API states that reasoning_content is the current turn's CoT and must not be passed back.

Impact: with reasoning models (e.g. deepseek-v4.1-flash), the model imitates patterns from its own past reasoning - including malformed tool-call markup - so tool calls are silently lost (tool_calls == 0, finish_reason == "stop"). It is self-reinforcing: the more it leaks, the more that markup appears in reasoning.

A/B (one captured opencode request, 1011 messages / 4.78 MB, replayed to the same endpoint with a "write a ~120-line script" instruction appended):

variant leak rate
with reasoning_content 4 / 5
without reasoning_content 0 / 5
last 300 msgs, with 2 / 5
last 300 msgs, without 0 / 5

"Leak" is defined strictly as: markup inside delta.content and tool_calls == 0 and finish_reason == "stop".

Observed message structure in the captured request: assistant messages 480, of which reasoning_content present in 480.

Excluded by A/B: max_tokens (256k vs 128k -> 4/5 vs 4/5), system prompt content, temperature, tool_choice, parallel_tool_calls, thinking/reasoning_effort fields, and endpoint (official api.deepseek.com vs the opencode gateway). The dose-response (100 msgs 0/5 -> 300 msgs 2-3/5 -> 1009 msgs 4/5) is fully explained by the replayed CoT.

A different client (CodeBuddy) with the same model and the same real leaked-text corpus in a 1.13 MB history does not reproduce it (0/5).

Suggested fix: do not send reasoning_content back when building the request payload (keep it for UI display only); optionally gate behind a provider/model capability flag.

Reproduction: run a long session with a reasoning model, then ask it to write a long file - occasionally the tool call is emitted as text; re-sending the same request with reasoning_content stripped removes the failure (0/5 vs 4/5).

Environment: opencode 2.0.30 (Windows), providers opencode-go and official deepseek, model deepseek-v4.1-flash (variant max).

Ngôn ngữ chính
TypeScript
Star
215k
Fork
28.9k
Merge trung bình
7 giờ 53 phút
Pull request đã merge (30 ngày)
278

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.