Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions crates/nemoclaw-sdk/src/services/installers/ollama/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
)
}
}
Expand Down
12 changes: 12 additions & 0 deletions crates/nemoclaw-sdk/tests/ollama_proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"] {
Expand Down
1 change: 1 addition & 0 deletions docs/agents-inference/inference.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Loading