Async streaming ignores response_model and returns raw text

Đang mở
#9,283 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

@laoyyu đang làm issue này rồi.

Từ ngày 9/11/2026.

  • #9284 của @laoyyu — đang mở
  • #9288 của @badrbel — đang mở

Đánh giá

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

Hướng nghiên cứu

Read lib/crewai/src/crewai/llm.py, comparing _ahandle_streaming_response with _handle_streaming_response and how the sync path uses InternalInstructor. Reproduce with LLM.acall(..., response_model=Answer) and confirm the async result is raw text. Done means async streaming returns the serialized structured response; a linked open pull request is already addressing this issue.

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

Mô tả

Description

LLM.acall(..., response_model=...) with stream=True returns the raw streamed string instead of the validated model.

The sync path (_handle_streaming_response) converts the accumulated text through InternalInstructor and returns model_dump_json() when a response_model is configured, but the async twin (_ahandle_streaming_response) accepts the same response_model argument and never uses it.

Steps to reproduce
from pydantic import BaseModel
from crewai import LLM

class Answer(BaseModel):
    answer: str

llm = LLM(model="gpt-4o-mini", stream=True)

sync = llm.call("What is 6 * 7?", response_model=Answer)      # '{"answer": "42"}'
async_ = await llm.acall("What is 6 * 7?", response_model=Answer)  # 'The answer is 42.' (raw text)
Expected behavior

Both code paths should return the serialized structured response; async streaming should not silently downgrade to unstructured text. Any downstream Answer.model_validate_json(result) then fails with a JSON decode error even though the model answered correctly.

Environment
  • crewai: current main (lib/crewai/src/crewai/llm.py, _ahandle_streaming_response)
Ngôn ngữ chính
Python
Star
60.6k
Fork
9.1k
Merge trung bình
1 ngày 9 giờ
Pull request đã merge (30 ngày)
218

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.