litellm - ✅(Solved) Fix [Bug]: Response.incomplete is unhandled in responses->chat streaming transform and drops content_filters [1 pull requests, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
BerriAI/litellm#27186Fetched 2026-05-06 06:15:38
View on GitHub
Comments
0
Participants
1
Timeline
4
Reactions
0
Author
Participants
Timeline (top)
labeled ×2cross-referenced ×1referenced ×1

Fix Action

Fixed

PR fix notes

PR #27266: fix(responses): handle response.incomplete streaming event in Responses->Chat transform

Description (problem / solution / changelog)

Summary

The Responses API streaming transform (LiteLLMResponsesAPIStreamingIterator) did not handle the response.incomplete event type, which is sent by Azure OpenAI when generation ends due to max_output_tokens being reached or a content filter trigger. The event fell through to the else: pass branch, silently discarding incomplete_details and content_filters.

Root cause

In litellm/completion_extras/litellm_responses_transformation/transformation.py, the _handle_event method handled response.completed, response.failed, and response.cancelled but had no branch for response.incomplete.

Fix

Add an elif event_type == "response.incomplete": handler that:

  • Maps incomplete_details.reason to a standard finish_reason:
    • "max_output_tokens""length"
    • "content_filter""content_filter"
    • anything else → "stop"
  • Forwards content_filters and incomplete_details via provider_specific_fields so callers can inspect the raw values
  • Extracts usage from the event if present
  • Returns a terminal ModelResponseStream with the correct finish_reason, matching the pattern already used by response.failed and response.cancelled

Fixes #27186

Changed files

  • litellm/completion_extras/litellm_responses_transformation/transformation.py (modified, +51/-0)

Code Example

verbose_logger.debug(
    f"Chat provider: Unhandled event type '{event_type}', creating empty chunk"
)

---
RAW_BUFFERClick to expand / collapse

Check for existing issues

  • I have searched the existing issues and checked that my issue is not a duplicate.

What happened?

Bug description

When using a Responses API compatible provider in streaming mode (Azure OpenAI), LiteLLM does not handle the response.incomplete event in: litellm/completion_extras/litellm_responses_transformation/transformation.py

Instead it falls through to:

verbose_logger.debug(
    f"Chat provider: Unhandled event type '{event_type}', creating empty chunk"
)

This causes terminal metadata like response.content_filters to be dropped before downstream callbacks / guardrails (e.g. async_post_call_streaming_iterator_hook() in CustomLogger) can inspect it.

Expected behavior:

  • response.incomplete should be explicitly handled
  • content_filters / incomplete_details should be forwarded on the streamed ModelResponseStream, ideally via provider_specific_fields

Relevant code path

Current unhandled-event fallback is in:

litellm/completion_extras/litellm_responses_transformation/transformation.py

The transform in this version handles events:

  • response.created
  • response.output_item.added
  • response.function_call_arguments.delta
  • response.output_item.done
  • response.output_text.delta
  • response.reasoning_summary_text.delta
  • response.completed

But it does not explicitly handle terminal events like:

  • response.incomplete

Relevant log output

What part of LiteLLM is this about?

No response

What LiteLLM version are you on ?

v1.83.14-stable

Twitter / LinkedIn details

No response

extent analysis

TL;DR

Modify the transformation.py file to explicitly handle the response.incomplete event and forward relevant metadata like content_filters via provider_specific_fields.

Guidance

  • Identify the transformation.py file in litellm/completion_extras/litellm_responses_transformation/ and locate the event handling logic.
  • Add a new condition to handle the response.incomplete event, similar to existing event handlers.
  • Update the ModelResponseStream to include provider_specific_fields with content_filters and incomplete_details when handling response.incomplete.
  • Verify the fix by checking if terminal metadata is correctly forwarded to downstream callbacks.

Example

if event_type == 'response.incomplete':
    # Handle response.incomplete event
    provider_specific_fields = {
        'content_filters': response.content_filters,
        'incomplete_details': response.incomplete_details
    }
    # Forward metadata via ModelResponseStream

Notes

This fix assumes that the response.incomplete event is not handled elsewhere in the codebase. Additional testing may be required to ensure the fix does not introduce regressions.

Recommendation

Apply workaround: Modify the transformation.py file to handle the response.incomplete event, as this is a specific fix for the reported issue and does not require upgrading to a different version.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING