{"record":{"id":"f41f8777666df0d5","repo":"BerriAI/litellm","slug":"error-updating-current-delta-chunks-e-got-tran","errorCode":null,"errorMessage":"Error updating current delta chunks: {e}, got transformed_message: {transformed_message}","messagePattern":"Error updating current delta chunks: (.+?), got transformed_message: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/llms/gemini/realtime/transformation.py","lineNumber":936,"sourceCode":"                any_delta_chunk = False\n                for event in transformed_message:\n                    if event[\"type\"] == \"response.output_text.delta\":\n                        current_delta_chunks.append(cast(OpenAIRealtimeResponseDelta, event))\n                        any_delta_chunk = True\n                if not any_delta_chunk:\n                    current_delta_chunks = None\n            else:\n                if (\n                    transformed_message[\"type\"] == \"response.output_text.delta\"\n                ):  # audio deltas are not accumulated (memory)\n                    if current_delta_chunks is None:\n                        current_delta_chunks = []\n                    current_delta_chunks.append(cast(OpenAIRealtimeResponseDelta, transformed_message))\n                else:\n                    current_delta_chunks = None\n            return current_delta_chunks\n        except Exception as e:\n            raise ValueError(\n                f\"Error updating current delta chunks: {e}, got transformed_message: {transformed_message}\"\n            )\n\n    def update_current_item_chunks(\n        self,\n        transformed_message: OpenAIRealtimeEvents | list[OpenAIRealtimeEvents],\n        current_item_chunks: list[OpenAIRealtimeOutputItemDone] | None,\n    ) -> list[OpenAIRealtimeOutputItemDone] | None:\n        try:\n            if isinstance(transformed_message, list):\n                current_item_chunks = []\n                any_item_chunk = False\n                for event in transformed_message:\n                    if event[\"type\"] == \"response.output_item.done\":\n                        current_item_chunks.append(cast(OpenAIRealtimeOutputItemDone, event))\n                        any_item_chunk = True\n                if not any_item_chunk:\n                    current_item_chunks = None","sourceCodeStart":918,"sourceCodeEnd":954,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/llms/gemini/realtime/transformation.py#L918-L954","documentation":"Raised in update_current_delta_chunks when an exception escapes its accumulation logic. The function inspects transformed_message['type'] to decide whether to append text-delta chunks; if transformed_message is not shaped as expected (not indexable, missing 'type'), a TypeError/KeyError is caught and re-raised as ValueError with the transformed payload.","triggerScenarios":"Calling update_current_delta_chunks with a transformed_message that is not a dict/list-of-dicts containing 'type' — e.g. passing a raw Gemini frame or a string instead of the OpenAI-shaped transformed event.","commonSituations":"Custom integrations invoking the state-management helpers directly with untransformed messages; litellm internal regressions after event-object changes; replay tooling feeding stale event shapes.","solutions":["Only pass messages produced by the transformer (OpenAIRealtimeEvents shapes) into update_current_delta_chunks.","Upgrade litellm if the error occurs inside the library's own pipeline.","Defensively check isinstance(transformed_message, dict) and 'type' in transformed_message before calling."],"exampleFix":"# before\nchunks = config.update_current_delta_chunks(transformed_message=raw_frame, current_delta_chunks=chunks)\n\n# after\nassert isinstance(transformed_message, dict) and 'type' in transformed_message\nchunks = config.update_current_delta_chunks(transformed_message=transformed_message, current_delta_chunks=chunks)\n","handlingStrategy":"type-guard","validationCode":"def is_transformed_event(msg) -> bool:\n    return isinstance(msg, dict) and \"type\" in msg","typeGuard":"def is_transformed_event(msg: object) -> bool:\n    return isinstance(msg, dict) and isinstance(msg.get(\"type\"), str)","tryCatchPattern":"try:\n    chunks = config.update_current_delta_chunks(transformed_message=msg, current_delta_chunks=chunks)\nexcept ValueError as e:\n    if \"Error updating current delta chunks\" in str(e):\n        logger.error(\"State update failed on: %r\", msg)\n        chunks = None  # reset accumulator, continue session\n    else:\n        raise","preventionTips":["Never feed raw Gemini frames into the state helpers; pass transformer output only.","Assert event shape in tests of custom realtime bridges.","Reset accumulators on error rather than aborting the session."],"tags":["gemini","realtime","state-management","internal","type-mismatch"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}