[BUG] Native OpenAI sync streaming with response_model returns an empty string and emits no completed event when the parse is missing

Aperta Adatta ai principianti
#9,788 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.

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

Valutazione

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

Direzione di ricerca

Leggi lib/crewai/src/crewai/llms/providers/openai/completion.py e confronta _handle_streaming_completion con _ahandle_streaming_completion per il caso in cui manchi il parsing. Poi esamina test_openai_streaming_with_response_model e aggiungi una copertura per uno stream la cui completion finale ha parsed = None. Il lavoro è completato quando il percorso sincrono restituisce il testo accumulato ed emette LLMCallCompletedEvent, come nel comportamento asincrono.

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

Descrizione

Description

In the native OpenAI provider, sync streaming with response_model returns an empty string and emits no completion event when the final parse is missing. _handle_streaming_completion only logs "Failed to get parsed result from stream" and returns "", which leaves llm_call_started unpaired. The async twin (_ahandle_streaming_completion) emits the completed event and returns the accumulated text.

Steps to Reproduce
  1. Stream with response_model set and a stream whose final completion has parsed = None (for example a refusal or an empty parse), as in test_openai_streaming_with_response_model.
  2. The call returns "", and no LLMCallCompletedEvent is emitted.
Expected behavior

Like the async path: the completed event fires with the accumulated deltas and the text is returned.

Screenshots/Code snippets

Same event-pairing family as #8496 and #8498, but those cover other paths.

Evidence

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

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.