Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions changelog/unreleased/qoder-history-reasoning-content.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
### English

- Qoder requests now keep the `reasoning_content` of earlier assistant messages instead of silently dropping it.

### 中文

- Qoder 请求现在会保留历史 assistant 消息中的 `reasoning_content`,不再静默丢弃。
3 changes: 3 additions & 0 deletions internal/providers/qoder/direct.go
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,9 @@ func BuildPlainChatBody(req translate.ChatRequest, now time.Time) map[string]any
if message.ToolCallID != "" {
item["tool_call_id"] = message.ToolCallID
}
if message.ReasoningContent != "" {
item["reasoning_content"] = message.ReasoningContent
}
if len(message.ToolCalls) > 0 {
item["tool_calls"] = json.RawMessage(message.ToolCalls)
}
Expand Down
26 changes: 26 additions & 0 deletions internal/providers/qoder/history_reasoning_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package qoder

import (
"testing"
"time"

"github.com/caigee-cmd/cli2api/internal/translate"
)

// Regression for #330: client-supplied historical reasoning must survive the
// plaintext body rebuild.
func TestBuildPlainChatBodyKeepsHistoricalReasoning(t *testing.T) {
req := translate.ChatRequest{Model: "dfmodel", Messages: []translate.ChatMessage{
{Role: "user", Content: "Use the synthetic snapshot."},
{Role: "assistant", Content: "Snapshot checked.", ReasoningContent: "Synthetic marker: M1"},
{Role: "user", Content: "Continue."},
}}
body := BuildPlainChatBody(req, time.Unix(1, 0))
messages := body["messages"].([]map[string]any)
if got := messages[1]["reasoning_content"]; got != "Synthetic marker: M1" {
t.Fatalf("historical reasoning lost: got %#v", got)
}
if _, ok := messages[0]["reasoning_content"]; ok {
t.Fatalf("empty reasoning_content should be omitted: %#v", messages[0])
}
}
Loading