The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
refactor(anthropic): trim hold-back commentary and drop dead rebuilt-content expression
mateo398e3d214cc9
diff --git a/litellm/llms/anthropic/experimental_pass_through/messages/agentic_streaming_iterator.py b/litellm/llms/anthropic/experimental_pass_through/messages/agentic_streaming_iterator.pyindex 4cf348dda9e..a88b148e92c 100644--- a/litellm/llms/anthropic/experimental_pass_through/messages/agentic_streaming_iterator.py+++ b/litellm/llms/anthropic/experimental_pass_through/messages/agentic_streaming_iterator.py@@ -7,14 +7,10 @@ all bytes, and on stream exhaustion rebuilds the full Anthropic responseto run through agentic completion hooks. If an agentic hook fires, thefollow-up response is chained as Phase 2 of the same iterator.-In hold-back mode (``hold_back=True``), chunks are buffered instead of-yielded live, with SSE ping events emitted while the upstream message is-in flight and while the agentic hooks run. On exhaustion the hooks run-first: if a follow-up response replaces the message, only the follow-up-is yielded and the buffered message is dropped; otherwise the buffer is-replayed verbatim, unless it holds a tool_use for a server-fulfilled tool-(e.g. ``headroom_retrieve``), in which case an SSE ``error`` event is-emitted because such a block must never reach a client that cannot+In hold-back mode (``hold_back=True``) chunks are buffered instead of yielded+live, keepalive pings run until the hooks finish, and then either the follow-up+replaces the message or the buffer replays, except that a buffered tool_use for+a server-fulfilled tool fails the turn rather than reaching a client that cannotexecute it."""@@ -329,11 +325,6 @@ class AgenticAnthropicStreamingIterator:verbose_logger.debug("AgenticStreamingIterator: Could not rebuild response from SSE bytes")return- [- (f"{b.get('type')}({b.get('name', '')})" if b.get("type") == "tool_use" else b.get("type"))- for b in rebuilt.get("content", [])- ]-result: Final = await self._http_handler._call_agentic_completion_hooks(response=rebuilt,model=self._model,diff --git a/litellm/llms/custom_httpx/llm_http_handler.py b/litellm/llms/custom_httpx/llm_http_handler.pyindex e9b88e45219..193a38a5404 100644--- a/litellm/llms/custom_httpx/llm_http_handler.py+++ b/litellm/llms/custom_httpx/llm_http_handler.py@@ -5041,13 +5041,7 @@ class BaseLLMHTTPHandler:@staticmethoddef _server_fulfilled_tools_in_request(logging_obj: LiteLLMLoggingObj, tools: object) -> frozenset[str]:- """- The request's tools that a registered callback fulfills server-side (e.g.- ``headroom_retrieve``). The model's tool_use for such a tool must never- reach the client, which cannot execute it: the agentic loop replaces the- whole message with a follow-up response, so a stream carrying any of- these is buffered (with ping keepalives) instead of forwarded live.- """+ """The request's tools that a registered callback fulfills server-side (e.g. ``headroom_retrieve``)."""if not isinstance(tools, list) or not tools:return frozenset()from litellm.litellm_core_utils.prompt_templates.factory import has_tool_with_name