CommandCodeAI / CommandCodeAI/command-code

BYOK: reasoning_content gets dropped from history, breaks multi-turn calls to thinking-mode models (400 Invalid_request_error)

Đang mở
#877 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

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

Ngôn ngữ chính
Không có dữ liệu ngôn ngữ
Star
4k
Fork
350
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

Summary

Using a custom BYOK provider in ~/.commandcode/providers.json (plain openai-compatible wire type) pointed at a thinking-mode model (DeepSeek V4 Flash, GLM 5.3), a session works fine at first. At some point later in the same conversation, once the assistant's previous turn involved real generation and has to be sent back as history, it fails with:

Error: 400 Invalid_request_error The reasoning_content in the thinking mode must be passed back to the API.

What's actually happening

These models return both content and reasoning_content on the assistant message, e.g.:

{
"message": {
"role": "assistant",
"content": "pong",
"reasoning_content": "The user wants the single word "pong". Simple."
}
}

Their API requires reasoning_content to be sent back exactly as received when that message is replayed as history on a later turn. Command Code's client only seems to keep content when it rebuilds the assistant turn for the next request, so reasoning_content gets dropped and the upstream model rejects the call.

Verified this isn't the proxy

I run a small local reverse proxy in front of the provider (plain byte passthrough, forwards request bodies and streamed responses unmodified, only touches headers and drops stray literal null SSE events). To rule it out, I added a temporary log line right where it reads the incoming request body, before anything else happens to it, and drove two turns through Command Code:

[debug] /v1/chat/completions body has reasoning_content=False len=71435 (turn 1, no history yet, expected)
[debug] /v1/chat/completions body has reasoning_content=False len=71537 (turn 2, has history, still missing)

reasoning_content is already absent from the request body the moment it reaches the proxy. Since the proxy never parses or rewrites request bodies, this confirms the client drops it before the request is even sent.

One nuance: a two-turn test with short, trivial answers ("say the word alpha" / "now say beta") went through fine, no error. The failure only showed up after a turn where the model actually generated real output (in my case, a chunk of code). So the upstream seems to only enforce the reasoning_content requirement when the prior turn did substantial reasoning, not on every second turn.

Steps to reproduce

  1. Add a BYOK provider pointed at any OpenAI-compatible endpoint running a thinking-mode model that returns reasoning_content (DeepSeek's own API reproduces this directly, no third party needed).
  2. Start an interactive cmdc session on that model.
  3. Ask it to do something that requires actual generation (write some code, explain something at length).
  4. Send a follow-up in the same conversation.
  5. Get the 400 above.

Expected behavior

reasoning_content should be kept and sent back with content when a prior assistant turn is replayed, same as content already is.

Environment

  • Command Code 1.54.2
  • Windows 11 Pro (10.0.22631)
  • BYOK, openai-compatible wire type
  • Models: deepseek-v4-flash, glm-5.3
  • Trace IDs: 634363e49a74aecf70b17642bd756acc, e362e38e22b160d3f0464663323079c1

Workaround

Switching to a model on the same provider that doesn't return reasoning_content (a Claude or GPT-class model) avoids it, since there's nothing to replay.

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

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.

Hướng nghiên cứu

Bắt đầu từ đường dẫn yêu cầu BYOK tương thích với openai, nơi xây dựng các body cho /v1/chat/completions, bằng cách sử dụng ~/.commandcode/providers.json và bản tái hiện nhiều lượt đã cung cấp. Công việc được xem là hoàn tất khi reasoning_content trong phản hồi của một assistant được giữ lại trong yêu cầu tiếp theo cùng với content, để các mô hình ở chế độ suy luận không còn trả về 400 đã được báo cáo.

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

Đánh giá

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

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.