[BUG] Native OpenAI async streaming does not send response_model as response_format

Đang mở Phù hợp với người mới
#9,785 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.

  • #9794 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
84/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
ai, backend

Hướng nghiên cứu

Đọc lib/crewai/src/crewai/llms/providers/openai/completion.py và so sánh _ahandle_streaming_completion với _handle_streaming_completion. Tìm bài kiểm thử test_openai_streaming_with_response_model và kiểm tra cách bài kiểm thử này bao phủ đường dẫn bất đồng bộ. Công việc hoàn tất khi yêu cầu streaming bất đồng bộ bao gồm lược đồ response_model dưới dạng response_format và một bài kiểm thử xác minh các đối số của yêu cầu.

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

Mô tả

Description

OpenAICompletion._ahandle_streaming_completion ignores the per-call response_model when it builds the request. In llms/providers/openai/completion.py the if response_model: branch calls self._get_async_client().chat.completions.create(**params), and params come from _prepare_completion_params, which only sets response_format from self.response_format. The sync twin (_handle_streaming_completion) uses beta.chat.completions.stream(..., response_format=response_model). So await llm.acall(..., response_model=M) with streaming sends an unconstrained request and usually gets prose back instead of an instance of M.

Steps to Reproduce
  1. Create LLM(model="openai/gpt-4o", stream=True) with the native OpenAI provider.
  2. Mock or inspect llm._async_client.chat.completions.create and call await llm.acall(messages, response_model=SomeModel).
  3. The kwargs passed to create contain no response_format.
Expected behavior

The structured-output schema of response_model is sent, as on the sync path.

Screenshots/Code snippets

Related, on the LiteLLM path (llm.py): #9283 and PR #9284. This issue is the native OpenAI async path only.

Evidence

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

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.