Async streaming ignores response_model and returns raw text

オープン
#9,283 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@laoyyu がすでに取り組んでいます。

2026年11月9日 から。

  • #9284 @laoyyu による — オープン
  • #9288 @badrbel による — オープン

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
25/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
停滞
技術スタック
python
領域
ai, backend

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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)
主要言語
Python
スター
60.6k
フォーク
9.1k
平均マージ
1日 9時間
マージ済み PR(30日)
218

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

crewAIInc/crewAI のほかの issue

crewAIInc/crewAI の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。