{"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":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/completion_extras/litellm_responses_transformation/transformation.py","lineNumber":1317,"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":1299,"sourceCodeEnd":1335,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/completion_extras/litellm_responses_transformation/transformation.py#L1299-L1335","documentation":"A Responses API streaming event of type response.function_call_arguments.delta or response.custom_tool_call_input.delta arrived without a usable 'delta' payload — the field is missing, None, or an empty string. Since the delta text is the only content of these events, the translator cannot produce a tool-call argument fragment and raises with the full chunk echoed. It almost always indicates a provider/gateway emitting non-conforming delta events.","triggerScenarios":"A provider streaming function-call argument deltas that omits the delta field on some events (seen with nonstandard OpenAI-compatible gateways); a final flush event with empty delta; middleware rewriting events and dropping the delta key; fabricated test streams missing the field.","commonSituations":"Third-party gateways in front of Responses-API models with imperfect SSE fidelity; tool-calling agents streaming through the bridge; versions of litellm before empty-delta tolerance was added; recording/replay fixtures that lost fields.","solutions":["Upgrade litellm — argument-delta handling has been made more tolerant across releases","Capture the raw event from the error text and report the non-conforming provider/gateway","If you control the event source, always include 'delta' (empty string events should simply not be sent)","Wrap custom translation loops to skip delta events where event.get('delta') is falsy"],"exampleFix":"// before\nout = translate_responses_chunk_to_openai_stream(event)  # event has no 'delta' key -> ValueError: Chat provider: Invalid function argument delta\n\n// after\nif event.get(\"type\") in (\"response.function_call_arguments.delta\",\n                          \"response.custom_tool_call_input.delta\") and not event.get(\"delta\"):\n    continue  # skip non-conforming empty delta events\nout = translate_responses_chunk_to_openai_stream(event)","handlingStrategy":"fallback","validationCode":"DELTA_EVENTS = (\"response.function_call_arguments.delta\",\n                 \"response.custom_tool_call_input_delta\")\n\ndef delta_event_is_translatable(chunk: dict) -> bool:\n    if chunk.get(\"type\") in DELTA_EVENTS and not chunk.get(\"delta\"):\n        return False  # non-conforming event without payload: skip it\n    return True","typeGuard":"def has_delta_payload(chunk: dict) -> bool:\n    return bool(chunk.get(\"delta\")) or chunk.get(\"type\") not in (\"response.function_call_arguments.delta\", \"response.custom_tool_call_input_delta\")","tryCatchPattern":"try:\n    out = translate_responses_chunk_to_openai_stream(chunk)\nexcept ValueError as e:\n    if \"Invalid function argument delta\" in str(e):\n        logger.debug(\"skipping delta event without payload: %s\", chunk)\n        out = None  # skip and continue the stream; argument fragments arrive in other events\n    else:\n        raise","preventionTips":["Skip delta-class events whose 'delta' field is missing or empty instead of aborting the whole stream","Capture offending raw events for the bug report — the provider/gateway is non-conforming","Upgrade litellm, where tolerance for empty argument deltas improves across releases"],"tags":["streaming","tool-calling","sse","responses-api"],"backgroundTag":"invalid-streaming-delta","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}