Skip to content

Commit 0b353ab

Browse files
fix(responses): drop redundant SSE prefix strip after SSEDecoder switch
SSEDecoder already strips the 'data:' field prefix from each event, so the extra call to _strip_sse_data_from_chunk on sse.data was redundant and could incorrectly mangle payloads whose actual content starts with 'data:'. Co-authored-by: Yassin Kortam <[email protected]>
1 parent 0923b6e commit 0b353ab

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

litellm/responses/streaming_iterator.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
from litellm.responses.utils import ResponsesAPIRequestUtils
2929
from litellm.types.llms.openai import ResponsesAPIStreamEvents
3030
from litellm.types.utils import CallTypes
31-
from litellm.utils import CustomStreamWrapper, async_post_call_success_deployment_hook
31+
from litellm.utils import async_post_call_success_deployment_hook
3232

3333

3434
@lru_cache(maxsize=1)
@@ -121,10 +121,10 @@ def _process_chunk(self, chunk) -> Optional[Any]:
121121
if not chunk:
122122
return None
123123

124-
# Handle SSE format (data: {...})
125-
chunk = CustomStreamWrapper._strip_sse_data_from_chunk(chunk)
126-
if chunk is None:
127-
return None
124+
# NOTE: ``SSEDecoder`` already strips the SSE ``data:`` field prefix, so
125+
# the value passed in here is the raw field content. Do not re-run
126+
# ``_strip_sse_data_from_chunk`` on it — doing so would incorrectly mangle
127+
# payloads whose actual JSON value happens to start with ``data:``.
128128

129129
# Handle "[DONE]" marker
130130
if chunk == STREAM_SSE_DONE_STRING:

0 commit comments

Comments
 (0)