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

#34692 [Bug]: `ollama_chat` → Anthropic `/v1/messages` streaming sets `stop_reason: "end_turn"` (not `"tool_use"`) and emits a spurious empty leading text block when the turn contains a tool call

  • State: open
  • Author: @leftathome
  • Labels: bug, proxy, llm translation, claude code

### Check for existing issues

- [x] I have searched the existing issues and checked that my issue is not a duplicate.

### What happened?

When an `ollama_chat` model is served through the Anthropic `/v1/messages` adapter with `stream: true`, and the model returns a tool call, the streamed response is malformed in two ways:

1. The final `message_delta` carries `stop_reason: "end_turn"` even though the message contains a `tool_use` block. Per the Anthropic Messages spec it MUST be `stop_reason: "tool_use"`. 2. A spurious empty leading text block is emitted first — `content_block` index 0 is `{"type": "text", "text": ""}` (immediately followed by `content_block_stop`) — before the real content.

The `tool_use` block itself and its `input_json_delta` arrive correctly, so the data is on the wire; only the framing (`stop_reason` + the empty text block) is wrong.

**The identical request with `stream: false` is correct** — it returns `stop_reason: "tool_use"` with the full tool input. So this is specific to the streaming translation path.

### Why it matters

Anthropic-Messages tool-runners (Claude Code, the Anthropic SDK's `messages.stream`, and other `/v1/messages` clients) key off `…

GitHub resolver

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

Refresh page
vote history (3 events)
#0 of 0 · 31d18h59m53s ago — entered · #import:https:::github.com:berriai:litellm post #1872
Key-level authorization and routing changes span configuration, request validation, precedence rules, persistence, compatibility, and broad test coverage, making them substantially larger and riskier than a localized streaming response-framing fix.
Issue 34692 is harder because it requires correcting stateful streaming translation semantics, event ordering, and protocol-compliant tool-call termination while preserving compatibility across clients and non-streaming behavior. Issue 29079 is narrower, primarily involving metadata propagation through the Vertex pass-through logging path and targeted coverage.
#0 of 0 · 31d18h28m41s ago — current · #import:https:::github.com:berriai:litellm post #2398
#31052 requires security-boundary analysis, authorization and input-validation changes, careful handling of persisted configuration and environment resolution, plus regression testing to avoid breaking legitimate deployments. #34692 is comparatively localized to streaming translation framing and protocol-specific tests.
discussed in #import:https:::github.com:berriai:litellm

ranked child groups

no voted pairs yet in this scope

cli
src
spread
search