From 4690bbc363e952d29baf31f838b7502c905f8812 Mon Sep 17 00:00:00 2001 From: Evi Nova <66773372+Tranquil-Flow@users.noreply.github.com> Date: Fri, 5 Jun 2026 10:18:10 +1000 Subject: [PATCH] fix(local): recognize unqualified hostnames as local endpoints (#9248) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Docker Compose service names (e.g. ollama, litellm, hermes-litellm) are unqualified hostnames with no dots. These are always local — they resolve via Docker DNS, /etc/hosts, or mDNS. Without this fix, the stale stream timeout fires on local LLM proxies, causing infinite reconnect loops. Closes #7905 --- agent/model_metadata.py | 4 ++++ tests/agent/test_local_stream_timeout.py | 10 ++++++++++ 2 files changed, 14 insertions(+) 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",