[Bug] GLM-5.2 Cloud returns empty responses (no content, no reasoning) on complex prompts — agent frameworks dead in the water

用户通过 Ollama Cloud API 端点 https://ollama.com/v1/chat/completions 调用 glm-5.2 模型,使用代理框架(如 Hermes Agent, OpenHands)发送完整工具调用上下文(8K token 系统提示 + 约40个工具 sche

[Bug] GLM-5.2 Cloud returns empty responses (no content, no reasoning) on complex prompts — agent frameworks dead in the water

[Bug] GLM-5.2 Cloud returns empty responses (no content, no reasoning) on complex prompts — agent frameworks dead in the water

快速结论:此报错发生在通过 Ollama Cloud 调用 glm-5.2 模型时,复杂提示词(如大型系统提示、工具 schema、对话历史)导致模型返回空内容(content: "", reasoning: "")且 HTTP 200 无错误。优先排查本地的 num_predict(token 配额)设置是否过小或缺失。

问题场景

用户通过 Ollama Cloud API 端点 https://ollama.com/v1/chat/completions 调用 glm-5.2 模型,使用代理框架(如 Hermes Agent, OpenHands)发送完整工具调用上下文(8K token 系统提示 + 约40个工具 schema + 对话历史)时,出现持续的空响应。简单提示词(如 {"content":"hi"})正常返回。

报错原文


2026-07-09 07:09:59 Empty response (no content or reasoning) — retry 1/3 (model=glm-5.2)
2026-07-09 07:10:38 Empty response (no content or reasoning) — retry 2/3 (model=glm-5.2)
2026-07-09 07:10:54 Empty response (no content or reasoning) — retry 3/3 (model=glm-5.2)
2026-07-09 07:11:22 Empty response after 3 retries. No fallback available. model=glm-5.2 provider=ollama-cloud

HTTP 200 响应体示例:{"choices":[{"message":{"role":"assistant","content":"","reasoning":""}}]}

原因分析

根据 Issue 讨论链的最终结论,根本原因是本地 Ollama 服务配置中的 num_predict(token 配额)缺失或设置过低。当模型处理包含大量 system prompt、工具 schema 的长上下文时,glm-5.2 的推理/思考阶段会在输出 token 预算耗尽之前就终止,导致生成为空(content 和 reasoning 均为空)。简单请求因 token 消耗少而正常通过。

注意:虽然 Issue 最初怀疑是 Ollama 云端后端问题(类似 #15453 的 502/503 空响应),且其他用户报告出现相同症状但无配置更改,但 Issue 关闭者认定这是用户侧配置错误。

环境排查

  • 确认本地 Ollama 服务配置:检查 num_predict(或等效参数,如 max_tokens)是否被设置,以及其具体数值。
  • 确认模型与客户端:模型 glm-5.2,客户端为直接调用 Ollama Cloud API(base_url: https://ollama.com/v1),非本地代理。
  • 测试简单提示词:使用简短 curl 命令验证 API 密钥和基础连接是否正常。
  • 对比测试:使用相同提示词切换至另一模型(如 kimi-k2.6)看是否正常,以排除客户端或网络问题。

解决步骤

  1. 检查并显式设置 token 配额:在 Ollama 服务配置(如 modelfile 或 API 调用参数)中,为 glm-5.2 明确设置一个足够高的 num_predict 值(例如 4096、8192 或更大),确保输出 token 预算在复杂推理场景下不被过早耗尽。
  2. 验证配置文件:确认 num_predict 未被意外设置为 0 或一个极小的数字。
  3. 重启 Ollama 服务:应用配置更改后,重启本地 Ollama 服务,使新参数生效。
  4. 重新测试复杂请求:使用导致失败的完整 prompt(含 system prompt、工具 schema、历史记录)重新发送请求,观察是否返回内容。

验证方法

再次运行报错原文中的 Hermes 日志程序或发送带有完整上下文的多轮请求,确认不再出现 Empty response (no content or reasoning) 日志行,且 contentreasoning 字段包含非空文本。

参考来源

ollama/ollama #17097

GamsGo AI

AI 工具推荐

想把多个 AI 模型放在一个入口?

GamsGo AI 集成 ChatGPT、DeepSeek、Gemini、Claude、Midjourney、Veo 等常用模型,适合写作、绘图、视频和日常 AI 工作流。

了解 GamsGo AI

推广链接:通过此链接购买,我可能获得佣金,不影响你的价格。

celebrityanime
celebrityanime
文章: 12175

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注