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

Aperta Adatta ai principianti
#9,785 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@basil-k-aji-dev ci sta già lavorando.

Dal 25/11/2026.

  • #9794 di @basil-k-aji-dev — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
84/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
python
Ambito
ai, backend

Direzione di ricerca

Leggi lib/crewai/src/crewai/llms/providers/openai/completion.py e confronta _ahandle_streaming_completion con _handle_streaming_completion. Trova il test test_openai_streaming_with_response_model e verifica come copre il percorso asincrono. Il lavoro è completo quando la richiesta di streaming asincrona include lo schema di response_model come response_format e un test verifica gli argomenti della richiesta.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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

Lingua principale
Python
Stelle
61.2k
Fork
9.2k
Merge medio
1g 14h
PR unite (30g)
180

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di crewAIInc/crewAI

Tutte le issue di crewAIInc/crewAI

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.