diff --git a/litellm/a2a_protocol/card_resolver.py b/litellm/a2a_protocol/card_resolver.py index 5b837b654cd..d13c97c7bf4 100644 --- a/litellm/a2a_protocol/card_resolver.py +++ b/litellm/a2a_protocol/card_resolver.py @@ -5,9 +5,10 @@ Extends the A2A SDK's card resolver to support multiple well-known paths and fixes agent card URL issues where the card contains internal/localhost URLs. """ -from typing import TYPE_CHECKING, Any, Dict, List, Optional +from typing import TYPE_CHECKING, Any, Dict, Optional from litellm._logging import verbose_logger +from litellm.constants import LOCALHOST_URL_PATTERNS if TYPE_CHECKING: from a2a.types import AgentCard @@ -26,16 +27,6 @@ try: except ImportError: pass -# Patterns that indicate a localhost/internal URL that should be replaced -# with the original base_url. This is a common misconfiguration where -# developers deploy agents with development URLs in their agent cards. -LOCALHOST_URL_PATTERNS: List[str] = [ - "localhost", - "127.0.0.1", - "0.0.0.0", - "[::1]", # IPv6 localhost -] - def is_localhost_or_internal_url(url: Optional[str]) -> bool: """ diff --git a/litellm/constants.py b/litellm/constants.py index 25decd363a6..57670f2199a 100644 --- a/litellm/constants.py +++ b/litellm/constants.py @@ -306,6 +306,15 @@ DEFAULT_MAX_TOKENS_FOR_TRITON = int(os.getenv("DEFAULT_MAX_TOKENS_FOR_TRITON", 2 #### Networking settings #### request_timeout: float = float(os.getenv("REQUEST_TIMEOUT", 6000)) # time in seconds DEFAULT_A2A_AGENT_TIMEOUT: float = float(os.getenv("DEFAULT_A2A_AGENT_TIMEOUT", 6000)) # 10 minutes +# Patterns that indicate a localhost/internal URL in A2A agent cards that should be +# replaced with the original base_url. This is a common misconfiguration where +# developers deploy agents with development URLs in their agent cards. +LOCALHOST_URL_PATTERNS: List[str] = [ + "localhost", + "127.0.0.1", + "0.0.0.0", + "[::1]", # IPv6 localhost +] STREAM_SSE_DONE_STRING: str = "[DONE]" STREAM_SSE_DATA_PREFIX: str = "data: " ### SPEND TRACKING ###