diff --git a/litellm/types/utils.py b/litellm/types/utils.py index 5f66ba1fd0a..9fc6350dddc 100644 --- a/litellm/types/utils.py +++ b/litellm/types/utils.py @@ -40,7 +40,7 @@ from pydantic import ( field_validator, model_validator, ) -from typing_extensions import Required, TypedDict +from typing_extensions import NotRequired, Required, TypedDict from litellm._uuid import uuid from litellm.types.llms.base import ( @@ -164,7 +164,7 @@ class AgenticLoopParams(TypedDict, total=False): custom_llm_provider: str """The LLM provider name (e.g., 'bedrock', 'anthropic')""" - api_key: str + api_key: NotRequired[Optional[str]] """Deployment-specific API key resolved by get_llm_provider() (optional). Stored so agentic follow-up calls (e.g. websearch interception) reuse the @@ -172,7 +172,7 @@ class AgenticLoopParams(TypedDict, total=False): provider env vars. """ - api_base: str + api_base: NotRequired[Optional[str]] """Deployment-specific API base URL resolved by get_llm_provider() (optional).""" diff --git a/tests/test_litellm/llms/anthropic/experimental_pass_through/messages/test_anthropic_experimental_pass_through_messages_handler.py b/tests/test_litellm/llms/anthropic/experimental_pass_through/messages/test_anthropic_experimental_pass_through_messages_handler.py index cd9589eaa7d..0a179aab789 100644 --- a/tests/test_litellm/llms/anthropic/experimental_pass_through/messages/test_anthropic_experimental_pass_through_messages_handler.py +++ b/tests/test_litellm/llms/anthropic/experimental_pass_through/messages/test_anthropic_experimental_pass_through_messages_handler.py @@ -530,7 +530,7 @@ def test_agentic_loop_params_preserves_dynamic_api_key_and_api_base(): ), patch("litellm.completion", return_value="test-response"), ): - try: + with pytest.raises(Exception): anthropic_messages_handler( max_tokens=100, messages=[{"role": "user", "content": "hi"}], @@ -540,8 +540,6 @@ def test_agentic_loop_params_preserves_dynamic_api_key_and_api_base(): api_base="https://my-proxy.example.com/v1", litellm_logging_obj=logging_obj, ) - except (ValueError, TypeError, AttributeError): - pass agentic_loop_params = logging_obj.model_call_details.get("agentic_loop_params") assert agentic_loop_params is not None @@ -572,7 +570,7 @@ def test_agentic_loop_params_omits_keys_when_dynamic_values_are_none(): ), patch("litellm.completion", return_value="test-response"), ): - try: + with pytest.raises(Exception): anthropic_messages_handler( max_tokens=100, messages=[{"role": "user", "content": "hi"}], @@ -580,8 +578,6 @@ def test_agentic_loop_params_omits_keys_when_dynamic_values_are_none(): custom_llm_provider="anthropic", litellm_logging_obj=logging_obj, ) - except (ValueError, TypeError, AttributeError): - pass agentic_loop_params = logging_obj.model_call_details.get("agentic_loop_params") assert agentic_loop_params is not None