BerriAI/litellm · error · ValueError

Error updating current delta chunks: {e}, got transformed_me

Error message

Error updating current delta chunks: {e}, got transformed_message: {transformed_message}

What it means

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.

Source

Thrown at litellm/llms/gemini/realtime/transformation.py:936

                any_delta_chunk = False
                for event in transformed_message:
                    if event["type"] == "response.output_text.delta":
                        current_delta_chunks.append(cast(OpenAIRealtimeResponseDelta, event))
                        any_delta_chunk = True
                if not any_delta_chunk:
                    current_delta_chunks = None
            else:
                if (
                    transformed_message["type"] == "response.output_text.delta"
                ):  # audio deltas are not accumulated (memory)
                    if current_delta_chunks is None:
                        current_delta_chunks = []
                    current_delta_chunks.append(cast(OpenAIRealtimeResponseDelta, transformed_message))
                else:
                    current_delta_chunks = None
            return current_delta_chunks
        except Exception as e:
            raise ValueError(
                f"Error updating current delta chunks: {e}, got transformed_message: {transformed_message}"
            )

    def update_current_item_chunks(
        self,
        transformed_message: OpenAIRealtimeEvents | list[OpenAIRealtimeEvents],
        current_item_chunks: list[OpenAIRealtimeOutputItemDone] | None,
    ) -> list[OpenAIRealtimeOutputItemDone] | None:
        try:
            if isinstance(transformed_message, list):
                current_item_chunks = []
                any_item_chunk = False
                for event in transformed_message:
                    if event["type"] == "response.output_item.done":
                        current_item_chunks.append(cast(OpenAIRealtimeOutputItemDone, event))
                        any_item_chunk = True
                if not any_item_chunk:
                    current_item_chunks = None

View on GitHub (pinned to 6c2dcb801b)

Solutions

  1. Only pass messages produced by the transformer (OpenAIRealtimeEvents shapes) into update_current_delta_chunks.
  2. Upgrade litellm if the error occurs inside the library's own pipeline.
  3. Defensively check isinstance(transformed_message, dict) and 'type' in transformed_message before calling.

Example fix

# before
chunks = config.update_current_delta_chunks(transformed_message=raw_frame, current_delta_chunks=chunks)

# after
assert isinstance(transformed_message, dict) and 'type' in transformed_message
chunks = config.update_current_delta_chunks(transformed_message=transformed_message, current_delta_chunks=chunks)
Defensive patterns

Strategy: type-guard

Validate before calling

def is_transformed_event(msg) -> bool:
    return isinstance(msg, dict) and "type" in msg

Type guard

def is_transformed_event(msg: object) -> bool:
    return isinstance(msg, dict) and isinstance(msg.get("type"), str)

Try / catch

try:
    chunks = config.update_current_delta_chunks(transformed_message=msg, current_delta_chunks=chunks)
except ValueError as e:
    if "Error updating current delta chunks" in str(e):
        logger.error("State update failed on: %r", msg)
        chunks = None  # reset accumulator, continue session
    else:
        raise

Prevention

When it happens

Trigger: 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.

Common situations: Custom integrations invoking the state-management helpers directly with untransformed messages; litellm internal regressions after event-object changes; replay tooling feeding stale event shapes.

Related errors


AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15). Data as JSON: /api/errors/f41f8777666df0d5. Report an issue: GitHub.