From 53ddf35b78372af35fe5ebb6e6c8a287ae5b5aab Mon Sep 17 00:00:00 2001 From: mxrain Date: Sun, 15 Feb 2026 11:38:28 +0800 Subject: [PATCH] fix: preserve ReasoningContent in toolloop for thinking models MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When using thinking models (e.g., Kimi K2.5), the API requires all assistant messages with tool calls to include reasoning_content. This field was missing in RunToolLoop, causing subagent failures with the error: 已启用思考功能,但索引2处的助手工具调用消息中缺少推理内容 Aligns toolloop.go with the existing handling in agent/loop.go. --- pkg/tools/toolloop.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/tools/toolloop.go b/pkg/tools/toolloop.go index 1302079b4..e63361342 100644 --- a/pkg/tools/toolloop.go +++ b/pkg/tools/toolloop.go @@ -97,8 +97,9 @@ func RunToolLoop(ctx context.Context, config ToolLoopConfig, messages []provider // 6. Build assistant message with tool calls assistantMsg := providers.Message{ - Role: "assistant", - Content: response.Content, + Role: "assistant", + Content: response.Content, + ReasoningContent: response.ReasoningContent, // Preserve for thinking models (e.g., GLM-Z1) } for _, tc := range response.ToolCalls { argumentsJSON, _ := json.Marshal(tc.Arguments)