From d885c7046281e3294c00f744c60f45a0854b1666 Mon Sep 17 00:00:00 2001 From: Elle <163466757+elle13eth@users.noreply.github.com> Date: Mon, 1 Jun 2026 22:49:59 +0200 Subject: [PATCH] Treat Docker host gateway as local When running Odysseus in Docker and connecting to a local LLM on the host machine (e.g. `llama.cpp` or `Ollama`), the standard endpoint `http://host.docker.internal` is used to breach the container network. Because `host.docker.internal` was missing from `_LOCAL_HOSTS`, Odysseus incorrectly treated local self-hosted models as cloud APIs. This triggered the fallback behavior where actual API-reported context limits were being ignored and overridden by hardcoded fallbacks in `KNOWN_CONTEXT_WINDOWS`. **Changes** - Added `"host.docker.internal"` to the `_LOCAL_HOSTS` whitelist in `src/model_context.py` so that Dockerized deployments correctly trust and respect the context limits of locally hosted models. **Checks Ran** - [x] Syntax check (`python -m py_compile src/model_context.py`) - [x] Tested manually in Docker (`docker compose up -d --build`) on a Windows host using `llama-server`. The correct API context length is now correctly reported in the UI instead of falling back to the 131k hardcode. --- src/model_context.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/model_context.py b/src/model_context.py index df644d2..23cdb86 100644 --- a/src/model_context.py +++ b/src/model_context.py @@ -14,7 +14,7 @@ import httpx logger = logging.getLogger(__name__) -_LOCAL_HOSTS = {"localhost", "127.0.0.1", "0.0.0.0", "::1"} +_LOCAL_HOSTS = {"localhost", "127.0.0.1", "0.0.0.0", "::1", "host.docker.internal"} _PRIVATE_PREFIXES = ("10.", "172.16.", "172.17.", "172.18.", "172.19.", "172.20.", "172.21.", "172.22.", "172.23.", "172.24.", "172.25.", "172.26.", "172.27.", "172.28.", "172.29.",