From 8d2413f33fbc345418d33902a26f40fe182eee46 Mon Sep 17 00:00:00 2001 From: Josh Vorick Date: Mon, 9 Mar 2026 17:05:03 -0400 Subject: [PATCH] Fix Langfuse callback skipping for Anthropic streaming passthrough MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- .../anthropic_passthrough_logging_handler.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/litellm/proxy/pass_through_endpoints/llm_provider_handlers/anthropic_passthrough_logging_handler.py b/litellm/proxy/pass_through_endpoints/llm_provider_handlers/anthropic_passthrough_logging_handler.py index e70d6cb7fca..56766134fd3 100644 --- a/litellm/proxy/pass_through_endpoints/llm_provider_handlers/anthropic_passthrough_logging_handler.py +++ b/litellm/proxy/pass_through_endpoints/llm_provider_handlers/anthropic_passthrough_logging_handler.py @@ -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,