Fix Langfuse callback skipping for Anthropic streaming passthrough

Fixes #17476

When using Anthropic pass-through endpoints with streaming and Langfuse
callbacks, streaming requests were completing successfully but failing to
log to Langfuse. Non-streaming requests worked correctly.

Root cause:
- _handle_logging_anthropic_collected_chunks() successfully builds the
  complete response from chunks
- However, kwargs only included response_cost and model, missing the
  complete_streaming_response key
- In litellm_logging.py, Langfuse callback checks for
  complete_streaming_response and skips logging when None

Solution:
- Add complete_streaming_response to kwargs dict before returning
- This ensures callbacks like Langfuse can access the complete response
  and properly log streaming requests

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Josh Vorick 2026-03-09 17:05:03 -04:00
parent 5610945830
commit 8d2413f33f

View file

@ -218,6 +218,9 @@ class AnthropicPassthroughLoggingHandler:
logging_obj=litellm_logging_obj,
)
# Add complete_streaming_response to kwargs so callbacks like Langfuse can access it
kwargs["complete_streaming_response"] = complete_streaming_response
return {
"result": complete_streaming_response,
"kwargs": kwargs,