{"record":{"id":"454d8a5eeb9f9a5a","repo":"BerriAI/litellm","slug":"chat-provider-invalid-function-argument-delta-pa","errorCode":null,"errorMessage":"Chat provider: Invalid function argument delta {parsed_chunk}","messagePattern":"Chat provider: Invalid function argument delta (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/completion_extras/litellm_responses_transformation/transformation.py","lineNumber":1315,"sourceCode":"                    choices=[\n                        StreamingChoices(\n                            index=0,\n                            delta=Delta(\n                                tool_calls=[\n                                    ChatCompletionToolCallChunk(\n                                        id=None,\n                                        index=tool_call_index,\n                                        type=\"function\",\n                                        function=ChatCompletionToolCallFunctionChunk(name=None, arguments=content_part),\n                                    )\n                                ]\n                            ),\n                            finish_reason=None,\n                        )\n                    ]\n                )\n            else:\n                raise ValueError(f\"Chat provider: Invalid function argument delta {parsed_chunk}\")\n        elif event_type == ResponsesAPIStreamEvents.OUTPUT_ITEM_DONE:\n            # New output item added\n            output_item = parsed_chunk.get(\"item\", {})\n            if output_item.get(\"type\") in (\"function_call\", \"custom_tool_call\"):\n                if tool_call_index_map is None:\n                    # Stateless callers (the responses guardrail handler extracting\n                    # tool calls from a buffered output_item.done) get the complete\n                    # tool call; per-stream callers already received it via\n                    # output_item.added and the argument delta events\n                    return ModelResponseStream(\n                        choices=[  # mutable-ok: ModelResponseStream coerces only list choices\n                            StreamingChoices(\n                                index=0,\n                                delta=Delta(\n                                    tool_calls=(\n                                        _tool_call_dict_from_output_item(\n                                            output_item, parsed_chunk.get(\"output_index\", 0)\n                                        ),","sourceCodeStart":1297,"sourceCodeEnd":1333,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/completion_extras/litellm_responses_transformation/transformation.py#L1297-L1333","documentation":"For response.function_call_arguments.delta events the transformer requires a non-None 'delta' field carrying the argument fragment; if delta is missing or None it raises. The delta is the incremental tool-call argument string streamed by the provider.","triggerScenarios":"A provider or proxy emits response.function_call_arguments.delta events with the delta field omitted or null (e.g. an empty keep-alive delta or a non-conformant gateway rewriting events).","commonSituations":"Non-OpenAI providers whose Responses API emulation drops empty deltas instead of omitting the event; proxies that re-serialize events and lose null-adjacent fields; older fixtures recorded before the field was required.","solutions":["Filter out delta events with no payload before transformation: skip if event.get('delta') is None","If behind a gateway, update it or report the event shape divergence","Upgrade litellm in case tolerances for empty deltas have been added"],"exampleFix":"# before\nfor ev in events:\n    chunks = transformer.chunk_parser(ev, ...)\n\n# after — tolerate providers that emit delta events without a payload\nfor ev in events:\n    if ev.get(\"type\") == \"response.function_call_arguments.delta\" and ev.get(\"delta\") is None:\n        continue\n    chunks = transformer.chunk_parser(ev, ...)","handlingStrategy":"validation","validationCode":"def delta_event_valid(ev: dict) -> bool:\n    return ev.get(\"type\") != \"response.function_call_arguments.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 function argument delta\" in str(e):\n        out = None  # tolerate provider emitting empty delta events\n    else:\n        raise","preventionTips":["Filter delta events lacking a payload before transformation","Verify gateway/provider Responses API emulation against OpenAI's event schema"],"tags":["streaming","tool-calls","chunk-transformer","delta"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}