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

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

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

@basil-k-aji-dev がすでに取り組んでいます。

2026年11月25日 から。

  • #9794 @basil-k-aji-dev による — オープン

評価

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

調査の方向性

lib/crewai/src/crewai/llms/providers/openai/completion.pyを読み、_ahandle_streaming_completionと_handle_streaming_completionを比較してください。テストtest_openai_streaming_with_response_modelを見つけ、非同期パスをどのようにカバーしているか確認してください。非同期ストリーミングリクエストにresponse_modelのスキーマがresponse_formatとして含まれ、テストでリクエスト引数が検証されることが完了条件です。

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

説明

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

主要言語
Python
スター
61.2k
フォーク
9.2k
平均マージ
1日 14時間
マージ済み PR(30日)
180

環境構築

はじめの一歩

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

crewAIInc/crewAI のほかの issue

crewAIInc/crewAI の issue をすべて見る

似ている issue

Python の issue をもっと見る

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

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