[BUG] Native OpenAI sync streaming with response_model returns an empty string and emits no completed event when the parse is missing

未关闭 适合新手
#9,788 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

@basil-k-aji-dev 已经在做这个了。

开始于 2026年11月25日。

  • #9795 来自 @basil-k-aji-dev —— 未关闭

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
82/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
python

调研方向

阅读 lib/crewai/src/crewai/llms/providers/openai/completion.py,比较 _handle_streaming_completion 和 _ahandle_streaming_completion 在缺少解析结果时的处理。然后检查 test_openai_streaming_with_response_model,为最终 completion 的 parsed = None 的流添加覆盖。同步路径返回累积的文本并发出 LLMCallCompletedEvent,与异步行为一致,即为完成。

由索引模型根据 Issue 内容生成。

描述

Description

In the native OpenAI provider, sync streaming with response_model returns an empty string and emits no completion event when the final parse is missing. _handle_streaming_completion only logs "Failed to get parsed result from stream" and returns "", which leaves llm_call_started unpaired. The async twin (_ahandle_streaming_completion) emits the completed event and returns the accumulated text.

Steps to Reproduce
  1. Stream with response_model set and a stream whose final completion has parsed = None (for example a refusal or an empty parse), as in test_openai_streaming_with_response_model.
  2. The call returns "", and no LLMCallCompletedEvent is emitted.
Expected behavior

Like the async path: the completed event fires with the accumulated deltas and the text is returned.

Screenshots/Code snippets

Same event-pairing family as #8496 and #8498, but those cover other paths.

Evidence

Code reading of lib/crewai/src/crewai/llms/providers/openai/completion.py at 97f2424 (sync handler vs the async one). I can send a fix with a test copied from the existing streaming test.

Operating System

Linux (Debian-based)

Python Version

3.12

crewAI Version

1.15.45 (origin/main at 97f2424)

crewAI Tools Version

Not relevant

Virtual Environment

uv

主要语言
Python
星标
61.2k
派生
9.2k
平均合并
1 天 14 小时
30 天内合并 PR
180

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

crewAIInc/crewAI 的其他 Issue

查看 crewAIInc/crewAI 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。