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: clean up fresh tech debt from 2026-10-03 (#44484)
devin-ai-integration[bot]bb4f7211d71e
diff --git a/litellm/decisions/main.py b/litellm/decisions/main.pyindex da037f1d8cb..4864fcaa0e4 100644--- a/litellm/decisions/main.py+++ b/litellm/decisions/main.py@@ -59,7 +59,7 @@ def _resolve_provider_model(model: str, custom_llm_provider: str | None) -> tuplmodel=model,llm_provider=provider,)- upstream_model: Final = model.removeprefix(f"{provider}/") if model.startswith(f"{provider}/") else model+ upstream_model: Final = model.removeprefix(f"{provider}/")if not upstream_model:raise litellm.BadRequestError(message="A model name is required for the Decisions API",diff --git a/litellm/harness/handlers/tool_loop_handler.py b/litellm/harness/handlers/tool_loop_handler.pyindex 33efcba4ff7..d3acb50eadb 100644--- a/litellm/harness/handlers/tool_loop_handler.py+++ b/litellm/harness/handlers/tool_loop_handler.py@@ -267,11 +267,8 @@ class ToolLoopHandler(BaseHarnessHandler):tool_specs: list[ChatCompletionToolParam] = copy.deepcopy( # mutable-ok: acompletion takes tool listlist(self._tool_specs))- request_kwargs: dict[str, object] = { # mutable-ok: acompletion takes keyword arguments- key: value for key, value in self._completion_kwargs.items() if key not in {"messages", "tools"}- }kwargs: dict[str, object] = { # mutable-ok: acompletion takes keyword arguments- **request_kwargs,+ **{key: value for key, value in self._completion_kwargs.items() if key not in {"messages", "tools"}},"messages": messages,**({"tools": tool_specs} if tool_specs else {}),}@@ -287,8 +284,7 @@ class ToolLoopHandler(BaseHarnessHandler):yield Text(content)tool_calls = message.tool_calls or ()if not tool_calls:- final_text = content or ""- ctx.final_text = final_text # rebind-ok: SessionContext is the runtime's per-turn result sink+ ctx.final_text = content or "" # rebind-ok: SessionContext is the runtime's per-turn result sinkctx.output_json = content if ctx.output is not None else None # rebind-ok: per-turn output sinkfinal_message: ChatCompletionMessageParam = {"role": "assistant",diff --git a/litellm/harness/options.py b/litellm/harness/options.pyindex b0014fea393..18865359ba8 100644--- a/litellm/harness/options.py+++ b/litellm/harness/options.py@@ -36,7 +36,7 @@ class DeepAgentsOptions:@dataclass(frozen=True)class ToolLoopOptions:- completion_kwargs: Mapping[str, Any] = field(default_factory=dict)+ completion_kwargs: Mapping[str, object] = field(default_factory=dict)HarnessOptions = ClaudeCodeOptions | CodexOptions | OpenCodeOptions | DeepAgentsOptions | ToolLoopOptionsdiff --git a/litellm/llms/anthropic/files/transformation.py b/litellm/llms/anthropic/files/transformation.pyindex 04d057ed3e9..da21f130f1a 100644--- a/litellm/llms/anthropic/files/transformation.py+++ b/litellm/llms/anthropic/files/transformation.py@@ -125,13 +125,12 @@ class AnthropicFilesConfig(BaseFilesConfig):return self._finalize_headers(headers, auth_header)@staticmethod- def _resolve_params(- litellm_params: dict, api_base: str | None- ) -> tuple[dict | None, str | None]: # mutable-ok: mirrors the sync validate_environment contract this overrides+ def _resolve_params(litellm_params: dict, api_base: str | None) -> tuple[Mapping[str, object] | None, str | None]:params_mapping: Final = litellm_params if isinstance(litellm_params, dict) else None- if api_base is None and params_mapping is not None:- api_base = params_mapping.get("api_base")- return params_mapping, api_base+ resolved_api_base: Final = (+ api_base if api_base is not None or params_mapping is None else params_mapping.get("api_base")+ )+ return params_mapping, resolved_api_base@staticmethoddef _finalize_headers(headers: dict, auth_header: Mapping[str, str] | None) -> dict: # mutable-ok: out-param