Skip to content

Commit 8a25cd9

Browse files
intel352claude
andcommitted
fix: handle reasoning_content for Qwen3.5 and similar models
fromOpenAIResponse now extracts reasoning_content from ExtraFields when content is empty (reasoning models put output there). Also increase default max_tokens to 8192 for reasoning models. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent e507e72 commit 8a25cd9

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

provider/llama_cpp.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const (
1717
defaultLlamaCppPort = 8081
1818
defaultLlamaCppGPULayers = -1
1919
defaultLlamaCppContextSize = 8192
20-
defaultLlamaCppMaxTokens = 4096
20+
defaultLlamaCppMaxTokens = 8192
2121
)
2222

2323
// LlamaCppConfig holds configuration for the LlamaCpp provider.

provider/openai_convert.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,16 @@ func fromOpenAIResponse(resp *openaisdk.ChatCompletion) (*Response, error) {
8181
}
8282
msg := resp.Choices[0].Message
8383
result.Content = msg.Content
84+
// For reasoning models (Qwen3.5, etc.) that put output in reasoning_content
85+
// instead of content, extract it from the raw JSON extra fields.
86+
if result.Content == "" {
87+
if rc, ok := msg.JSON.ExtraFields["reasoning_content"]; ok && rc.Valid() {
88+
var reasoning string
89+
if err := json.Unmarshal([]byte(rc.Raw()), &reasoning); err == nil && reasoning != "" {
90+
result.Content = reasoning
91+
}
92+
}
93+
}
8494
for _, tc := range msg.ToolCalls {
8595
var args map[string]any
8696
if tc.Function.Arguments != "" {

0 commit comments

Comments
 (0)