{"record":{"id":"f05e4cf287afdf72","repo":"BerriAI/litellm","slug":"error-updating-current-item-chunks-e-got-trans","errorCode":null,"errorMessage":"Error updating current item chunks: {e}, got transformed_message: {transformed_message}","messagePattern":"Error updating current item chunks: (.+?), got transformed_message: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/llms/gemini/realtime/transformation.py","lineNumber":964,"sourceCode":"            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\n            else:\n                if transformed_message[\"type\"] == \"response.output_item.done\":\n                    if current_item_chunks is None:\n                        current_item_chunks = []\n                    current_item_chunks.append(cast(OpenAIRealtimeOutputItemDone, transformed_message))\n                else:\n                    current_item_chunks = None\n            return current_item_chunks\n        except Exception as e:\n            raise ValueError(f\"Error updating current item chunks: {e}, got transformed_message: {transformed_message}\")\n\n    def transform_response_done_event(\n        self,\n        message: BidiGenerateContentServerMessage,\n        current_response_id: str | None,\n        current_conversation_id: str | None,\n        output_items: list[OpenAIRealtimeOutputItemDone] | None,\n        session_configuration_request: str | None = None,\n    ) -> OpenAIRealtimeDoneEvent:\n        if current_conversation_id is None:\n            current_conversation_id = f\"conv_{uuid.uuid4()}\"\n        if current_response_id is None:\n            current_response_id = f\"resp_{uuid.uuid4()}\"\n\n        if session_configuration_request:\n            session_configuration_request_dict: BidiGenerateContentSetup = json.loads(\n                session_configuration_request\n            ).get(\"setup\", {})","sourceCodeStart":946,"sourceCodeEnd":982,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/llms/gemini/realtime/transformation.py#L946-L982","documentation":"Raised in update_current_item_chunks, the item-level counterpart of the delta-chunk accumulator. It reads transformed_message['type'] looking for 'response.output_item.done'; any exception (non-dict input, missing 'type') is caught and re-raised as ValueError embedding the transformed_message. Guards internal state consistency while assembling completed output items.","triggerScenarios":"Passing a transformed_message that is not a dict with a 'type' key (raw string, Gemini-native frame, None) into update_current_item_chunks; list inputs whose elements are malformed.","commonSituations":"Direct use of the realtime transformer's state helpers in custom bridges; version mismatches between the transformer and hand-rolled event producers; test fixtures with simplified event dicts.","solutions":["Feed only transformer-output events (OpenAIRealtimeEvents) into this helper.","Add a shape check (dict with 'type') before calling.","Upgrade litellm when the error originates inside the library loop."],"exampleFix":"# before\nitems = config.update_current_item_chunks(transformed_message=frame, current_item_chunks=items)\n\n# after\nif not (isinstance(frame, dict) and 'type' in frame):\n    raise TypeError('expected transformed OpenAI realtime event dict')\nitems = config.update_current_item_chunks(transformed_message=frame, current_item_chunks=items)\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    items = config.update_current_item_chunks(transformed_message=msg, current_item_chunks=items)\nexcept ValueError as e:\n    if \"Error updating current item chunks\" in str(e):\n        logger.error(\"Item state update failed on: %r\", msg)\n        items = None\n    else:\n        raise","preventionTips":["Feed only OpenAI-shaped transformed events into item-chunk accumulation.","Keep transformer and state-helper versions in lockstep (same litellm release).","Log the failing payload to spot producer/consumer shape mismatches early."],"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"}