Skip to content
Closed
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
cdea9c9
refactor: clear fresh tech debt from the last 24 hours (2026-09-05, 2…
mateo-berri Sep 6, 2026
1faefd6
Merge remote-tracking branch 'origin/litellm_internal_staging' into l…
mateo-berri Sep 9, 2026
40e96e3
refactor: clear fresh tech debt from the last 24 hours (2026-09-09)
mateo-berri Sep 9, 2026
223a24a
Merge remote-tracking branch 'origin/litellm_internal_staging' into l…
mateo-berri Sep 10, 2026
0a89eef
refactor: clear fresh tech debt from the last 24 hours (2026-09-10)
mateo-berri Sep 10, 2026
2d0ee09
refactor: keep the pre-existing cost-estimate comment and usage cost …
mateo-berri Sep 10, 2026
65eddb5
Merge remote-tracking branch 'origin/litellm_internal_staging' into l…
mateo-berri Sep 13, 2026
a84163f
refactor: clear fresh tech debt from the last 24 hours (2026-09-13)
mateo-berri Sep 13, 2026
1bc2438
refactor: keep the model info pricing helper out of the cleanup
mateo-berri Sep 13, 2026
dd0c118
Merge remote-tracking branch 'origin/main' into litellm_techdebt_2026…
devin-ai-integration[bot] Sep 16, 2026
229add2
refactor: drop suppressions that no longer suppress anything (2026-09…
devin-ai-integration[bot] Sep 16, 2026
76cb86b
refactor: keep the rebind-ok reason inside the line limit
devin-ai-integration[bot] Sep 16, 2026
715f099
fix(anthropic): rebuild the refusal message_delta by spreading the chunk
devin-ai-integration[bot] Sep 16, 2026
279ac56
Merge remote-tracking branch 'origin/main' into litellm_techdebt_2026…
devin-ai-integration[bot] Sep 17, 2026
90ea534
refactor: clear fresh tech debt from the last 24 hours (2026-09-17)
devin-ai-integration[bot] Sep 17, 2026
a55aa85
Merge remote-tracking branch 'origin/main' into litellm_techdebt_2026…
devin-ai-integration[bot] Sep 18, 2026
f349b1c
refactor: clear fresh tech debt from the last 24 hours (2026-09-18)
devin-ai-integration[bot] Sep 18, 2026
412714e
Merge remote-tracking branch 'origin/main' into litellm_techdebt_2026…
devin-ai-integration[bot] Sep 19, 2026
6290f99
refactor: clear fresh tech debt from the last 24 hours (2026-09-19)
devin-ai-integration[bot] Sep 19, 2026
523d61d
refactor: keep the pre-existing protected-resource return type out of…
devin-ai-integration[bot] Sep 19, 2026
52df288
Merge remote-tracking branch 'origin/main' into litellm_techdebt_2026…
devin-ai-integration[bot] Sep 20, 2026
6110536
refactor: clear fresh tech debt from the last 24 hours (2026-09-20)
devin-ai-integration[bot] Sep 20, 2026
3e16241
Merge remote-tracking branch 'origin/main' into litellm_techdebt_2026…
devin-ai-integration[bot] Sep 22, 2026
c54de16
refactor: type fresh getattr, Any, and bare dict debt from 2026-09-22
devin-ai-integration[bot] Sep 22, 2026
28a1ac2
fix(mcp): keep the string guard on tools/list next_cursor
devin-ai-integration[bot] Sep 22, 2026
018a6a9
refactor(vercel_ai_gateway): type the embedding error headers dict
devin-ai-integration[bot] Sep 22, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion litellm/litellm_core_utils/litellm_logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -4881,7 +4881,7 @@ def _maybe_construct_otel_v2(callback_name: str, _in_memory_loggers: list[Custom
for callback in _in_memory_loggers:
if (
isinstance(callback, OpenTelemetryV2)
and getattr(callback, "callback_name", None) == callback_name
and callback.callback_name == callback_name
and (serves_a_destination or not _exports_nowhere(callback.config))
):
return callback
Expand Down
4 changes: 2 additions & 2 deletions litellm/litellm_core_utils/prompt_templates/common_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2014,11 +2014,11 @@ def strip_encrypted_reasoning_from_messages(messages: object) -> None:
"""
if not isinstance(messages, list):
return
for content in _anthropic_content_lists(cast(list[object], messages)): # cast-ok: untyped client json
for content in anthropic_content_lists(cast(list[object], messages)): # cast-ok: untyped client json
_strip_encrypted_reasoning_from_blocks(content)


def _anthropic_content_lists(messages: Sequence[object]) -> Iterator[object]:
def anthropic_content_lists(messages: Sequence[object]) -> Iterator[object]:
return (
cast(list[object], content) # cast-ok: narrowed by isinstance
for message in messages
Expand Down
2 changes: 1 addition & 1 deletion litellm/litellm_core_utils/streaming_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -1480,7 +1480,7 @@ def _dispatch_provider_chunk(
"is_finished": chunk_finish_reason is not None,
"finish_reason": chunk_finish_reason,
"original_chunk": cached_chunk,
"tool_calls": (getattr(cached_choice.delta, "tool_calls", None) if cached_choice is not None else None),
"tool_calls": cached_choice.delta.tool_calls if cached_choice is not None else None,
}

completion_obj["content"] = response_obj["text"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
Final,
Literal,
Protocol,
cast, # noqa: TID251 # rebuilt message_delta dict spans the ContentBlockDelta/MessageBlockDelta union
get_args,
)

Expand All @@ -25,6 +24,7 @@
ContentBlockDelta,
ContextManagementResponse,
MessageBlockDelta,
MessageDelta,
StreamingContentBlockDeltaType,
UsageDelta,
UsageIteration,
Expand Down Expand Up @@ -1006,26 +1006,28 @@ def _with_refusal_stop_details(
self,
processed_chunk: ContentBlockDelta | MessageBlockDelta,
) -> ContentBlockDelta | MessageBlockDelta:
if processed_chunk.get("type") != "message_delta" or not self._refusal_text:
if processed_chunk["type"] != "message_delta" or not self._refusal_text:
return processed_chunk
delta: Final = cast(Mapping[str, object], processed_chunk["delta"]) # cast-ok: keys checked before use
delta: Final = processed_chunk["delta"]
if delta.get("stop_reason") == "max_tokens":
return processed_chunk
from litellm.llms.anthropic.experimental_pass_through.messages.utils import (
refusal_stop_details,
)

return cast( # cast-ok: rebuilt dict matches the message_delta TypedDict shape for this branch
ContentBlockDelta | MessageBlockDelta,
{ # mutable-ok: fresh translation payload; never mutated after construction
**processed_chunk,
"delta": { # mutable-ok: fresh message_delta payload; never mutated after construction
**delta,
"stop_reason": "refusal",
"stop_details": refusal_stop_details(self._refusal_text),
},
},
)
refusal_delta: Final[MessageDelta] = { # mutable-ok: fresh message_delta payload
**delta,
"stop_reason": "refusal",
"stop_details": refusal_stop_details(self._refusal_text),
}
if "context_management" in processed_chunk:
return MessageBlockDelta(
type="message_delta",
delta=refusal_delta,
usage=processed_chunk["usage"],
context_management=processed_chunk["context_management"],
)
return MessageBlockDelta(type="message_delta", delta=refusal_delta, usage=processed_chunk["usage"])

@staticmethod
def _delta_has_content(processed_chunk: Mapping[str, object]) -> bool:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def _mapping_field(container: object, key: str) -> object | None:
"""One key of a raw provider payload, or None when the payload is not a mapping."""
if not isinstance(container, Mapping):
return None
return cast(Mapping[str, object], container).get(key) # cast-ok: raw payload, callers re-check every value
return container.get(key)


def _mapping_str_field(container: object, key: str) -> str | None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ def _thinking_block_from_reasoning_item(
cls,
summary: Iterable[object],
encrypted_content: object,
) -> dict[str, Any] | None: # mutable-ok: API message payload
) -> dict[str, object] | None: # mutable-ok: API message payload
"""The one Anthropic block for a Responses reasoning item.

The item's encrypted reasoning rides the block's opaque field (`signature`, or
Expand Down Expand Up @@ -200,7 +200,7 @@ def _assistant_block_group_key(indexed_block: tuple[int, Mapping[str, object]])
@classmethod
def _assistant_group_to_input_items(
cls, group: tuple[Mapping[str, object], ...]
) -> tuple[dict[str, Any], ...]: # mutable-ok: API message payload
) -> tuple[dict[str, object], ...]: # mutable-ok: API message payload
first: Final = group[0]
btype: Final = first.get("type")
if btype in ("thinking", "redacted_thinking"):
Expand Down
5 changes: 3 additions & 2 deletions litellm/proxy/_experimental/mcp_server/tool_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,15 @@ def with_mcp_proxy_identity(tool: Tool, server_id: str) -> Tool:


def _mcp_proxy_identity(tool: Tool) -> MCPProxyToolIdentity:
identity: Final = (tool.meta or {}).get(_MCP_PROXY_IDENTITY_META_KEY) # mutable-ok: absent metadata default
identity: Final = None if tool.meta is None else tool.meta.get(_MCP_PROXY_IDENTITY_META_KEY)
if not isinstance(identity, Mapping):
raise TypeError("MCP proxy tool identity is missing")
server_id: Final = identity.get("server_id")
tool_name: Final = identity.get("tool_name")
if not isinstance(server_id, str) or not isinstance(tool_name, str):
raise TypeError("MCP proxy tool identity is invalid")
return {"server_id": server_id, "tool_name": tool_name} # mutable-ok: TypedDict identity payload
resolved: Final[MCPProxyToolIdentity] = {"server_id": server_id, "tool_name": tool_name}
return resolved


def mcp_proxy_tool_id(tool: Tool) -> str:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import asyncio
import re
from collections.abc import Mapping
from datetime import datetime
from typing import TYPE_CHECKING, Any, Final, cast
from urllib.parse import urlparse
Expand Down Expand Up @@ -380,7 +381,7 @@ def _handle_audio_predict_response(
@staticmethod
def _is_audio_predict_response(
model: str,
json_response: dict, # mutable-ok: predicate inspects the decoded provider response dictionary without mutation
json_response: Mapping[str, object],
) -> bool:
return (
VertexPassthroughLoggingHandler._get_audio_prediction_count(json_response=json_response) > 0
Expand All @@ -389,7 +390,7 @@ def _is_audio_predict_response(

@staticmethod
def _get_audio_prediction_count(
json_response: dict, # mutable-ok: counter inspects the decoded provider response dictionary without mutation
json_response: Mapping[str, object],
) -> int:
predictions: Final = json_response.get("predictions")
if not isinstance(predictions, list):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
)
from litellm.integrations.custom_logger import CustomLogger, Span
from litellm.litellm_core_utils.prompt_templates.common_utils import (
anthropic_content_lists,
encrypted_content_of_block,
strip_encrypted_reasoning_from_messages,
)
Expand Down Expand Up @@ -154,10 +155,7 @@ def _anthropic_content_blocks(messages: object) -> Iterator[Mapping[str, object]
return iter(())
return (
cast(Mapping[str, object], block) # cast-ok: narrowed by isinstance
for message in cast(list[object], messages) # cast-ok: narrowed by isinstance
if isinstance(message, Mapping)
for content in (cast(Mapping[str, object], message).get("content"),) # cast-ok: narrowed by isinstance
if isinstance(content, list)
for content in anthropic_content_lists(cast(list[object], messages)) # cast-ok: narrowed by isinstance
for block in cast(list[object], content) # cast-ok: narrowed by isinstance
if isinstance(block, Mapping)
)
Expand Down
1 change: 0 additions & 1 deletion litellm/types/llms/bedrock.py
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,6 @@ class AmazonTitanMultimodalEmbeddingResponse(TypedDict):
message: str # Specifies any errors that occur during generation.


# TwelveLabs Marengo Embed types
TWELVELABS_EMBEDDING_INPUT_TYPES = Literal["text", "image", "video", "audio"]
TWELVELABS_EMBEDDING_OPTIONS = Literal["visual-text", "visual-image", "audio"]

Expand Down
Loading