Skip to content

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

@malaiwah

Description

@malaiwah

Bug Description

is_local_endpoint() in agent/model_metadata.py only matches IP addresses, localhost, and _LOCAL_HOSTS. When running Hermes behind a local LLM proxy (e.g. LiteLLM, Ollama) accessed via Docker/Podman DNS name (like hermes-litellm or ollama), the function returns False.

This causes the stale stream timeout (180s default) to NOT be auto-disabled (the fix from #6368), leading to the infinite retry loop described in #7069 — the local model is still prefilling but the agent kills the connection and reconnects.

Root Cause

The check at line ~4951 in run_agent.py:

if _stream_stale_timeout_base == 180.0 and self.base_url and is_local_endpoint(self.base_url):
    _stream_stale_timeout = float("inf")

...never triggers because is_local_endpoint("http://hermes-litellm:4000/v1") returns False — it's not an IP, not in _LOCAL_HOSTS, and the hostname can't be parsed as an IP address.

Proposed Fix

Three additions to is_local_endpoint():

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

  2. DNS resolution fallback — resolve the hostname to an IP with socket.gethostbyname(), then check if it's private. This catches qualified local hostnames like ollama.local or litellm.internal.

  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 is unusual.

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Medium — degraded but workaround existsarea/dockerDocker image, Compose, packagingcomp/agentCore agent loop, run_agent.py, prompt buildertype/bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions