AstrBot icon indicating copy to clipboard operation
AstrBot copied to clipboard

[Bug]v4.22.3 使用 GPT-5 系列推理模型时出现 "OpenAI completion has no usable output"

Open qq529 opened this issue 7 months ago • 9 comments

What happened / 发生了什么

升级到 v4.22.3 后,在配置页面测试 Provider(/config/provider/check_one)时,GPT-5 系列推理模型(gpt-5.3-codex 和 gpt-5.4)均报错: OpenAI completion has no usable output 模型返回的 content=None、tool_calls=None、reasoning_content=None,但有少量 reasoning_tokens,导致 AstrBot 判断没有可用输出。 之前在 v4.20.0 时是 “API 返回的 completion 无法解析”,升级后错误提示变为 “has no usable output”,但问题依然存在。

Reproduce / 如何复现?

使用容器部署的 AstrBot v4.22.3 添加 OpenAI 兼容 Provider,模型选择 gpt-5.3-codex 或 gpt-5.4 在 Web 管理页面点击“检查”该 Provider(或进行实际对话) 立即触发报错

即使使用极短的 prompt(prompt_tokens 只有 13),也会出现此问题。

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

AstrBot 版本:v4.22.3 部署方式:容器部署(Docker) 提供商:OpenAI 兼容接口(gpt-5.3-codex、gpt-5.4) 消息平台:aiocqhttp(QQ) 操作系统:Linux(容器环境)

OS

Linux

Logs / 报错日志

gpt-5.4 的报错: text[2026-04-07 20:04:55.135] [Core] [ERRO] [v4.22.3] [sources.openai_source:801]: OpenAI completion has no usable output: ChatCompletion(id='resp_041d4aeca84d177c0169d4f32d16f8819b965f5dcbe016d236', choices=[Choice(finish_reason='stop', index=0, logprobs=None, message=ChatCompletionMessage(content=None, refusal=None, role='assistant', annotations=None, audio=None, function_call=None, tool_calls=None, reasoning_content=None), native_finish_reason='stop')], created=1775563565, model='gpt-5.4', object='chat.completion', service_tier=None, system_fingerprint=None, usage=CompletionUsage(completion_tokens=18, prompt_tokens=13, total_tokens=31, completion_tokens_details=CompletionTokensDetails(..., reasoning_tokens=10, ...))). gpt-5.3-codex 的报错: text[2026-04-07 20:05:15.180] [Core] [ERRO] [v4.22.3] [sources.openai_source:801]: OpenAI completion has no usable output: ChatCompletion(id='resp_084a4920c7a9aadc0169d4f341a454819b81634e4fa5f3efd0', choices=[Choice(finish_reason='stop', index=0, logprobs=None, message=ChatCompletionMessage(content=None, refusal=None, role='assistant', annotations=None, audio=None, function_call=None, tool_calls=None, reasoning_content=None), native_finish_reason='stop')], created=1775563585, model='gpt-5.3-codex', object='chat.completion', service_tier=None, system_fingerprint=None, usage=CompletionUsage(completion_tokens=6, prompt_tokens=13, total_tokens=19, completion_tokens_details=CompletionTokensDetails(..., reasoning_tokens=0, ...))). 同时会看到: text[WARN] Provider chat GPT/gpt-5.x is unavailable. Error: OpenAI completion has no usable output.

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

  • [ ] Yes!

Code of Conduct

qq529 avatar Apr 07 '26 12:04 qq529

Hi @qq529! I'm Dosu and I’m helping the AstrBot team.

这个问题的根因已经定位到了。在 openai_source.py 的 _parse_openai_completion() 方法中(约第 887-896 行),判断"有效输出"的条件是检查三个字段:completion_text、reasoning_content(字符串)、tools_call_args,三者都为空时抛出 EmptyModelOutputError [1]。

GPT-5 系列推理模型返回的响应中 content=None、reasoning_content=None、tool_calls=None,但 reasoning_tokens > 0。当前代码完全不检查 reasoning_tokens,只看 reasoning_content 字符串是否非空,所以即使模型确实做了推理工作,也会被判定为"无可用输出" [2]。

这与之前 issue #7044 报告的问题本质相同 [3]。维护者 @Soulter 在 PR #7104 中引入了重试机制来缓解此现象,但并没有从根本上解决 GPT-5 推理模型返回空 reasoning_content 的情况。

目前有一个 open PR #6115 直接针对此问题,允许解析 reasoning-only 的 completion [4]。如果该 PR 合并,应该能修复你遇到的问题。

临时解决方案:可以尝试切换到非推理模型(如 gpt-4o)来规避此问题,等待上述 PR 合并后再切回 GPT-5 系列。

To reply, just mention @dosu.


Docs are dead. Just use Dosu.

Leave Feedback Ask Dosu about AstrBot Share Dosu with your team

dosubot[bot] avatar Apr 07 '26 12:04 dosubot[bot]

实际对话的时候会报错吗?

Soulter avatar Apr 08 '26 03:04 Soulter

astrbot | astrbot.core.exceptions.EmptyModelOutputError: OpenAI completion has no usable output. response_id=resp_0eb20823aad376140169d545f3f4808191ad4a698aa32eeda5, finish_reason=stop astrbot | [01:59:18.321] [Core] [WARN] [v4.22.3] [runners.tool_loop_agent_runner:287]: Switched from openai/gpt-5.2 to fallback chat provider: openai/gpt-5.1 astrbot | [01:59:19.676] [Core] [ERRO] [v4.22.3] [sources.openai_source:801]: OpenAI completion has no usable output: ChatCompletion(id='resp_03b50c4ebe9284f20169d545f685f48191a32bdf8bde1aac71', choices=[Choice(finish_reason='stop', index=0, logprobs=None, message=ChatCompletionMessage(content=None, refusal=None, role='assistant', annotations=None, audio=None, function_call=None, tool_calls=None, reasoning_content=None), native_finish_reason='stop')], created=1775584758, model='gpt-5.1-2025-11-13', object='chat.completion', service_tier=None, system_fingerprint=None, usage=CompletionUsage(completion_tokens=82, prompt_tokens=860, total_tokens=942, completion_tokens_details=CompletionTokensDetails(accepted_prediction_tokens=None, audio_tokens=None, reasoning_tokens=18, rejected_prediction_tokens=None), prompt_tokens_details=PromptTokensDetails(audio_tokens=None, cached_tokens=0))). astrbot | [01:59:19.676] [Core] [WARN] [v4.22.3] [runners.tool_loop_agent_runner:341]: Chat Model openai/gpt-5.1 returned empty output on attempt 1/3. astrbot | [01:59:22.291] [Core] [ERRO] [v4.22.3] [sources.openai_source:801]: OpenAI completion has no usable output: ChatCompletion(id='resp_032ef3bf08d2a4180169d545f8d1ac8191a33761eba58c62b6', choices=[Choice(finish_reason='stop', index=0, logprobs=None, message=ChatCompletionMessage(content=None, refusal=None, role='assistant', annotations=None, audio=None, function_call=None, tool_calls=None, reasoning_content=None), native_finish_reason='stop')], created=1775584760, model='gpt-5.1-2025-11-13', object='chat.completion', service_tier=None, system_fingerprint=None, usage=CompletionUsage(completion_tokens=54, prompt_tokens=860, total_tokens=914, completion_tokens_details=CompletionTokensDetails(accepted_prediction_tokens=None, audio_tokens=None, reasoning_tokens=15, rejected_prediction_tokens=None), prompt_tokens_details=PromptTokensDetails(audio_tokens=None, cached_tokens=0))). astrbot | [01:59:22.292] [Core] [WARN] [v4.22.3] [runners.tool_loop_agent_runner:341]: Chat Model openai/gpt-5.1 returned empty output on attempt 2/3. astrbot | [01:59:27.583] [Core] [ERRO] [v4.22.3] [sources.openai_source:801]: OpenAI completion has no usable output: ChatCompletion(id='resp_0ef361366514b86e0169d545fc8824819180751c097a61537a', choices=[Choice(finish_reason='stop', index=0, logprobs=None, message=ChatCompletionMessage(content=None, refusal=None, role='assistant', annotations=None, audio=None, function_call=None, tool_calls=None, reasoning_content=None), native_finish_reason='stop')], created=1775584764, model='gpt-5.1-2025-11-13', object='chat.completion', service_tier=None, system_fingerprint=None, usage=CompletionUsage(completion_tokens=75, prompt_tokens=860, total_tokens=935, completion_tokens_details=CompletionTokensDetails(accepted_prediction_tokens=None, audio_tokens=None, reasoning_tokens=16, rejected_prediction_tokens=None), prompt_tokens_details=PromptTokensDetails(audio_tokens=None, cached_tokens=0))). astrbot | [01:59:27.584] [Core] [WARN] [v4.22.3] [runners.tool_loop_agent_runner:341]: Chat Model openai/gpt-5.1 returned empty output on attempt 3/3. astrbot | [01:59:27.584] [Core] [WARN] [v4.22.3] [runners.tool_loop_agent_runner:350]: Chat Model openai/gpt-5.1 request error: OpenAI completion has no usable output. response_id=resp_0ef361366514b86e0169d545fc8824819180751c097a61537a, finish_reason=stop astrbot | Traceback (most recent call last): astrbot | astrbot | File "/AstrBot/main.py", line 141, in astrbot | asyncio.run(main_async(args.webui_dir)) astrbot | │ │ │ │ └ None astrbot | │ │ │ └ Namespace(webui_dir=None) astrbot | │ │ └ <function main_async at 0xe83e97383c40> astrbot | │ └ <function run at 0xe83e9b06da80> astrbot | └ <module 'asyncio' from '/usr/local/lib/python3.12/asyncio/init.py'> astrbot | astrbot | File "/usr/local/lib/python3.12/asyncio/runners.py", line 195, in run astrbot | return runner.run(main) astrbot | │ │ └ <coroutine object main_async at 0xe83e9811f300> astrbot | │ └ <function Runner.run at 0xe83e9ae2ef20> astrbot | └ <asyncio.runners.Runner object at 0xe83e79c1bf80> astrbot | File "/usr/local/lib/python3.12/asyncio/runners.py", line 118, in run astrbot | return self._loop.run_until_complete(task) astrbot | │ │ │ └ <Task pending name='Task-1' coro=<main_async() running at /AstrBot/main.py:121> wait_for=<_GatheringFuture pending cb=[Task.t... astrbot | │ │ └ <function BaseEventLoop.run_until_complete at 0xe83e9ae2cb80> astrbot | │ └ <_UnixSelectorEventLoop running=True closed=False debug=False> astrbot | └ <asyncio.runners.Runner object at 0xe83e79c1bf80> astrbot | File "/usr/local/lib/python3.12/asyncio/base_events.py", line 678, in run_until_complete astrbot | self.run_forever() astrbot | │ └ <function BaseEventLoop.run_forever at 0xe83e9ae2cae0> astrbot | └ <_UnixSelectorEventLoop running=True closed=False debug=False> astrbot | File "/usr/local/lib/python3.12/asyncio/base_events.py", line 645, in run_forever astrbot | self._run_once() astrbot | │ └ <function BaseEventLoop._run_once at 0xe83e9ae2e8e0> astrbot | └ <_UnixSelectorEventLoop running=True closed=False debug=False> astrbot | File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1999, in _run_once astrbot | handle._run() astrbot | │ └ <function Handle._run at 0xe83e9b014c20> astrbot | └ <Handle <_asyncio.TaskStepMethWrapper object at 0xe83e67179d20>()> astrbot | File "/usr/local/lib/python3.12/asyncio/events.py", line 88, in _run astrbot | self._context.run(self._callback, *self._args) astrbot | │ │ │ │ │ └ <member '_args' of 'Handle' objects> astrbot | │ │ │ │ └ <Handle <_asyncio.TaskStepMethWrapper object at 0xe83e67179d20>()> astrbot | │ │ │ └ <member '_callback' of 'Handle' objects> astrbot | │ │ └ <Handle <_asyncio.TaskStepMethWrapper object at 0xe83e67179d20>()> astrbot | │ └ <member '_context' of 'Handle' objects> astrbot | └ <Handle <_asyncio.TaskStepMethWrapper object at 0xe83e67179d20>()> astrbot | astrbot | File "/AstrBot/astrbot/core/pipeline/scheduler.py", line 87, in execute astrbot | await self._process_stages(event) astrbot | │ │ └ <astrbot.core.platform.sources.aiocqhttp.aiocqhttp_message_event.AiocqhttpMessageEvent object at 0xe83e67242480> astrbot | │ └ <function PipelineScheduler._process_stages at 0xe83e79c5d300> astrbot | └ <astrbot.core.pipeline.scheduler.PipelineScheduler object at 0xe83e78a8fce0> astrbot | astrbot | File "/AstrBot/astrbot/core/pipeline/scheduler.py", line 52, in _process_stages astrbot | async for _ in coroutine: astrbot | │ └ <async_generator object ProcessStage.process at 0xe83e703fc240> astrbot | └ None astrbot | astrbot | File "/AstrBot/astrbot/core/pipeline/process_stage/stage.py", line 65, in process astrbot | async for _ in self.agent_sub_stage.process(event): astrbot | │ │ │ └ <astrbot.core.platform.sources.aiocqhttp.aiocqhttp_message_event.AiocqhttpMessageEvent object at 0xe83e67242480> astrbot | │ │ └ <function AgentRequestSubStage.process at 0xe83e7045f880> astrbot | │ └ <astrbot.core.pipeline.process_stage.method.agent_request.AgentRequestSubStage object at 0xe83e6728bb90> astrbot | └ <astrbot.core.pipeline.process_stage.stage.ProcessStage object at 0xe83e6728bbc0> astrbot | astrbot | File "/AstrBot/astrbot/core/pipeline/process_stage/method/agent_request.py", line 47, in process astrbot | async for resp in self.agent_sub_stage.process(event, self.prov_wake_prefix): astrbot | │ │ │ │ │ └ '' astrbot | │ │ │ │ └ <astrbot.core.pipeline.process_stage.method.agent_request.AgentRequestSubStage object at 0xe83e6728bb90> astrbot | │ │ │ └ <astrbot.core.platform.sources.aiocqhttp.aiocqhttp_message_event.AiocqhttpMessageEvent object at 0xe83e67242480> astrbot | │ │ └ <function InternalAgentSubStage.process at 0xe83e7064a020> astrbot | │ └ <astrbot.core.pipeline.process_stage.method.agent_sub_stages.internal.InternalAgentSubStage object at 0xe83e6728bb00> astrbot | └ <astrbot.core.pipeline.process_stage.method.agent_request.AgentRequestSubStage object at 0xe83e6728bb90> astrbot | astrbot | File "/AstrBot/astrbot/core/pipeline/process_stage/method/agent_sub_stages/internal.py", line 335, in process astrbot | async for _ in run_agent( astrbot | └ <function run_agent at 0xe83e70fb4900> astrbot | astrbot | File "/AstrBot/astrbot/core/astr_agent_run_util.py", line 124, in run_agent astrbot | async for resp in agent_runner.step(): astrbot | │ └ <function ToolLoopAgentRunner.step at 0xe83e8e549c60> astrbot | └ <astrbot.core.agent.runners.tool_loop_agent_runner.ToolLoopAgentRunner object at 0xe83e67014500> astrbot | astrbot | File "/AstrBot/astrbot/core/agent/runners/tool_loop_agent_runner.py", line 456, in step astrbot | async for llm_response in self._iter_llm_responses_with_fallback(): astrbot | │ └ <function ToolLoopAgentRunner._iter_llm_responses_with_fallback at 0xe83e8e5498a0> astrbot | └ <astrbot.core.agent.runners.tool_loop_agent_runner.ToolLoopAgentRunner object at 0xe83e67014500> astrbot | astrbot | > File "/AstrBot/astrbot/core/agent/runners/tool_loop_agent_runner.py", line 305, in _iter_llm_responses_with_fallback astrbot | async for attempt in retrying: astrbot | │ └ <AsyncRetrying object at 0xe83e670d7bc0 (stop=<tenacity.stop.stop_after_attempt object at 0xe83e67103230>, wait=<tenacity.wai... astrbot | └ <tenacity.AttemptManager object at 0xe83e670d4bf0> astrbot | astrbot | File "/usr/local/lib/python3.12/site-packages/tenacity/asyncio/init.py", line 170, in anext astrbot | do = await self.iter(retry_state=self._retry_state) astrbot | │ │ │ └ <RetryCallState 255354714539936: attempt #3; slept for 3.0; last result: failed (EmptyModelOutputError OpenAI completion has ... astrbot | │ │ └ <AsyncRetrying object at 0xe83e670d7bc0 (stop=<tenacity.stop.stop_after_attempt object at 0xe83e67103230>, wait=<tenacity.wai... astrbot | │ └ <function AsyncRetrying.iter at 0xe83e8eddfa60> astrbot | └ <AsyncRetrying object at 0xe83e670d7bc0 (stop=<tenacity.stop.stop_after_attempt object at 0xe83e67103230>, wait=<tenacity.wai... astrbot | File "/usr/local/lib/python3.12/site-packages/tenacity/asyncio/init.py", line 157, in iter astrbot | result = await action(retry_state) astrbot | │ └ <RetryCallState 255354714539936: attempt #3; slept for 3.0; last result: failed (EmptyModelOutputError OpenAI completion has ... astrbot | └ <function wrap_to_async_func..inner at 0xe83e67446ac0> astrbot | File "/usr/local/lib/python3.12/site-packages/tenacity/_utils.py", line 111, in inner astrbot | return call(*args, **kwargs) astrbot | │ │ └ {} astrbot | │ └ (<RetryCallState 255354714539936: attempt #3; slept for 3.0; last result: failed (EmptyModelOutputError OpenAI completion has... astrbot | └ <function BaseRetrying._post_stop_check_actions..exc_check at 0xe83e67445d00> astrbot | File "/usr/local/lib/python3.12/site-packages/tenacity/init.py", line 413, in exc_check astrbot | raise retry_exc.reraise() astrbot | │ └ <function RetryError.reraise at 0xe83e8eddcea0> astrbot | └ RetryError(<Future at 0xe83e67267c50 state=finished raised EmptyModelOutputError>) astrbot | File "/usr/local/lib/python3.12/site-packages/tenacity/init.py", line 184, in reraise astrbot | raise self.last_attempt.result() astrbot | │ │ └ <function Future.result at 0xe83e9bd0f7e0> astrbot | │ └ <Future at 0xe83e67267c50 state=finished raised EmptyModelOutputError> astrbot | └ RetryError(<Future at 0xe83e67267c50 state=finished raised EmptyModelOutputError>) astrbot | File "/usr/local/lib/python3.12/concurrent/futures/_base.py", line 449, in result astrbot | return self.__get_result() astrbot | └ None astrbot | File "/usr/local/lib/python3.12/concurrent/futures/_base.py", line 401, in __get_result astrbot | raise self._exception astrbot | └ None astrbot | astrbot | File "/AstrBot/astrbot/core/agent/runners/tool_loop_agent_runner.py", line 309, in _iter_llm_responses_with_fallback astrbot | async for resp in self._iter_llm_responses( astrbot | │ └ <function ToolLoopAgentRunner._iter_llm_responses at 0xe83e8e549800> astrbot | └ <astrbot.core.agent.runners.tool_loop_agent_runner.ToolLoopAgentRunner object at 0xe83e67014500> astrbot | astrbot | File "/AstrBot/astrbot/core/agent/runners/tool_loop_agent_runner.py", line 272, in _iter_llm_responses astrbot | yield await self.provider.text_chat(**payload) astrbot | │ │ │ └ {'contexts': [Message(role='system', content="You are running in Safe Mode.\n\nRules:\n- Do NOT generate pornographic, sexual... astrbot | │ │ └ <function ProviderOpenAIOfficial.text_chat at 0xe83e72d4c360> astrbot | │ └ <astrbot.core.provider.sources.openai_source.ProviderOpenAIOfficial object at 0xe83e70f16ab0> astrbot | └ <astrbot.core.agent.runners.tool_loop_agent_runner.ToolLoopAgentRunner object at 0xe83e67014500> astrbot | astrbot | File "/AstrBot/astrbot/core/provider/sources/openai_source.py", line 1064, in text_chat astrbot | ) = await self._handle_api_error( astrbot | │ └ <function ProviderOpenAIOfficial._handle_api_error at 0xe83e72d4c2c0> astrbot | └ <astrbot.core.provider.sources.openai_source.ProviderOpenAIOfficial object at 0xe83e70f16ab0> astrbot | astrbot | File "/AstrBot/astrbot/core/provider/sources/openai_source.py", line 1012, in _handle_api_error astrbot | raise e astrbot | └ EmptyModelOutputError('OpenAI completion has no usable output. response_id=resp_0ef361366514b86e0169d545fc8824819180751c097a6... astrbot | astrbot | File "/AstrBot/astrbot/core/provider/sources/openai_source.py", line 1052, in text_chat astrbot | llm_response = await self._query(payloads, func_tool) astrbot | │ │ │ └ ToolSet(tools=[BilibiliTool(name='bilibili_read', description='获取一个哔哩哔哩视频的概要。如果视频没有字幕则返回提示信息。', parameters={'type': 'object',... astrbot | │ │ └ {'messages': [{'role': 'system', 'content': "You are running in Safe Mode.\n\nRules:\n- Do NOT generate pornographic, sexuall... astrbot | │ └ <function ProviderOpenAIOfficial._query at 0xe83e72d37d80> astrbot | └ <astrbot.core.provider.sources.openai_source.ProviderOpenAIOfficial object at 0xe83e70f16ab0> astrbot | astrbot | File "/AstrBot/astrbot/core/provider/sources/openai_source.py", line 494, in _query astrbot | llm_response = await self._parse_openai_completion(completion, tools) astrbot | │ │ │ └ ToolSet(tools=[BilibiliTool(name='bilibili_read', description='获取一个哔哩哔哩视频的概要。如果视频没有字幕则返回提示信息。', parameters={'type': 'object',... astrbot | │ │ └ ChatCompletion(id='resp_0ef361366514b86e0169d545fc8824819180751c097a61537a', choices=[Choice(finish_reason='stop', index=0, l... astrbot | │ └ <function ProviderOpenAIOfficial._parse_openai_completion at 0xe83e72d4c0e0> astrbot | └ <astrbot.core.provider.sources.openai_source.ProviderOpenAIOfficial object at 0xe83e70f16ab0> astrbot | astrbot | File "/AstrBot/astrbot/core/provider/sources/openai_source.py", line 802, in _parse_openai_completion astrbot | raise EmptyModelOutputError( astrbot | └ <class 'astrbot.core.exceptions.EmptyModelOutputError'> astrbot |

luke358 avatar Apr 08 '26 03:04 luke358

直接在chat中聊天是正常的 Image

luke358 avatar Apr 08 '26 03:04 luke358

发现原因可能是返回的message里不包含content,导致异常

geekjam avatar Apr 08 '26 03:04 geekjam

在webui chat中聊天是正常的应该是走了流式接口,遇到过类似的流式正常,非流式异常,排查过上游gpt的问题吗

kterna avatar Apr 08 '26 03:04 kterna

感觉确实可能是上游模型的问题,我测试了流式和非流式。

非流式返回的内容是空的

curl -i https://***.***/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer sk-***" \
  -d '{
    "model": "gpt-5",
    "messages": [
      {"role": "user", "content": "你好,请只回复:测试成功"}
    ],
    "stream": false,
    "temperature": 0
  }'


HTTP/2 200
content-type: application/json

{
  "id":"resp_***",
  "object":"chat.completion",
  "created":1775621509,
  "model":"gpt-5-2025-08-07",
  "choices":[
    {
      "index":0,
      "message":{
        "role":"assistant",
        "content":null,
        "reasoning_content":null,
        "tool_calls":null
      },
      "finish_reason":"stop",
      "native_finish_reason":"stop"
    }
  ],
  "usage":{
    "completion_tokens":158,
    "total_tokens":171,
    "prompt_tokens":13,
    "prompt_tokens_details":{"cached_tokens":0},
    "completion_tokens_details":{"reasoning_tokens":128}
  }
}

luke358 avatar Apr 08 '26 04:04 luke358

在使用 v4.22.3时遇到了完全相同的问题。

核心现象:Web 端正常,机器人端报错

同一个 Provider 和同一个模型(gpt-5.3-codex / gpt-5.4),在 AstrBot 自带的 Web ChatUI 界面可以正常对话并接收到回复。但在通过 QQ (aiocqhttp) 消息触发时,会 100% 触发 OpenAI completion has no usable output。

日志分析

从后台日志可以看到,API 响应其实是成功的,且消耗了 completion_tokens,但内容并未被填充在 content 字段中:

报错日志片段:

[Core] [ERRO] [v4.22.3] [sources.openai_source:801]: OpenAI completion has no usable output: ChatCompletion(id='resp_0983753e74119dc10169d5e0e9ac18819b91853f62d9f41c03', choices=[Choice(finish_reason='stop', index=0, logprobs=None, message=ChatCompletionMessage(content=None, refusal=None, role='assistant', annotations=None, audio=None, function_call=None, tool_calls=None))], created=1775624427, model='gpt-5.3-codex', object='chat.completion', usage=CompletionUsage(completion_tokens=6, prompt_tokens=1335, total_tokens=1341))
  • Token 消耗:completion_tokens 并不为 0(如上显示为 6),说明模型实际生成了推理内容或正文。
  • 字段缺失:由于推理型模型(Reasoning Models)通常将内容放在 reasoning_content 中,而 content 为 None,导致 openai_source.py 认为该响应无效。
  • 平台差异:Web 端可能因为开启了流式(Stream)传输或者有不同的容错逻辑,可以正常显示内容;但后端在处理机器人消息的非流式请求时,由于严格校验 content 字段导致抛出异常。

环境说明

  • 版本:v4.22.3
  • 部署方式:uv
  • 模型:gpt-5.3-codex / gpt-5.4 (OpenAI 兼容接口)
  • 消息平台:aiocqhttp (QQ)

Cc-Cece avatar Apr 08 '26 05:04 Cc-Cece

same

Eternity-boundary avatar Nov 09 '26 11:11 Eternity-boundary