Skip to content

Get up and running with Kimi, GLM, MiniMax, DeepSeek, gpt-oss, Qwen, Gemma and other models.

openai: always provide reasoning

Devon Rifkin735c41f9ca38
diff --git a/openai/openai.go b/openai/openai.go
index 17ef6e82d..50fdb81e9 100644
--- a/openai/openai.go
+++ b/openai/openai.go
@@ -478,6 +478,7 @@ func fromChatRequest(r ChatCompletionRequest) (*api.ChatRequest, error) {
if toolName != "" {
messages[len(messages)-1].ToolName = toolName
}
+ messages[len(messages)-1].Thinking = msg.Reasoning
}
default:
// content is only optional if tool calls are present
@@ -493,7 +494,7 @@ func fromChatRequest(r ChatCompletionRequest) (*api.ChatRequest, error) {
return nil, errors.New("invalid tool call arguments")
}
}
- messages = append(messages, api.Message{Role: msg.Role, ToolCalls: toolCalls})
+ messages = append(messages, api.Message{Role: msg.Role, Thinking: msg.Reasoning, ToolCalls: toolCalls})
}
}
diff --git a/openai/openai_test.go b/openai/openai_test.go
index 830571351..0d7f016ba 100644
--- a/openai/openai_test.go
+++ b/openai/openai_test.go
@@ -274,6 +274,83 @@ func TestChatMiddleware(t *testing.T) {
Stream: &False,
},
},
+ {
+ name: "chat handler with tools and empty content",
+ body: `{
+ "model": "test-model",
+ "messages": [
+ {"role": "user", "content": "What's the weather like in Paris Today?"},
+ {"role": "assistant", "content": "", "tool_calls": [{"id": "id", "type": "function", "function": {"name": "get_current_weather", "arguments": "{\"location\": \"Paris, France\", \"format\": \"celsius\"}"}}]}
+ ]
+ }`,
+ req: api.ChatRequest{
+ Model: "test-model",
+ Messages: []api.Message{
+ {
+ Role: "user",
+ Content: "What's the weather like in Paris Today?",
+ },
+ {
+ Role: "assistant",
+ ToolCalls: []api.ToolCall{
+ {
+ Function: api.ToolCallFunction{
+ Name: "get_current_weather",
+ Arguments: map[string]any{
+ "location": "Paris, France",
+ "format": "celsius",
+ },
+ },
+ },
+ },
+ },
+ },
+ Options: map[string]any{
+ "temperature": 1.0,
+ "top_p": 1.0,
+ },
+ Stream: &False,
+ },
+ },
+ {
+ name: "chat handler with tools and thinking content",
+ body: `{
+ "model": "test-model",
+ "messages": [
+ {"role": "user", "content": "What's the weather like in Paris Today?"},
+ {"role": "assistant", "reasoning": "Let's see what the weather is like in Paris", "tool_calls": [{"id": "id", "type": "function", "function": {"name": "get_current_weather", "arguments": "{\"location\": \"Paris, France\", \"format\": \"celsius\"}"}}]}
+ ]
+ }`,
+ req: api.ChatRequest{
+ Model: "test-model",
+ Messages: []api.Message{
+ {
+ Role: "user",
+ Content: "What's the weather like in Paris Today?",
+ },
+ {
+ Role: "assistant",
+ Thinking: "Let's see what the weather is like in Paris",
+ ToolCalls: []api.ToolCall{
+ {
+ Function: api.ToolCallFunction{
+ Name: "get_current_weather",
+ Arguments: map[string]any{
+ "location": "Paris, France",
+ "format": "celsius",
+ },
+ },
+ },
+ },
+ },
+ },
+ Options: map[string]any{
+ "temperature": 1.0,
+ "top_p": 1.0,
+ },
+ Stream: &False,
+ },
+ },
{
name: "tool response with call ID",
body: `{