diff --git a/agent/model_metadata.py b/agent/model_metadata.py index 724457fd8..0ce9d0c63 100644 --- a/agent/model_metadata.py +++ b/agent/model_metadata.py @@ -441,6 +441,10 @@ def is_local_endpoint(base_url: str) -> bool: # Docker / Podman / Lima internal DNS names (e.g. host.docker.internal) if any(host.endswith(suffix) for suffix in _CONTAINER_LOCAL_SUFFIXES): return True + # Unqualified hostnames (no dots) are local by definition — Docker + # Compose service names, /etc/hosts entries, or mDNS names. + if host and "." not in host: + return True # RFC-1918 private ranges, link-local, and Tailscale CGNAT try: addr = ipaddress.ip_address(host) diff --git a/tests/agent/test_local_stream_timeout.py b/tests/agent/test_local_stream_timeout.py index 0252633f3..91ca7f404 100644 --- a/tests/agent/test_local_stream_timeout.py +++ b/tests/agent/test_local_stream_timeout.py @@ -98,6 +98,16 @@ class TestIsLocalEndpoint: def test_container_dns_names(self, url): assert is_local_endpoint(url) is True + @pytest.mark.parametrize("url", [ + "http://ollama:11434", + "http://litellm:4000/v1", + "http://hermes-litellm:8080", + "http://vllm:8000", + ]) + def test_unqualified_docker_hostnames(self, url): + """Unqualified hostnames (no dots) are local — Docker Compose, /etc/hosts, etc.""" + assert is_local_endpoint(url) is True + @pytest.mark.parametrize("url", [ "https://api.openai.com", "https://openrouter.ai/api",