diff --git a/crates/nemoclaw-sdk/src/services/installers/ollama/mod.rs b/crates/nemoclaw-sdk/src/services/installers/ollama/mod.rs index daed794106c..6990cb9a439 100644 --- a/crates/nemoclaw-sdk/src/services/installers/ollama/mod.rs +++ b/crates/nemoclaw-sdk/src/services/installers/ollama/mod.rs @@ -120,9 +120,15 @@ impl OllamaProxy { && endpoint.scheme() == "http" && endpoint.path() == "/v1" && endpoint.port().is_some() - && matches!(endpoint.host(), Some(url::Host::Ipv4(_))) - && self.endpoint != self.upstream.endpoint, + && matches!(endpoint.host(), Some(url::Host::Ipv4(_))), "Ollama proxy requires a local external daemon, pinned installed model, private endpoint, and local Docker runner", + )?; + // The proxy shares the host network and, before each request, rejects + // any non-loopback listener on the daemon's port, which would include + // its own listener on that port. + require( + endpoint.port() != upstream.port(), + "Ollama proxy endpoint must use a port other than its upstream daemon's", ) } } diff --git a/crates/nemoclaw-sdk/tests/ollama_proxy.rs b/crates/nemoclaw-sdk/tests/ollama_proxy.rs index 97e6fb8a431..f2327cad141 100644 --- a/crates/nemoclaw-sdk/tests/ollama_proxy.rs +++ b/crates/nemoclaw-sdk/tests/ollama_proxy.rs @@ -335,6 +335,18 @@ fn proxy_rejects_unpinned_models_nonlocal_daemons_and_ambiguous_ownership() { assert!(Document::parse(value.to_string().as_bytes()).is_err()); } +#[test] +fn proxy_rejects_an_endpoint_on_the_daemon_port() { + // The proxy shares the host network, so its own listener on a private + // address would fail its check that the daemon listens only on loopback. + let mut value = input(); + value["spec"]["services"]["ollama-auth"]["endpoint"] = json!("http://172.20.0.1:11434/v1"); + let error = Document::parse(value.to_string().as_bytes()) + .unwrap_err() + .to_string(); + assert!(error.contains("port"), "{error}"); +} + #[test] fn deep_agents_and_pi_use_authenticated_ollama_proxy_connections() { for harness in ["deepagents", "pi"] { diff --git a/docs/agents-inference/inference.md b/docs/agents-inference/inference.md index ad2523289de..f91b6512f9c 100644 --- a/docs/agents-inference/inference.md +++ b/docs/agents-inference/inference.md @@ -485,6 +485,7 @@ The service's `upstream.endpoint` identifies the external daemon. Its `endpoint` identifies the managed proxy and supplies the native inference URL. The route's model must match `upstream.model.name`, including its tag, such as `qwen3:4b`. The proxy uses the host network and checks that the daemon has no listener on a non-loopback address. +The proxy's `endpoint` must use a port other than the daemon's, because that check would also find the proxy's own listener. Don't declare `endpoint` or `credential` on this provider. The referenced service supplies its connection and generated credential. The service declaration manages only the proxy.