Skip to content

[Bug]频繁报错 LLM 响应错误: All chat models failed: TypeError: object of type 'NoneType' has no len() #6252

@bighamx

Description

@bighamx

What happened / 发生了什么

在使用QQ机器人和agent交流时,时长收到以下信息:
LLM 响应错误: All chat models failed: TypeError: object of type 'NoneType' has no len()
此时查看系统日志,有以下信息:
[2026-03-14 17:36:32.437] [Core] [WARN] [v4.20.0] [runners.tool_loop_agent_runner:268]: Chat Model openrouter/openrouter/hunter-alpha request error: object of type 'NoneType' has no len()
Traceback (most recent call last):
File "C:\Users\chuckie.astrbot_launcher\instances\0459b44f-ec59-4130-ba58-102e49802780\core\astrbot\core\agent\runners\tool_loop_agent_runner.py", line 243, in _iter_llm_responses_with_fallback
async for resp in self._iter_llm_responses(include_model=idx == 0):
File "C:\Users\chuckie.astrbot_launcher\instances\0459b44f-ec59-4130-ba58-102e49802780\core\astrbot\core\agent\runners\tool_loop_agent_runner.py", line 220, in _iter_llm_responses
yield await self.provider.text_chat(**payload)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\chuckie.astrbot_launcher\instances\0459b44f-ec59-4130-ba58-102e49802780\core\astrbot\core\provider\sources\openai_source.py", line 763, in text_chat
) = await self._handle_api_error(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\chuckie.astrbot_launcher\instances\0459b44f-ec59-4130-ba58-102e49802780\core\astrbot\core\provider\sources\openai_source.py", line 714, in _handle_api_error
raise e
File "C:\Users\chuckie.astrbot_launcher\instances\0459b44f-ec59-4130-ba58-102e49802780\core\astrbot\core\provider\sources\openai_source.py", line 751, in text_chat
llm_response = await self._query(payloads, func_tool)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\chuckie.astrbot_launcher\instances\0459b44f-ec59-4130-ba58-102e49802780\core\astrbot\core\provider\sources\openai_source.py", line 264, in _query
llm_response = await self._parse_openai_completion(completion, tools)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\chuckie.astrbot_launcher\instances\0459b44f-ec59-4130-ba58-102e49802780\core\astrbot\core\provider\sources\openai_source.py", line 471, in _parse_openai_completion
if len(completion.choices) == 0:
^^^^^^^^^^^^^^^^^^^^^^^
TypeError: object of type 'NoneType' has no len()

Reproduce / 如何复现?

正常和agent聊天

AstrBot version, deployment method (e.g., Windows Docker Desktop deployment), provider used, and messaging platform used. / AstrBot 版本、部署方式(如 Windows Docker Desktop 部署)、使用的提供商、使用的消息平台适配器

使用launcher部署
4.20.0
Openrouter
QQ机器人

OS

Windows

Logs / 报错日志

[2026-03-14 17:30:39.851] [Core] [INFO] [runners.tool_loop_agent_runner:657]: Agent 使用工具: ['astrbot_execute_shell']
[2026-03-14 17:30:39.851] [Core] [INFO] [runners.tool_loop_agent_runner:703]: 使用工具:astrbot_execute_shell,参数:{'command': 'type C:\Users\chuckie\.openclaw\workspace\skills\everything-search\search.py | findstr /n "." | head -50'}
[2026-03-14 17:30:39.943] [Core] [INFO] [runners.tool_loop_agent_runner:881]: Tool astrbot_execute_shell Result: {"stdout": "", "stderr": "'head' \u4e0d\u662f\u5185\u90e8\u6216\u5916\u90e8\u547d\u4ee4\uff0c\u4e5f\u4e0d\u662f\u53ef\u8fd0\u884c\u7684\u7a0b\u5e8f\r\n\u6216\u6279\u5904\u7406\u6587\u4ef6\u3002\r\n", "exit_code": 255}
[2026-03-14 17:32:45.479] [Core] [WARN] [v4.20.0] [runners.tool_loop_agent_runner:268]: Chat Model openrouter/openrouter/hunter-alpha request error: object of type 'NoneType' has no len()
Traceback (most recent call last):
File "C:\Users\chuckie.astrbot_launcher\instances\0459b44f-ec59-4130-ba58-102e49802780\core\astrbot\core\agent\runners\tool_loop_agent_runner.py", line 243, in _iter_llm_responses_with_fallback
async for resp in self._iter_llm_responses(include_model=idx == 0):
File "C:\Users\chuckie.astrbot_launcher\instances\0459b44f-ec59-4130-ba58-102e49802780\core\astrbot\core\agent\runners\tool_loop_agent_runner.py", line 220, in _iter_llm_responses
yield await self.provider.text_chat(**payload)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\chuckie.astrbot_launcher\instances\0459b44f-ec59-4130-ba58-102e49802780\core\astrbot\core\provider\sources\openai_source.py", line 763, in text_chat
) = await self._handle_api_error(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\chuckie.astrbot_launcher\instances\0459b44f-ec59-4130-ba58-102e49802780\core\astrbot\core\provider\sources\openai_source.py", line 714, in _handle_api_error
raise e
File "C:\Users\chuckie.astrbot_launcher\instances\0459b44f-ec59-4130-ba58-102e49802780\core\astrbot\core\provider\sources\openai_source.py", line 751, in text_chat
llm_response = await self._query(payloads, func_tool)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\chuckie.astrbot_launcher\instances\0459b44f-ec59-4130-ba58-102e49802780\core\astrbot\core\provider\sources\openai_source.py", line 264, in _query
llm_response = await self._parse_openai_completion(completion, tools)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\chuckie.astrbot_launcher\instances\0459b44f-ec59-4130-ba58-102e49802780\core\astrbot\core\provider\sources\openai_source.py", line 471, in _parse_openai_completion
if len(completion.choices) == 0:
^^^^^^^^^^^^^^^^^^^^^^^
TypeError: object of type 'NoneType' has no len()
[2026-03-14 17:32:45.492] [Core] [INFO] [respond.stage:184]: Prepare to send - /D425866BDDB69A1305199BAE0B166AFB: LLM 响应错误: All chat models failed: TypeError: object of type 'NoneType' has no len()
[2026-03-14 17:32:56.774] [Core] [INFO] [core.event_bus:66]: [default] [default(qq_official)] D425866BDDB69A1305199BAE0B166AFB: [At:qq_official] 打开书房灯
[2026-03-14 17:33:03.172] [Core] [INFO] [runners.tool_loop_agent_runner:657]: Agent 使用工具: ['web_search']
[2026-03-14 17:33:03.173] [Core] [INFO] [runners.tool_loop_agent_runner:703]: 使用工具:web_search,参数:{'query': '打开书房灯 智能家居 控制命令', 'max_results': 3}
[2026-03-14 17:33:03.173] [Core] [INFO] [web_searcher.main:213]: web_searcher - search_from_search_engine: 打开书房灯 智能家居 控制命令
[2026-03-14 17:33:04.961] [Core] [INFO] [web_searcher.main:88]: web_searcher - scraping web: Gmail - Email from Google - https://mail.google.com › mail
[2026-03-14 17:33:05.037] [Core] [INFO] [web_searcher.main:88]: web_searcher - scraping web: Sign in - Google Accounts - https://accounts.google.com › Login
[2026-03-14 17:33:05.038] [Core] [INFO] [web_searcher.main:88]: web_searcher - scraping web: Gmail - Email by Google - App Store - https://apps.apple.com › us › app › gmail-email-by-google
[2026-03-14 17:33:05.042] [Core] [INFO] [runners.tool_loop_agent_runner:881]: Tool web_search Result: 1. Gmail - Email from Google

  1. Sign in - Google Accounts

  2. Gmail - Email by Google - App Store

[2026-03-14 17:33:19.660] [Core] [INFO] [respond.stage:184]: Prepare to send - /D425866BDDB69A1305199BAE0B166AFB: 抱歉,我无法直接控制你的智能家居设备 😅

我目前是一个文本助手,没有连接到你的智能家居系统(如小米、华为、天猫精灵等平台)。

不过我可以帮你:

💡 如何控制书房灯?

  1. 使用对应的智能家居App:小米米家、华为智慧生活、天猫精灵等
  2. 语音助手:小爱同学、小度、天猫精灵等
  3. 智能开关:如果你有智能开关,可以通过App控制

🔧 需要我帮你什么?

  • 搜索你使用的智能家居品牌如何设置语音控制?
  • 提供连接智能灯的步骤指导?
  • 帮助编写自动化脚本(如果你有智能家居开发板)?

请告诉我你使用的是哪个品牌的智能家居设备,我可以提供更具体的帮助!
[2026-03-14 17:34:04.355] [Core] [INFO] [core.event_bus:66]: [default] [default(qq_official)] D425866BDDB69A1305199BAE0B166AFB: [At:qq_official] 你已经有这个skill
[2026-03-14 17:34:12.637] [Core] [INFO] [runners.tool_loop_agent_runner:657]: Agent 使用工具: ['web_search']
[2026-03-14 17:34:12.637] [Core] [INFO] [runners.tool_loop_agent_runner:703]: 使用工具:web_search,参数:{'query': 'openclaw 控制灯 skill', 'max_results': 5}
[2026-03-14 17:34:12.638] [Core] [INFO] [web_searcher.main:213]: web_searcher - search_from_search_engine: openclaw 控制灯 skill
[2026-03-14 17:34:14.784] [Core] [INFO] [web_searcher.main:88]: web_searcher - scraping web: OpenClaw - OpenClaw - https://docs.openclaw.ai › zh-CN
[2026-03-14 17:34:14.784] [Core] [INFO] [web_searcher.main:88]: web_searcher - scraping web: OpenClaw 中文文档 | 个人 AI 助手 · 任意平台 · 龙虾之道 - https://openclaw.cc
[2026-03-14 17:34:14.785] [Core] [INFO] [web_searcher.main:88]: web_searcher - scraping web: OpenClaw | 能干活的 AI 助手 - https://openclaws.io › zh
[2026-03-14 17:34:14.785] [Core] [INFO] [web_searcher.main:88]: web_searcher - scraping web: OpenClaw 从安装到入门的完全指南(2026-02-04) - 知乎 - https://zhuanlan.zhihu.com
[2026-03-14 17:34:14.785] [Core] [INFO] [web_searcher.main:88]: web_searcher - scraping web: OpenClaw是什么?OpenClaw能做什么?OpenClaw详细介绍 ... - https://cloud.tencent.com › developer › article
[2026-03-14 17:34:16.199] [Core] [INFO] [runners.tool_loop_agent_runner:881]: Tool web_search Result: 1. OpenClaw - OpenClaw

  1. OpenClaw 中文文档 | 个人 AI 助手 · 任意平台 · 龙虾之道

企业服务GoClaw - 岗位型 AI 员工平台7×24 小时在岗,多渠道接入,输出稳定可复核的业务结果。

  1. OpenClaw | 能干活的 AI 助手

  2. OpenClaw 从安装到入门的完全指南(2026-02-04) - 知乎

BioEngXBioEngX-专业生物技术社区, 地址 www.bioengx.com。本专栏欢迎投稿。

  1. OpenClaw是什么?OpenClaw能做什么?OpenClaw详细介绍 ...

[2026-03-14 17:34:24.914] [Core] [INFO] [runners.tool_loop_agent_runner:657]: Agent 使用工具: ['web_search']
[2026-03-14 17:34:24.915] [Core] [INFO] [runners.tool_loop_agent_runner:703]: 使用工具:web_search,参数:{'query': 'home assistant 控制灯 API', 'max_results': 5}
[2026-03-14 17:34:24.915] [Core] [INFO] [web_searcher.main:213]: web_searcher - search_from_search_engine: home assistant 控制灯 API
[2026-03-14 17:34:26.914] [Core] [INFO] [web_searcher.main:88]: web_searcher - scraping web: .shop后缀的域名前景如何? - 知乎 - https://www.zhihu.com › question
[2026-03-14 17:34:26.915] [Core] [INFO] [web_searcher.main:88]: web_searcher - scraping web: shopify 独立站 .com 域名与 .shop 域名区别和影响大吗? - 知乎 - https://www.zhihu.com › question
[2026-03-14 17:34:26.915] [Core] [INFO] [web_searcher.main:88]: web_searcher - scraping web: shop和store英语都是商店,两者有什么区别_百度知道 - https://zhidao.baidu.com › question
[2026-03-14 17:34:26.917] [Core] [INFO] [web_searcher.main:88]: web_searcher - scraping web: 现在柚子社的官方补丁在哪里啊? - 知乎 - https://www.zhihu.com › question
[2026-03-14 17:34:26.918] [Core] [INFO] [web_searcher.main:88]: web_searcher - scraping web: store和shop有什么区别?_百度知道 - https://zhidao.baidu.com › question
[2026-03-14 17:34:26.931] [Core] [INFO] [runners.tool_loop_agent_runner:881]: Tool web_search Result: 1. .shop后缀的域名前景如何? - 知乎

  1. shopify 独立站 .com 域名与 .shop 域名区别和影响大吗? - 知乎

  2. shop和store英语都是商店,两者有什么区别_百度知道

  3. 现在柚子社的官方补丁在哪里啊? - 知乎

  4. store和shop有什么区别?_百度知道

[2026-03-14 17:36:32.437] [Core] [WARN] [v4.20.0] [runners.tool_loop_agent_runner:268]: Chat Model openrouter/openrouter/hunter-alpha request error: object of type 'NoneType' has no len()
Traceback (most recent call last):
File "C:\Users\chuckie.astrbot_launcher\instances\0459b44f-ec59-4130-ba58-102e49802780\core\astrbot\core\agent\runners\tool_loop_agent_runner.py", line 243, in _iter_llm_responses_with_fallback
async for resp in self._iter_llm_responses(include_model=idx == 0):
File "C:\Users\chuckie.astrbot_launcher\instances\0459b44f-ec59-4130-ba58-102e49802780\core\astrbot\core\agent\runners\tool_loop_agent_runner.py", line 220, in _iter_llm_responses
yield await self.provider.text_chat(**payload)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\chuckie.astrbot_launcher\instances\0459b44f-ec59-4130-ba58-102e49802780\core\astrbot\core\provider\sources\openai_source.py", line 763, in text_chat
) = await self._handle_api_error(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\chuckie.astrbot_launcher\instances\0459b44f-ec59-4130-ba58-102e49802780\core\astrbot\core\provider\sources\openai_source.py", line 714, in _handle_api_error
raise e
File "C:\Users\chuckie.astrbot_launcher\instances\0459b44f-ec59-4130-ba58-102e49802780\core\astrbot\core\provider\sources\openai_source.py", line 751, in text_chat
llm_response = await self._query(payloads, func_tool)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\chuckie.astrbot_launcher\instances\0459b44f-ec59-4130-ba58-102e49802780\core\astrbot\core\provider\sources\openai_source.py", line 264, in _query
llm_response = await self._parse_openai_completion(completion, tools)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\chuckie.astrbot_launcher\instances\0459b44f-ec59-4130-ba58-102e49802780\core\astrbot\core\provider\sources\openai_source.py", line 471, in _parse_openai_completion
if len(completion.choices) == 0:
^^^^^^^^^^^^^^^^^^^^^^^
TypeError: object of type 'NoneType' has no len()
[2026-03-14 17:36:32.448] [Core] [INFO] [respond.stage:184]: Prepare to send - /D425866BDDB69A1305199BAE0B166AFB: LLM 响应错误: All chat models failed: TypeError: object of type 'NoneType' has no len()
[2026-03-14 17:36:52.572] [Core] [WARN] [v4.20.0] [qqofficial.qqofficial_message_event:569]: [QQOfficial] post_c2c_message: API 返回 None,跳过本次发送

Are you willing to submit a PR? / 你愿意提交 PR 吗?

  • Yes!

Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:providerThe bug / feature is about AI Provider, Models, LLM Agent, LLM Agent Runner.bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions