{"record":{"id":"874fa668484d5a97","repo":"BerriAI/litellm","slug":"chat-provider-invalid-text-delta-parsed-chunk","errorCode":null,"errorMessage":"Chat provider: Invalid text delta {parsed_chunk}","messagePattern":"Chat provider: Invalid text delta (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/completion_extras/litellm_responses_transformation/transformation.py","lineNumber":1381,"sourceCode":"                        )\n                    ]\n                )\n\n        elif event_type == \"response.output_text.delta\":\n            # Content part added to output\n            content_part = parsed_chunk.get(\"delta\", None)\n            if content_part is not None:\n                return ModelResponseStream(\n                    choices=[\n                        StreamingChoices(\n                            index=0,\n                            delta=Delta(content=content_part),\n                            finish_reason=None,\n                        )\n                    ]\n                )\n            else:\n                raise ValueError(f\"Chat provider: Invalid text delta {parsed_chunk}\")\n        elif event_type == \"response.reasoning_summary_text.delta\":\n            content_part = parsed_chunk.get(\"delta\", None)\n            if content_part:\n                return ModelResponseStream(\n                    choices=[\n                        StreamingChoices(\n                            index=cast(int, parsed_chunk.get(\"summary_index\")),\n                            delta=Delta(reasoning_content=content_part),\n                        )\n                    ]\n                )\n        elif event_type == \"response.completed\":\n            # Response is fully complete - now we can signal is_finished=True\n            # This ensures we don't prematurely end the stream before tool_calls arrive\n\n            # Check if response contains function_call items in output\n            # to determine correct finish_reason\n            response_data: Final = parsed_chunk.get(\"response\", {})","sourceCodeStart":1363,"sourceCodeEnd":1399,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/completion_extras/litellm_responses_transformation/transformation.py#L1363-L1399","documentation":"For response.output_text.delta events the transformer requires a non-None 'delta' field with the text fragment; if the event lacks it, it raises. Symmetric to the function-arguments case: the provider streamed a text-delta event without any text payload.","triggerScenarios":"A response.output_text.delta event arrives with delta missing or None — non-conformant providers, proxies rewriting events, or malformed fixtures.","commonSituations":"Gateway emulation quirks; recorded SSE fixtures missing fields; providers that emit empty text deltas as null instead of empty strings.","solutions":["Drop text-delta events whose delta is None before transformation","Treat delta == '' as valid (it is) — only None/missing trips the error","Update or report the gateway producing the malformed event"],"exampleFix":"# before\nfor ev in events:\n    chunks = transformer.chunk_parser(ev, ...)\n\n# after\nfor ev in events:\n    if ev.get(\"type\") == \"response.output_text.delta\" and ev.get(\"delta\") is None:\n        continue\n    chunks = transformer.chunk_parser(ev, ...)","handlingStrategy":"validation","validationCode":"def text_delta_event_valid(ev: dict) -> bool:\n    return ev.get(\"type\") != \"response.output_text.delta\" or ev.get(\"delta\") is not None","typeGuard":null,"tryCatchPattern":"try:\n    out = transformer.chunk_parser(ev, ...)\nexcept ValueError as e:\n    if \"Invalid text delta\" in str(e):\n        out = None  # tolerate empty text-delta events\n    else:\n        raise","preventionTips":["Drop text-delta events with delta=None before transforming","Record and diff provider SSE streams against OpenAI's in integration tests"],"tags":["streaming","chunk-transformer","delta","text"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}