Skip to content

fix: is_local_endpoint misses Docker/Podman DNS names#7906

Closed
malaiwah wants to merge 1 commit into
NousResearch:mainfrom
malaiwah:fix/local-endpoint-docker-dns
Closed

fix: is_local_endpoint misses Docker/Podman DNS names#7906
malaiwah wants to merge 1 commit into
NousResearch:mainfrom
malaiwah:fix/local-endpoint-docker-dns

Conversation

@malaiwah

Copy link
Copy Markdown
Contributor

Summary

Extends is_local_endpoint() in agent/model_metadata.py to detect local LLM proxies accessed via container DNS names (e.g. ollama, litellm, hermes-litellm).

Without this fix, the stale stream timeout (180s, added in #6368) is NOT auto-disabled for local providers accessed via Docker/Podman DNS, causing the infinite retry loop described in #7069.

Changes

Three additions to is_local_endpoint():

  1. Unqualified hostnames (no dots) → always local. A hostname like ollama or litellm is always a local network name (Docker/Podman DNS, mDNS, /etc/hosts). This is the most common case and requires zero configuration.

  2. DNS resolution fallback — resolve the hostname to an IP with socket.gethostbyname(), check if the resolved address is private/loopback/link-local. Catches qualified local hostnames like ollama.local.

  3. Configurable model.local_endpoints — a list of hostnames in config.yaml to explicitly mark as local. Useful for edge cases where DNS resolution isn't available or the hostname doesn't resolve to a private IP.

Test plan

  • Verify is_local_endpoint("http://ollama:11434/v1") returns True (unqualified hostname)
  • Verify is_local_endpoint("http://my-litellm-proxy:4000/v1") returns True (unqualified hostname)
  • Verify is_local_endpoint("http://api.openai.com/v1") returns False (qualified, public)
  • Verify is_local_endpoint("http://localhost:11434/v1") still returns True (existing behavior)
  • Verify is_local_endpoint("http://192.168.1.100:8000/v1") still returns True (existing behavior)
  • Verify DNS resolution: is_local_endpoint("http://my-host.local:8000/v1") resolves and checks IP
  • Verify model.local_endpoints config is read when set
  • Verify graceful degradation when config is unavailable (no crash)

Fixes #7905
Related: #7069, #6368

🤖 Generated with Claude Code

)

Extends is_local_endpoint() to detect local LLM proxies accessed via
container DNS names (e.g. hermes-litellm, ollama), fixing the stale
stream timeout (180s) firing on local providers during prefill.

Three additions:

1. Unqualified hostnames (no dots) → always local. Docker/Podman DNS,
   mDNS, and /etc/hosts entries are always on the local network.

2. DNS resolution fallback — resolve hostname to IP with
   socket.gethostbyname(), check if the resolved address is private.

3. Configurable model.local_endpoints in config.yaml — explicit list
   of hostnames to treat as local for edge cases where DNS resolution
   isn't available.

Fixes NousResearch#7905
Related: NousResearch#7069, NousResearch#6368

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/agent Core agent loop, run_agent.py, prompt builder area/docker Docker image, Compose, packaging duplicate This issue or pull request already exists labels Apr 28, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Likely duplicate of #7950 (merged) — same fix for is_local_endpoint() missing Docker/Podman DNS names. This PR appears to be the earlier version that was superseded.

@benbarclay

Copy link
Copy Markdown
Collaborator

Thanks @malaiwah — closing as superseded. The entire stated goal is now on main: container-suffix matching (.docker.internal et al., via #7950) and unqualified/dotless hostnames being treated as local (via #9248, just merged) together cover the Docker/Podman DNS cases this PR targeted. The two extras here (socket.gethostbyname DNS fallback and a model.local_endpoints config knob) were intentionally left out — the DNS fallback adds a blocking network call to a hot metadata path. If you'd still like a manual override escape-hatch, a small standalone issue for just the config knob would be the cleaner path. Credit for getting the DNS-name gap on the radar. 🙏

@benbarclay benbarclay closed this Jun 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/docker Docker image, Compose, packaging comp/agent Core agent loop, run_agent.py, prompt builder duplicate This issue or pull request already exists P2 Medium — degraded but workaround exists type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

is_local_endpoint misses Docker/Podman DNS names — stale timeout fires on local LLM proxies

3 participants