Skip to content

[Bug] Agent 连续工具调用后 tool_choice=none,但响应仍为 finish_reason=tool_calls,最终报 LLM_model_response_empty #7339

Description

@Mrxia7757
  • 我已确认目前没有类似 issue
  • 我已完整查看过项目 README,以及项目文档
  • 我使用了自己的 key,并确认我的 key 是可正常使用的
  • 我理解并愿意跟进此 issue,协助测试和提供反馈
  • 我理解并认可上述内容,并理解项目维护者精力有限,不遵循规则的 issue 可能会被无视或直接关闭

说明:已检索到 #4764 等同样包含 chat:LLM_model_response_empty 的 Issue,但没有发现描述以下特定组合状态的 Issue:

  • FastGPT 请求中 tool_choice 已被设置为 none
  • 模型响应的 finish_reason 仍为 tool_calls
  • 实际没有返回有效 tool_calls
  • 没有返回正文,但返回了非空 reasoning 内容

因此提交本 Issue 补充具体复现条件和源码定位结果。

你的版本

  • 公有云版本
  • 私有部署版本, 具体版本号:
    • FastGPT: v4.15.2
    • FastGPT Pro: v4.15.2
    • AIProxy: v0.6.5

问题描述, 日志截图,配置文件等

在工作流的“工具调用”节点中,模型连续多轮仅返回工具调用、未返回最终回答。

FastGPT v4.15.2 的 Agent Loop 在连续工具调用超过 5 次后,会在下一次请求中将:

tool_choice: consecutiveRequestToolTimes > 5 ? 'none' : 'auto'

因此强制收尾请求中的关键参数为:

{
  "tool_choice": "none"
}

但该请求完成后出现了以下不一致状态:

{
  "finish_reason": "tool_calls",
  "toolCalls": [],
  "answerText": "",
  "reasoningText": "<non-empty>",
  "error": "chat:LLM_model_response_empty"
}

也就是:

  1. 请求已经通过 tool_choice: "none" 禁止继续调用工具;
  2. 响应的 finish_reason 仍然是 tool_calls
  3. 实际没有返回有效的 tool_calls
  4. 没有正文内容;
  5. 有 reasoning 内容;
  6. FastGPT 最终报错 chat:LLM_model_response_empty

模型配置页面测试正常,普通对话正常,前面的工具调用也能正常执行。问题只出现在连续工具调用达到 FastGPT 强制回答阈值后的收尾请求。

上游使用 OpenAI-compatible 接口,模型支持 reasoning 和 function/tool calling。由于涉及内部部署信息,此处未公开模型别名、接口地址、业务提示词、工具名称和业务源码;如维护者需要,可以继续提供脱敏后的原始流式响应或最小复现工作流。

复现步骤

可使用不包含任何业务代码的最小工作流复现:

  1. 私有部署 FastGPT v4.15.2,并通过 AIProxy v0.6.5 接入支持 reasoning 和 tool calling 的 OpenAI-compatible 模型。
  2. 新建一个工具调用节点。
  3. 配置一个无副作用的测试工具,例如固定返回:
{
  "ok": true
}
  1. 在系统提示词中要求模型连续调用该工具获取多段证据,在证据不足时继续调用工具。

  2. 使模型连续超过 5 轮只返回工具调用,不返回普通 answer content。

  3. 观察下一轮请求,FastGPT 会将 tool_choice 设置为 none

  4. 如果上游返回:

    • finish_reason: "tool_calls"
    • 无有效 tool_calls
    • 无 answer content
    • 仅有 reasoning content
  5. FastGPT 工作流报错:

chat:LLM_model_response_empty

预期结果

FastGPT 应对该不一致响应做明确处理,而不是仅返回通用的空响应错误。

建议至少采用以下一种处理方式:

  1. 当请求中的 tool_choicenone,但响应为 finish_reason: "tool_calls" 且没有有效 tool_calls 时,识别为模型协议异常,并返回明确错误信息;

  2. 自动重试一次,继续使用 tool_choice: "none",并明确要求模型输出最终文本;

  3. 如果 reasoning 内容非空,可将该状态记录为协议异常,而不是简单判定为完全空响应;

  4. 日志中明确记录:

    • 请求时的 tool_choice
    • 返回的 finish_reason
    • 是否存在有效 tool_calls
    • answer content 长度
    • reasoning content 长度
    • 上游原始 finish reason
  5. 避免将这种不一致状态仅归类为:

chat:LLM_model_response_empty

因为该错误不能区分:

  • 上游真正返回空内容;
  • 流式解析丢失工具调用;
  • AIProxy 协议转换异常;
  • 模型在 tool_choice: none 下仍错误结束为 tool_calls

相关截图

为避免公开内部信息,目前仅计划上传以下脱敏截图:

  1. FastGPT 版本信息;

  2. 工作流错误 chat:LLM_model_response_empty

  3. 脱敏后的请求摘要,显示 tool_choice: "none"

  4. 脱敏后的响应摘要,显示:

    • finish_reason: "tool_calls"
    • toolCalls: []
    • answerText 为空
    • reasoningText 非空;
  5. 官方 v4.15.2 镜像 Source Map 中以下逻辑的截图:

tool_choice: consecutiveRequestToolTimes > 5 ? 'none' : 'auto'

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions