Skip to content

fix: 修复 kimi-for-coding 开启思考模式无法回复的问题#7658

Closed
Blueteemo wants to merge 5 commits intoAstrBotDevs:masterfrom
Blueteemo:fix/reasoning-content-empty-completion
Closed

fix: 修复 kimi-for-coding 开启思考模式无法回复的问题#7658
Blueteemo wants to merge 5 commits intoAstrBotDevs:masterfrom
Blueteemo:fix/reasoning-content-empty-completion

Conversation

@Blueteemo
Copy link
Copy Markdown
Contributor

@Blueteemo Blueteemo commented Apr 18, 2026

问题描述

当使用 kimi-for-coding 模型开启思考模式(adaptive/思考预算0/思考深度Low)时,用户无法收到回复,控制台显示有思考内容但无报错。

根因分析

tool_loop_agent_runner.py 中,最终结果的 yield 逻辑只检查了 result_chaincompletion_text,没有处理仅有 reasoning_content 的情况。当模型仅返回思考内容而 completion_text 为空时,最终响应不会发送给用户。

修复方案

在以下两处添加对 reasoning_content 的分支处理:

  1. 主逻辑 (721-739行)
  2. skills_like fallback (754-767行)

completion_text 为空但 reasoning_content 有值时,将 reasoning_content 作为 fallback 返回给用户。

Related Issue

Fixes #7656

Summary by Sourcery

Bug Fixes:

  • Return reasoning content as a fallback response when completion text is empty so users still receive replies in thinking mode.

@auto-assign auto-assign Bot requested review from advent259141 and anka-afk April 18, 2026 23:05
@dosubot dosubot Bot added size:S This PR changes 10-29 lines, ignoring generated files. area:provider The bug / feature is about AI Provider, Models, LLM Agent, LLM Agent Runner. labels Apr 18, 2026
Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've left some high level feedback:

  • Consider extracting the shared llm_result yielding logic for completion_text / reasoning_content into a small helper to avoid duplicating the same AgentResponse construction in multiple branches.
  • Double-check that exposing reasoning_content directly to end users is acceptable for all calling contexts, as it may contain internal chain-of-thought or debugging details that were previously intentionally not surfaced.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Consider extracting the shared `llm_result` yielding logic for `completion_text` / `reasoning_content` into a small helper to avoid duplicating the same `AgentResponse` construction in multiple branches.
- Double-check that exposing `reasoning_content` directly to end users is acceptable for all calling contexts, as it may contain internal chain-of-thought or debugging details that were previously intentionally not surfaced.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds support for handling reasoning content in the tool loop agent runner by yielding an AgentResponse when reasoning_content is present. The reviewer suggests explicitly setting the MessageChain type to "reasoning" in both new logic paths to maintain consistency with streaming output and facilitate better UI representation of the thinking process.

Comment thread astrbot/core/agent/runners/tool_loop_agent_runner.py Outdated
Comment thread astrbot/core/agent/runners/tool_loop_agent_runner.py Outdated
@dosubot dosubot Bot added size:M This PR changes 30-99 lines, ignoring generated files. and removed size:S This PR changes 10-29 lines, ignoring generated files. labels Apr 18, 2026
@Blueteemo Blueteemo force-pushed the fix/reasoning-content-empty-completion branch from a0d72eb to 3c02c8b Compare April 19, 2026 02:58
@dosubot dosubot Bot added size:S This PR changes 10-29 lines, ignoring generated files. size:M This PR changes 30-99 lines, ignoring generated files. and removed size:M This PR changes 30-99 lines, ignoring generated files. size:S This PR changes 10-29 lines, ignoring generated files. labels Apr 19, 2026
@dosubot dosubot Bot added size:S This PR changes 10-29 lines, ignoring generated files. and removed size:M This PR changes 30-99 lines, ignoring generated files. labels Apr 19, 2026
@dosubot dosubot Bot added size:M This PR changes 30-99 lines, ignoring generated files. and removed size:S This PR changes 10-29 lines, ignoring generated files. labels Apr 19, 2026
@Soulter Soulter force-pushed the master branch 2 times, most recently from faf411f to 0068960 Compare April 19, 2026 09:50
@Blueteemo Blueteemo closed this Apr 21, 2026
@Blueteemo Blueteemo deleted the fix/reasoning-content-empty-completion branch April 22, 2026 01:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:provider The bug / feature is about AI Provider, Models, LLM Agent, LLM Agent Runner. size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug?]kimi-for-coding 开启思考模式无法回复

1 participant