Skip to content

AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.

feat(backend): send the Ollama blocks' traffic through the egress proxy (#15986)

Nicholas Tindle7d773e605767
diff --git a/autogpt_platform/backend/backend/util/llm/providers.py b/autogpt_platform/backend/backend/util/llm/providers.py
index 2b74cdb494..bc703ef6c4 100644
--- a/autogpt_platform/backend/backend/util/llm/providers.py
+++ b/autogpt_platform/backend/backend/util/llm/providers.py
@@ -52,6 +52,7 @@ from backend.data.llm_registry.llm_models import (
strip_anthropic_vendor_prefix,
)
from backend.util.clients import OPENROUTER_BASE_URL
+from backend.util.egress_proxy import egress_proxy_url
from backend.util.llm.conversions import (
ToolCall,
ToolContentBlock,
@@ -68,7 +69,7 @@ from backend.util.openai_responses import (
extract_responses_tool_calls,
extract_responses_usage,
)
-from backend.util.request import validate_url_host
+from backend.util.request import parse_url, validate_url_host
from backend.util.settings import Settings
settings = Settings()
@@ -760,6 +761,46 @@ async def _call_groq(
# Ollama (local-runner chat API)
# ---------------------------------------------------------------------------
+_OLLAMA_DEFAULT_PORT = 11434
+_SCHEME_PORTS = {"http": 80, "https": 443}
+
+
+def _ollama_url(host: str) -> str:
+ """*host* as a URL naming the port Ollama's client would connect to: 11434
+ for a host given with neither scheme nor port, otherwise its scheme's."""
+ url = parse_url(host)
+ # parse_url adds "http://" itself to a host that names no scheme.
+ scheme_given = "://" in host.replace("\\", "/")
+ port = _SCHEME_PORTS.get(url.scheme) if scheme_given else _OLLAMA_DEFAULT_PORT
+ if url.port is None and port is not None:
+ url = url._replace(netloc=f"{url.netloc}:{port}")
+ return url.geturl()
+
+
+def _configured_ollama_url() -> httpx.URL | None:
+ try:
+ return httpx.URL(_ollama_url(settings.config.ollama_host))
+ except (ValueError, httpx.InvalidURL):
+ return None
+
+
+async def _scope_ollama_key(request: httpx.Request) -> None:
+ """Drop the process's OLLAMA_API_KEY, which ollama.AsyncClient sends with
+ every request, redirects included, unless this request goes to the
+ configured Ollama endpoint itself, in scheme, host and port alike.
+
+ Being trusted is not enough: trust ignores the scheme, lets any port
+ through for an entry configured without one, and covers the copilot's chat
+ endpoint. httpx also keeps the header on an http-to-https redirect."""
+ url, configured = request.url, _configured_ollama_url()
+ # Both read by httpx: IDNA-encoded host, a scheme's default port as None.
+ if configured is None or (url.scheme, url.raw_host, url.port) != (
+ configured.scheme,
+ configured.raw_host,
+ configured.port,
+ ):
+ request.headers.pop("authorization", None)
+
async def _call_ollama(
*,
@@ -777,7 +818,16 @@ async def _call_ollama(
# SSRF guard — the host can be user-supplied (block-layer input
# field), so it must match an operator-configured trust list.
- await validate_url_host(ollama_host, trusted_hostnames=_trusted_ollama_hostnames())
+ checked, is_trusted, _ = await validate_url_host(
+ _ollama_url(ollama_host), trusted_hostnames=_trusted_ollama_hostnames()
+ )
+ if checked.port == 0:
+ # Ollama's client reads port 0 as no port and connects to its default.
+ raise ValueError(f"Ollama host {ollama_host!r} has an invalid port")
+ # Connect to the URL that was checked, never the raw input: Ollama's own
+ # parser reads some spellings (a backslash before "@", a leading "//") as a
+ # different host.
+ host = checked.geturl()
# ``num_predict`` is Ollama's OUTPUT token cap. ``num_ctx`` (the
# input context window) is deliberately left at the model default —
@@ -787,14 +837,13 @@ async def _call_ollama(
if temperature is not None:
options["temperature"] = temperature
- client = ollama.AsyncClient(
- host=ollama_host, timeout=request_timeout(timeout_seconds)
- )
- response = await client.chat(
+ response = await _send_ollama_chat(
+ host,
+ is_trusted=is_trusted,
+ timeout_seconds=timeout_seconds,
model=model,
messages=messages,
- stream=False,
- format="json" if force_json_output else None,
+ json_format=force_json_output,
options=options,
)
return ProviderResponse(
@@ -805,6 +854,51 @@ async def _call_ollama(
)
+async def _send_ollama_chat(
+ host: str,
+ *,
+ is_trusted: bool,
+ timeout_seconds: float,
+ model: str,
+ messages: list[dict],
+ json_format: bool,
+ options: dict[str, Any],
+) -> ollama.ChatResponse:
+ """Send one chat to the checked *host*, connecting the way its trust
+ allows."""
+ client_kwargs: dict[str, Any] = {
+ "host": host,
+ "timeout": request_timeout(timeout_seconds),
+ "event_hooks": {"request": [_scope_ollama_key]},
+ }
+ if not is_trusted:
+ # The host passed the address check, but ollama.AsyncClient hands the
+ # name to httpx, which resolves it again to connect and follows
+ # redirects on its own: a changed DNS answer or a redirect could still
+ # reach an internal address. The egress proxy checks every address it
+ # dials, on every hop. Trusted operator hosts connect without it: they
+ # are usually loopback, which the public-only proxy refuses.
+ client_kwargs["proxy"] = egress_proxy_url()
+
+ client = ollama.AsyncClient(**client_kwargs)
+ try:
+ return await client.chat(
+ model=model,
+ messages=messages,
+ stream=False,
+ format="json" if json_format else None,
+ options=options,
+ )
+ except httpx.ProxyError as e:
+ if is_trusted:
+ raise
+ # httpx's wording names a proxy the user never configured.
+ raise ConnectionError(
+ f"Could not connect to Ollama at {host}: it is unreachable or "
+ "not on a public address."
+ ) from e
+
+
def _trusted_ollama_hostnames() -> list[str]:
"""Hosts an Ollama call may target without IP-resolution checks.
diff --git a/autogpt_platform/backend/backend/util/llm/providers_test.py b/autogpt_platform/backend/backend/util/llm/providers_test.py
index 4aa6b09904..2cc8211b67 100644
--- a/autogpt_platform/backend/backend/util/llm/providers_test.py
+++ b/autogpt_platform/backend/backend/util/llm/providers_test.py
@@ -11,15 +11,20 @@ from __future__ import annotations
import asyncio
import contextlib
+import socket
from contextlib import contextmanager
from types import SimpleNamespace
+from typing import Self
from unittest.mock import AsyncMock, MagicMock, patch
import anthropic
import httpx
import pytest
+from aiohttp import web
+from aiohttp.test_utils import TestServer
from pydantic import ValidationError
+from backend.util import egress_proxy
from backend.util.llm import providers as providers_mod
from backend.util.llm.providers import (
DEFAULT_REQUEST_TIMEOUT_SECONDS,
@@ -33,6 +38,7 @@ from backend.util.llm.providers import (
is_forced_tool_choice_rejection,
request_timeout,
)
+from backend.util.request import parse_url
from backend.util.settings import Config, Settings
@@ -834,6 +840,12 @@ def _fake_ollama_chat_client(
return SimpleNamespace(chat=chat)
+async def _checked_as_trusted(url: str, trusted_hostnames=None):
+ """Stand-in for ``validate_url_host`` that skips DNS and reports the
+ host as trusted."""
+ return parse_url(url), True, []
+
+
@contextmanager
def _patched_ollama_dispatch(
captured: dict,
@@ -841,11 +853,11 @@ def _patched_ollama_dispatch(
content: str = "ok",
chat_base_url: str | None = None,
):
- """Patch set for an Ollama dispatch test: mocked SSRF validation, a
- stubbed copilot ``ChatConfig`` (so no real settings load happens),
- and a fake ``ollama.AsyncClient``. Yields ``(validate_mock,
- client_ctor_mock)``."""
- validate_mock = AsyncMock(return_value=None)
+ """Patch set for an Ollama dispatch test: mocked SSRF validation that
+ reports the host as trusted, a stubbed copilot ``ChatConfig`` (so no real
+ settings load happens), and a fake ``ollama.AsyncClient``. Yields
+ ``(validate_mock, client_ctor_mock)``."""
+ validate_mock = AsyncMock(side_effect=_checked_as_trusted)
client_ctor = MagicMock(
return_value=_fake_ollama_chat_client(captured, content=content)
)
@@ -963,9 +975,54 @@ class TestOllama:
assert result.content == '{"facts": []}'
assert result.prompt_tokens == 7
assert result.completion_tokens == 9
- ctor.assert_called_once_with(
- host="http://gpu-box:11434", timeout=request_timeout(42.0)
- )
+ ctor.assert_called_once()
+ assert ctor.call_args.kwargs["host"] == "http://gpu-box:11434"
+ assert ctor.call_args.kwargs["timeout"] == request_timeout(42.0)
+
+ @pytest.mark.asyncio
+ @pytest.mark.parametrize(
+ "ollama_host, expected",
+ [
+ ("gpu-box", "http://gpu-box:11434"),
+ ("gpu-box:8080", "http://gpu-box:8080"),
+ ("http://gpu-box", "http://gpu-box:80"),
+ ("https://gpu-box/ollama", "https://gpu-box:443/ollama"),
+ ("http:\\\\gpu-box", "http://gpu-box:80"),
+ ],
+ )
+ async def test_the_checked_url_is_the_one_the_client_gets(
+ self, ollama_host, expected
+ ):
+ """The SSRF check and the client see one URL, with the port Ollama's
+ client would use spelled out: its own 11434 for a host with neither
+ scheme nor port, otherwise the scheme's."""
+ with _patched_ollama_dispatch({}) as (validate_mock, ctor):
+ await call_provider(
+ provider="ollama",
+ model="llama3",
+ api_key="",
+ messages=[_msg("user", "hi")],
+ max_tokens=10,
+ ollama_host=ollama_host,
+ )
+ assert validate_mock.call_args.args[0] == expected
+ assert ctor.call_args.kwargs["host"] == expected
+
+ @pytest.mark.asyncio
+ async def test_rejects_port_zero(self):
+ # Ollama's client would read it as no port and connect elsewhere.
+ with _patched_ollama_dispatch({}) as (_, ctor), pytest.raises(
+ ValueError, match="invalid port"
+ ):
+ await call_provider(
+ provider="ollama",
+ model="llama3",
+ api_key="",
+ messages=[_msg("user", "hi")],
+ max_tokens=10,
+ ollama_host="gpu-box:0",
+ )
+ ctor.assert_not_called()
class TestOllamaTrustedHosts:
@@ -1011,7 +1068,7 @@ class TestOllamaTrustedHosts:
from backend.util.llm.providers import settings
captured: dict = {}
- validate_mock = AsyncMock(return_value=None)
+ validate_mock = AsyncMock(side_effect=_checked_as_trusted)
with (
patch(
"backend.util.llm.providers.validate_url_host",
@@ -1078,7 +1135,7 @@ class TestOllamaTrustedHosts:
The base_url read must be memoized after the first success while
every dispatch still gets the cached value in its trust list."""
captured: dict = {}
- validate_mock = AsyncMock(return_value=None)
+ validate_mock = AsyncMock(side_effect=_checked_as_trusted)
chat_config_ctor = MagicMock(
return_value=SimpleNamespace(
base_url="http://host.docker.internal:11434/v1"
@@ -1117,7 +1174,7 @@ class TestOllamaTrustedHosts:
from backend.util.llm.providers import settings
captured: dict = {}
- validate_mock = AsyncMock(return_value=None)
+ validate_mock = AsyncMock(side_effect=_checked_as_trusted)
chat_config_ctor = MagicMock(
side_effect=[
ValueError("transient misconfiguration"),
@@ -1172,6 +1229,323 @@ class TestOllamaTrustedHosts:
client_ctor.assert_not_called()
+class _FakeOllama:
+ """A loopback Ollama that answers a chat on any path, counting its requests
+ and recording the last ``Authorization`` header, or redirects every request
+ to ``redirect_to``."""
+
+ def __init__(self, redirect_to: str | None = None) -> None:
+ self.requests = 0
+ self.authorization: str | None = None
+ self.redirect_to = redirect_to
+ app = web.Application()
+ app.router.add_post("/{path:.*}", self._chat)
+ self.server = TestServer(app, host="127.0.0.1")
+
+ async def __aenter__(self) -> Self:
+ await self.server.start_server()
+ return self
+
+ async def __aexit__(self, *exc) -> None:
+ await self.server.close()
+
+ @property
+ def port(self) -> int:
+ assert self.server.port is not None
+ return self.server.port
+
+ async def _chat(self, request: web.Request) -> web.Response:
+ self.requests += 1
+ self.authorization = request.headers.get("Authorization")
+ if self.redirect_to:
+ return web.Response(status=307, headers={"Location": self.redirect_to})
+ return web.json_response(
+ {"model": "llama3", "message": {"role": "assistant", "content": "hi"}}
+ )
+
+
+def _fake_dns(
+ monkeypatch: pytest.MonkeyPatch, answers: dict[str, list[str | None]]
+) -> None:
+ """Answer each name in *answers* with its next address in turn, the last
+ one repeating; None means the name does not resolve. Other names resolve
+ for real."""
+ real_getaddrinfo = socket.getaddrinfo
+
+ def getaddrinfo(host, port, *args, **kwargs):
+ name = host.decode() if isinstance(host, bytes) else host
+ if name not in answers:
+ return real_getaddrinfo(host, port, *args, **kwargs)
+ queue = answers[name]
+ address = queue.pop(0) if len(queue) > 1 else queue[0]
+ if address is None:
+ raise socket.gaierror(socket.EAI_NONAME, "Name or service not known")
+ return [
+ (socket.AF_INET, socket.SOCK_STREAM, 6, "", (address, port or 0)),
+ ]
+
+ monkeypatch.setattr(socket, "getaddrinfo", getaddrinfo)
+
+
+def _vet_as_public(monkeypatch: pytest.MonkeyPatch, name: str) -> None:
+ """Let the egress proxy treat *name* as a public host that resolves to
+ loopback, so a test server can stand in for it. Every other target still
+ gets the proxy's real checks."""
+ real_public_addresses = egress_proxy.public_addresses
+
+ async def vetted(host: str) -> list[str]:
+ if host == name:
+ return ["127.0.0.1"]
+ return await real_public_addresses(host)
+
+ monkeypatch.setattr(egress_proxy, "public_addresses", vetted)
+
+
+async def _ollama_chat(
+ host: str, *, chat_base_url: str | None = None
+) -> ProviderResponse:
+ with patch(
+ "backend.copilot.config.ChatConfig",
+ return_value=SimpleNamespace(base_url=chat_base_url),
+ ):
+ result = await call_provider(
+ provider="ollama",
+ model="llama3",
+ api_key="",
+ messages=[_msg("user", "hi")],
+ max_tokens=10,
+ ollama_host=host,
+ timeout_seconds=10.0,
+ )
+ assert isinstance(result, ProviderResponse)
+ return result
+
+
+class TestOllamaEgress:
+ """A user-supplied Ollama host passes the address check once, but
+ ``ollama.AsyncClient`` resolves the name again when it connects and follows
+ redirects. So untrusted hosts connect through the egress proxy, which
+ checks every address it dials, and without the operator's API key;
+ operator-configured hosts connect without the proxy. These use the real
+ client, proxy and loopback servers: nothing between the check and the
+ socket is mocked."""
+
+ @pytest.mark.asyncio
+ async def test_a_host_that_rebinds_after_the_check_never_reaches_it(
+ self, monkeypatch
+ ):
+ async with _FakeOllama() as internal:
+ _fake_dns(monkeypatch, {"rebind.test": ["93.184.216.34", "127.0.0.1"]})
+ with pytest.raises(ConnectionError, match="Could not connect to Ollama"):
+ await _ollama_chat(f"http://rebind.test:{internal.port}")
+ assert internal.requests == 0
+
+ @pytest.mark.asyncio
+ async def test_a_redirect_to_an_internal_address_is_refused(self, monkeypatch):
+ async with _FakeOllama() as internal:
+ target = f"http://127.0.0.1:{internal.port}/api/chat"
+ async with _FakeOllama(redirect_to=target) as public:
+ _fake_dns(monkeypatch, {"public.test": ["93.184.216.34", "127.0.0.1"]})
+ _vet_as_public(monkeypatch, "public.test")
+ with pytest.raises(
+ ConnectionError, match="Could not connect to Ollama"
+ ):
+ await _ollama_chat(f"http://public.test:{public.port}")
+ assert public.requests == 1
+ assert internal.requests == 0
+
+ @pytest.mark.asyncio
+ async def test_environment_proxy_settings_cannot_route_around_the_proxy(
+ self, monkeypatch
+ ):
+ # A deployment's NO_PROXY usually exempts internal ranges; it must not
+ # exempt a user's Ollama host from the egress proxy. Both spellings,
+ # since a lowercase one wins where both are set.
+ monkeypatch.setenv("NO_PROXY", "*")
+ monkeypatch.setenv("no_proxy", "*")
+ async with _FakeOllama() as internal:
+ _fake_dns(monkeypatch, {"rebind.test": ["93.184.216.34", "127.0.0.1"]})
+ with pytest.raises(ConnectionError, match="Could not connect to Ollama"):
+ await _ollama_chat(f"http://rebind.test:{internal.port}")
+ assert internal.requests == 0
+
+ @pytest.mark.asyncio
+ async def test_a_backslash_cannot_name_a_different_host_than_the_one_checked(
+ self, monkeypatch
+ ):
+ # The check reads the backslash as a path separator and matches the
+ # trusted host; Ollama's own parser would read everything before "@" as
+ # a login and connect to the address after it.
+ async with _FakeOllama() as trusted, _FakeOllama() as internal:
+ monkeypatch.setattr(
+ providers_mod.settings.config,
+ "ollama_host",
+ f"127.0.0.1:{trusted.port}",
+ )
+ result = await _ollama_chat(
+ f"http://127.0.0.1:{trusted.port}\\@127.0.0.1:{internal.port}"
+ )
+ assert result.content == "hi"
+ assert trusted.requests == 1
+ assert internal.requests == 0
+
+ @pytest.mark.asyncio
+ async def test_an_untrusted_host_is_reached_through_the_proxy(self, monkeypatch):
+ # After the check the name stops resolving, so only a connection the
+ # proxy makes to the address it vetted can reach the server.
+ async with _FakeOllama() as server:
+ _fake_dns(monkeypatch, {"ollama.test": ["93.184.216.34", None]})
+ _vet_as_public(monkeypatch, "ollama.test")
+ result = await _ollama_chat(f"http://ollama.test:{server.port}")
+ assert result.content == "hi"
+ assert server.requests == 1
+
+ @pytest.mark.asyncio
+ async def test_the_operator_api_key_never_reaches_an_untrusted_host(
+ self, monkeypatch
+ ):
+ monkeypatch.setenv("OLLAMA_API_KEY", "operator-key")
+ async with _FakeOllama() as server:
+ _fake_dns(monkeypatch, {"ollama.test": ["93.184.216.34"]})
+ _vet_as_public(monkeypatch, "ollama.test")
+ await _ollama_chat(f"http://ollama.test:{server.port}")
+ assert server.requests == 1
+ assert server.authorization is None
+
+ @pytest.mark.asyncio
+ @pytest.mark.parametrize(
+ "configured_host, chat_base_url",
+ [
+ pytest.param("https://127.0.0.1:{port}", None, id="other-scheme"),
+ pytest.param("127.0.0.1", None, id="other-port"),
+ pytest.param(
+ "127.0.0.1:1", "http://127.0.0.1:{port}/api/v1", id="chat-endpoint"
+ ),
+ ],
+ )
+ async def test_a_trusted_host_that_is_not_the_configured_one_gets_no_key(
+ self, monkeypatch, configured_host, chat_base_url
+ ):
+ # Each host here is trusted, so it is reached without the proxy, but
+ # differs from the configured Ollama endpoint in scheme or port, or is
+ # the copilot's chat endpoint.
+ monkeypatch.setenv("OLLAMA_API_KEY", "operator-key")
+ async with _FakeOllama() as server:
+ monkeypatch.setattr(
+ providers_mod.settings.config,
+ "ollama_host",
+ configured_host.format(port=server.port),
+ )
+ await _ollama_chat(
+ f"http://127.0.0.1:{server.port}",
+ chat_base_url=chat_base_url and chat_base_url.format(port=server.port),
+ )
+ assert server.requests == 1
+ assert server.authorization is None
+
+ @pytest.mark.asyncio
+ async def test_a_trusted_host_is_reached_directly_with_the_operator_key(
+ self, monkeypatch
+ ):
+ # Operator-configured hosts are usually loopback, which the proxy
+ # refuses, so they must not be sent through it.
+ monkeypatch.setenv("OLLAMA_API_KEY", "operator-key")
+ async with _FakeOllama() as server:
+ host = f"http://127.0.0.1:{server.port}"
+ monkeypatch.setattr(providers_mod.settings.config, "ollama_host", host)
+ monkeypatch.setattr(
+ providers_mod,
+ "egress_proxy_url",
+ MagicMock(side_effect=AssertionError("trusted host was proxied")),
+ )
+ result = await _ollama_chat(host)
+ assert result.content == "hi"
+ assert server.requests == 1
+ assert server.authorization == "Bearer operator-key"
+
+ @pytest.mark.asyncio
+ @pytest.mark.parametrize(
+ "configured_host, url, keeps_key",
+ [
+ ("http://ollama.example", "http://ollama.example/api/chat", True),
+ ("http://ollama.example", "http://OLLAMA.example:80/api/chat", True),
+ ("http://ollama.example", "https://ollama.example/api/chat", False),
+ ("http://ollama.example", "http://ollama.example:8080/api/chat", False),
+ ("http://ollama.example", "http://ollama.example:0/api/chat", False),
+ ("http://ollama.example", "http://other.example/api/chat", False),
+ ("http://bücher.example", "http://xn--bcher-kva.example/api/chat", True),
+ ("http://xn--bcher-kva.example", "http://bücher.example/api/chat", True),
+ ("localhost:abc", "http://localhost/api/chat", False),
+ ],
+ )
+ async def test_each_request_keeps_the_key_only_for_the_configured_origin(
+ self, monkeypatch, configured_host, url, keeps_key
+ ):
+ monkeypatch.setattr(
+ providers_mod.settings.config, "ollama_host", configured_host
+ )
+ request = httpx.Request(
+ "POST", url, headers={"Authorization": "Bearer operator-key"}
+ )
+ await providers_mod._scope_ollama_key(request)
+ assert ("authorization" in request.headers) is keeps_key
+
+ @pytest.mark.asyncio
+ async def test_a_redirect_from_the_configured_endpoint_does_not_carry_the_key(
+ self, monkeypatch
+ ):
+ # httpx itself keeps the header on this redirect, from http to https
+ # on the same host; only the request hook can drop it.
+ monkeypatch.setenv("OLLAMA_API_KEY", "operator-key")
+ monkeypatch.setattr(
+ providers_mod.settings.config, "ollama_host", "http://ollama.example"
+ )
+ seen: list[tuple[str, str | None]] = []
+
+ def respond(request: httpx.Request) -> httpx.Response:
+ seen.append((str(request.url), request.headers.get("authorization")))
+ if request.url.scheme == "http":
+ return httpx.Response(
+ 307, headers={"Location": "https://ollama.example/api/chat"}
+ )
+ return httpx.Response(
+ 200,
+ json={
+ "model": "llama3",
+ "message": {"role": "assistant", "content": "hi"},
+ },
+ )
+
+ real_client = providers_mod.ollama.AsyncClient
+ monkeypatch.setattr(
+ providers_mod.ollama,
+ "AsyncClient",
+ lambda **kwargs: real_client(
+ **kwargs, transport=httpx.MockTransport(respond)
+ ),
+ )
+ await _ollama_chat("http://ollama.example")
+ assert seen == [
+ ("http://ollama.example/api/chat", "Bearer operator-key"),
+ ("https://ollama.example/api/chat", None),
+ ]
+
+ @pytest.mark.asyncio
+ async def test_the_configured_endpoint_s_client_also_scopes_the_key(self):
+ with _patched_ollama_dispatch({}) as (_, ctor):
+ await call_provider(
+ provider="ollama",
+ model="llama3",
+ api_key="",
+ messages=[_msg("user", "hi")],
+ max_tokens=10,
+ ollama_host=providers_mod.settings.config.ollama_host,
+ )
+ assert ctor.call_args.kwargs["event_hooks"] == {
+ "request": [providers_mod._scope_ollama_key]
+ }
+
+
# ---------------------------------------------------------------------------
# Temperature threading
# ---------------------------------------------------------------------------
diff --git a/autogpt_platform/backend/poetry.lock b/autogpt_platform/backend/poetry.lock
index 7ea36490a9..33d94bd338 100644
--- a/autogpt_platform/backend/poetry.lock
+++ b/autogpt_platform/backend/poetry.lock
@@ -359,7 +359,7 @@ version = "4.15.1"
description = "High-level concurrency and networking framework on top of asyncio or Trio"
optional = false
python-versions = ">=3.10"
-groups = ["main", "dev"]
+groups = ["main"]
files = [
{file = "anyio-4.15.1-py3-none-any.whl", hash = "sha256:6152fdbbf9a77fdec97731721bebf7c4c44f7c29b424b0065826173efc7ed101"},
{file = "anyio-4.15.1.tar.gz", hash = "sha256:9f28306018cbd6d329e64a36d58256edff76dd996fe423bc957326e578b82a94"},
@@ -753,7 +753,7 @@ version = "2026.10.19"
description = "Python package for providing Mozilla's CA Bundle."
optional = false
python-versions = ">=3.7"
-groups = ["main", "dev"]
+groups = ["main"]
files = [
{file = "certifi-2026.10.19-py3-none-any.whl", hash = "sha256:42d35340cc5b9ba78e818ddbff0c5b1c2b779de448a340fd1b989f5fa8670e1b"},
{file = "certifi-2026.10.19.tar.gz", hash = "sha256:035c1e85572b141bf1c3a3eff0e33a8eb74917522f2559075ff8d2fea780a1ae"},
@@ -2648,7 +2648,7 @@ version = "0.16.0"
description = "A pure-Python, bring-your-own-I/O implementation of HTTP/1.1"
optional = false
python-versions = ">=3.8"
-groups = ["main", "dev"]
+groups = ["main"]
files = [
{file = "h11-0.16.0-py3-none-any.whl", hash = "sha256:63cf8bbe7522de3bf65932fda1d9c2772064ffb3dae62d55932da54b31cb6c86"},
{file = "h11-0.16.0.tar.gz", hash = "sha256:4e35b956cf45792e4caa5885e69fba00bdbc6ffafbfa020300e549b208ee5ff1"},
@@ -2713,7 +2713,7 @@ version = "1.0.9"
description = "A minimal low-level HTTP client."
optional = false
python-versions = ">=3.8"
-groups = ["main", "dev"]
+groups = ["main"]
files = [
{file = "httpcore-1.0.9-py3-none-any.whl", hash = "sha256:2d400746a40668fc9dec9810239072b40b4484b640a8c38fd654a024c7a1bf55"},
{file = "httpcore-1.0.9.tar.gz", hash = "sha256:6e34463af53fd2ab5d807f399a9b45ea31c3dfa2276f15a2c3f00afff6e176e8"},
@@ -2833,7 +2833,7 @@ version = "0.28.1"
description = "The next generation HTTP client."
optional = false
python-versions = ">=3.8"
-groups = ["main", "dev"]
+groups = ["main"]
files = [
{file = "httpx-0.28.1-py3-none-any.whl", hash = "sha256:d909fcccc110f8c7faf814ca82a9a4d816bc5a6dbfea25d6591d6985b8ba59ad"},
{file = "httpx-0.28.1.tar.gz", hash = "sha256:75e98c5f16b0f35b567856f597f06ff2270a374470a5c2392242528e3e3e42fc"},
@@ -2845,6 +2845,7 @@ certifi = "*"
h2 = {version = ">=3,<5", optional = true, markers = "extra == \"http2\""}
httpcore = "==1.*"
idna = "*"
+socksio = {version = "==1.*", optional = true, markers = "extra == \"socks\""}
[package.extras]
brotli = ["brotli ; platform_python_implementation == \"CPython\"", "brotlicffi ; platform_python_implementation != \"CPython\""]
@@ -2939,7 +2940,7 @@ version = "3.20"
description = "Internationalized Domain Names in Applications (IDNA)"
optional = false
python-versions = ">=3.9"
-groups = ["main", "dev"]
+groups = ["main"]
files = [
{file = "idna-3.20-py3-none-any.whl", hash = "sha256:ab7ae7122974553370f0bdb919e1a960b2cd1bc1ef0276416d896db81c14582c"},
{file = "idna-3.20.tar.gz", hash = "sha256:a7db850025b95ded1eae8a46181a1a6c56c92c96f0e2b005d9ff8dc0210cab44"},
@@ -7218,6 +7219,18 @@ files = [
{file = "sniffio-1.3.1.tar.gz", hash = "sha256:f4324edc670a0f49750a81b895f35c3adb843cca46f0530f79fc1babb23789dc"},
]
+[[package]]
+name = "socksio"
+version = "1.0.0"
+description = "Sans-I/O implementation of SOCKS4, SOCKS4A, and SOCKS5."
+optional = false
+python-versions = ">=3.6"
+groups = ["main"]
+files = [
+ {file = "socksio-1.0.0-py3-none-any.whl", hash = "sha256:95dc1f15f9b34e8d7b16f06d74b8ccf48f609af32ab33c608d08761c5dcbb1f3"},
+ {file = "socksio-1.0.0.tar.gz", hash = "sha256:f88beb3da5b5c38b9890469de67d0cb0f9d494b78b106ca1845f96c10b91c4ac"},
+]
+
[[package]]
name = "sqlalchemy"
version = "2.0.52"
@@ -8857,4 +8870,4 @@ cffi = ["cffi (>=1.17,<2.0) ; platform_python_implementation != \"PyPy\" and pyt
[metadata]
lock-version = "2.1"
python-versions = ">=3.11,<3.14"
-content-hash = "133d9f66e45f601a459943efdd82f9cd556e509165d22f78a31853de812b2eaa"
+content-hash = "ca2da3be2070a5537cf0c6672dea47e6f6dbce53d261c8554b6d0c6248e849c4"
diff --git a/autogpt_platform/backend/pyproject.toml b/autogpt_platform/backend/pyproject.toml
index eaaffc8647..ddc90a015b 100644
--- a/autogpt_platform/backend/pyproject.toml
+++ b/autogpt_platform/backend/pyproject.toml
@@ -39,6 +39,8 @@ gravitasml = "^0.1.4"
graphiti-core = ">=0.28.2,<0.31.0"
groq = ">=0.30,<1.8"
html2text = "^2024.2.26"
+# SOCKS support for the egress proxy that untrusted Ollama hosts connect through.
+httpx = { extras = ["socks"], version = "^0.28.1" }
jinja2 = "^3.1.6"
jsonref = "^1.1.0"
jsonschema = "^4.25.0"
@@ -120,7 +122,6 @@ publicsuffixlist = "1.1.0.20261010"
aiohappyeyeballs = "^2.6.1"
black = "^24.10.0"
faker = ">=38.2,<41.0"
-httpx = "^0.28.1"
isort = "^5.13.2"
poethepoet = ">=0.41,<0.49"
pre-commit = "^4.4.0"