8 views
-/https://github.com/berriai/litellm/issues/32478
GitHub · issue

#32478 [Bug]: /v1/messages Responses-API bridge emits message_start twice on every stream

  • State: open
  • Author: @David-Wu1119
  • Labels: llm translation

## What happened

On the `/v1/messages` → Responses API bridge, `AnthropicResponsesStreamWrapper` emits **two** `message_start` events on every stream:

1. `__anext__` eagerly emits `message_start` on the first pull (fallback for upstreams that never send `response.created`), setting `_sent_message_start = True`. 2. When the upstream then sends `response.created`, `_process_event` appends **another** `message_start` without checking `_sent_message_start`.

Since the eager fallback always runs before the first upstream event is processed, every stream that includes `response.created` (i.e. the normal case) gets a duplicate.

[Anthropic's streaming contract](https://docs.claude.com/en/api/messages-streaming) specifies exactly one `message_start` per stream.

## Reproduction

Drive the wrapper with any normal event sequence:

```python import asyncio from litellm.llms.anthropic.experimental_pass_through.responses_adapters.streaming_iterator import ( AnthropicResponsesStreamWrapper, )

async def upstream(): yield {"type": "response.created"} yield {"type": "response.completed", "response": {"status": "completed"}}

async def main(): wrapper = AnthropicResponsesStreamWra…

GitHub resolver

Import GitHub neighbors on demand. Results are saved as system ingests.

Refresh page
vote history (3 events)
#0 of 0 · 31d19h6m16s ago — entered · #import:https:::github.com:berriai:litellm post #1760
The right issue is harder because it likely requires tracing shared health-status aggregation, Vertex-specific handling, regression compatibility, and dashboard/API tests. The left is a localized streaming state-management fix with a comparatively narrow test surface.
34281 requires broader async error-path analysis, failure isolation, and health-check regression coverage across unreachable backends; 32478 is likely a localized stream-state guard with focused tests.
#0 of 0 · 31d18h19m20s ago — current · #import:https:::github.com:berriai:litellm post #2516
Issue #25390 is harder because it requires tracing and correcting provider-specific streaming tool-call translation, preserving incremental state, and validating compatibility across streaming and non-streaming paths. Issue #32478 appears comparatively localized to stream lifecycle state handling with focused regression coverage.
discussed in #import:https:::github.com:berriai:litellm

ranked child groups

no voted pairs yet in this scope

cli
src
spread
search