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

Đang mở Phù hợp với người mới
#9,788 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@basil-k-aji-dev đang làm issue này rồi.

Từ ngày 25/11/2026.

  • #9795 của @basil-k-aji-dev — đang mở

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
82/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
python
Lĩnh vực
backend-api-design

Hướng nghiên cứu

Đọc lib/crewai/src/crewai/llms/providers/openai/completion.py, so sánh _handle_streaming_completion với _ahandle_streaming_completion trong trường hợp thiếu kết quả phân tích. Sau đó kiểm tra test_openai_streaming_with_response_model và bổ sung kiểm thử cho luồng có completion cuối cùng với parsed = None. Hoàn tất khi đường đi đồng bộ trả về văn bản đã tích lũy và phát ra LLMCallCompletedEvent, giống như hành vi bất đồng bộ.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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

Ngôn ngữ chính
Python
Star
61.2k
Fork
9.2k
Merge trung bình
1 ngày 14 giờ
Pull request đã merge (30 ngày)
180

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của crewAIInc/crewAI

Tất cả issue của crewAIInc/crewAI

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.