Fix reasoning_content error in tool calls for kimi-k2.5 and other thinking models

This commit is contained in:
jdhxyy 2026-02-27 20:28:42 +08:00
parent 29d4019e62
commit b33929fd13
2 changed files with 15 additions and 8 deletions

5
.gitignore vendored
View file

@ -12,6 +12,11 @@ build/
/picoclaw-test /picoclaw-test
cmd/**/workspace cmd/**/workspace
# Go debug binaries (created by VS Code Go extension)
__debug_bin
__debug_bin.exe
__debug_bin*
# Picoclaw specific # Picoclaw specific
# PicoClaw # PicoClaw

View file

@ -284,10 +284,11 @@ func parseResponse(body []byte) (*LLMResponse, error) {
// It mirrors protocoltypes.Message but omits SystemParts, which is an // It mirrors protocoltypes.Message but omits SystemParts, which is an
// internal field that would be unknown to third-party endpoints. // internal field that would be unknown to third-party endpoints.
type openaiMessage struct { type openaiMessage struct {
Role string `json:"role"` Role string `json:"role"`
Content string `json:"content"` Content string `json:"content"`
ToolCalls []ToolCall `json:"tool_calls,omitempty"` ReasoningContent string `json:"reasoning_content,omitempty"`
ToolCallID string `json:"tool_call_id,omitempty"` ToolCalls []ToolCall `json:"tool_calls,omitempty"`
ToolCallID string `json:"tool_call_id,omitempty"`
} }
// stripSystemParts converts []Message to []openaiMessage, dropping the // stripSystemParts converts []Message to []openaiMessage, dropping the
@ -297,10 +298,11 @@ func stripSystemParts(messages []Message) []openaiMessage {
out := make([]openaiMessage, len(messages)) out := make([]openaiMessage, len(messages))
for i, m := range messages { for i, m := range messages {
out[i] = openaiMessage{ out[i] = openaiMessage{
Role: m.Role, Role: m.Role,
Content: m.Content, Content: m.Content,
ToolCalls: m.ToolCalls, ReasoningContent: m.ReasoningContent,
ToolCallID: m.ToolCallID, ToolCalls: m.ToolCalls,
ToolCallID: m.ToolCallID,
} }
} }
return out return out