6 views
-/https://github.com/berriai/litellm/issues/31121
GitHub · issue

#31121 [Bug]: Non-streaming /v1/messages (anthropic_messages) emits duplicate litellm_request OTEL spans + double success/cost callbacks

  • State: open
  • Author: @ashudeep
  • Labels: llm translation

### What happened?

A single **non-streaming** `POST /v1/messages` (the dedicated Anthropic Messages endpoint) emits **two** OpenTelemetry spans named `litellm_request` for the one request. Both spans carry identical input/output/token-usage and identical duration, but **different** (regenerated) response ids (`chatcmpl-...`). The success path runs twice as well, so the cost/spend logging and any registered success callback fire twice per request.

A plain `POST /chat/completions` against the same proxy/config does **not** double — the issue is specific to the `/v1/messages` (`anthropic_messages`) path.

This is the **non-streaming** counterpart of the streaming pass-through duplication fixed in #29550 / #29598. That fix is guarded by `logging_obj.stream is True`, so it does not cover this non-streaming case.

### Version

`v1.82.3` (also present on `main` at time of filing).

### Minimal reproduction

`config.yaml`:

```yaml model_list: - model_name: claude litellm_params: model: anthropic/claude-3-5-sonnet-latest api_key: os.environ/ANTHROPIC_API_KEY

litellm_settings: success_callback: ["otel"] ```

Env: `OTEL_EXPORTER_OTLP_ENDPOINT=...` (any OTLP backend; a …

GitHub resolver

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

Refresh page
vote history (2 events)
#0 of 0 · 31d18h30m31s ago — entered · #import:https:::github.com:berriai:litellm post #2442
31121 requires tracing a request through multiple execution and callback layers, isolating path-specific control flow, and preventing duplicate side effects without regressing related streaming behavior. 33440 is a more localized configuration, validation, propagation, and test change with limited behavioral risk.
#0 of 0 · 31d17h52m34s ago — current · #import:https:::github.com:berriai:litellm post #3098
The left issue likely requires tracing and correcting budget enforcement across team, member, key, and request-accounting paths, with careful handling of limits, persistence, concurrency, and regression coverage. The right issue appears narrower: isolate a duplicated non-streaming instrumentation/callback path and apply a targeted guard or refactor, followed by focused tests.
discussed in #import:https:::github.com:berriai:litellm

ranked child groups

no voted pairs yet in this scope

cli
src
spread
search