Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.
JavaScript 3d-generationai-agentsanimationavatardigital-humangenerative-aiglbgltfimage-to-3dllmmcpmcp-servermodel-context-protocolsolanatext-to-3dthreejsweb-componentswebglwebxrx402
fix(workers): send a descriptive User-Agent when a GPU worker fetches a caller's image
nirholasd886d09e12e2
diff --git a/workers/avatar-pipeline-controller/worker_security.py b/workers/avatar-pipeline-controller/worker_security.pyindex a0360fe96..f920c365c 100644--- a/workers/avatar-pipeline-controller/worker_security.py+++ b/workers/avatar-pipeline-controller/worker_security.py@@ -61,6 +61,21 @@ def require_api_key(authorization: Optional[str], api_key: str) -> None:DEFAULT_MAX_BYTES = 64 * 1024 * 1024 # 64 MiB_MAX_REDIRECTS = 4+# Hosts that enforce a User-Agent policy refuse httpx's default+# "python-httpx/<version>": upload.wikimedia.org answers it with 403 Forbidden+# and serves the same image to a descriptive agent (measured 2026-10-09, when+# model-triposg failed every job whose reference photo was a Wikimedia link).+# Callers may still pass their own User-Agent; it replaces this one.+DEFAULT_USER_AGENT = "three.ws-worker/1.0 (+https://three.ws)"+++def _fetch_headers(headers: Optional[dict]) -> dict:+ """Caller headers over the default User-Agent, matched case-insensitively."""+ merged = dict(headers or {})+ if not any(str(k).lower() == "user-agent" for k in merged):+ merged["User-Agent"] = DEFAULT_USER_AGENT+ return merged+class UnsafeUrlError(ValueError):"""Raised when a URL targets a disallowed scheme or a private/internal IP."""@@ -153,7 +168,7 @@ def fetch_remote_bytes(current = assert_safe_url(url, allow_http=allow_http)with httpx.Client(follow_redirects=False, timeout=timeout) as client:for _ in range(_MAX_REDIRECTS + 1):- with client.stream("GET", current, headers=headers) as resp:+ with client.stream("GET", current, headers=_fetch_headers(headers)) as resp:if resp.is_redirect:location = resp.headers.get("location")if not location:@@ -192,7 +207,7 @@ async def fetch_remote_bytes_async("""current = assert_safe_url(url, allow_http=allow_http)for _ in range(_MAX_REDIRECTS + 1):- async with client.stream("GET", current, headers=headers) as resp:+ async with client.stream("GET", current, headers=_fetch_headers(headers)) as resp:if resp.is_redirect:location = resp.headers.get("location")if not location:diff --git a/workers/avatar-reconstruction/worker_security.py b/workers/avatar-reconstruction/worker_security.pyindex a0360fe96..f920c365c 100644--- a/workers/avatar-reconstruction/worker_security.py+++ b/workers/avatar-reconstruction/worker_security.py@@ -61,6 +61,21 @@ def require_api_key(authorization: Optional[str], api_key: str) -> None:DEFAULT_MAX_BYTES = 64 * 1024 * 1024 # 64 MiB_MAX_REDIRECTS = 4+# Hosts that enforce a User-Agent policy refuse httpx's default+# "python-httpx/<version>": upload.wikimedia.org answers it with 403 Forbidden+# and serves the same image to a descriptive agent (measured 2026-10-09, when+# model-triposg failed every job whose reference photo was a Wikimedia link).+# Callers may still pass their own User-Agent; it replaces this one.+DEFAULT_USER_AGENT = "three.ws-worker/1.0 (+https://three.ws)"+++def _fetch_headers(headers: Optional[dict]) -> dict:+ """Caller headers over the default User-Agent, matched case-insensitively."""+ merged = dict(headers or {})+ if not any(str(k).lower() == "user-agent" for k in merged):+ merged["User-Agent"] = DEFAULT_USER_AGENT+ return merged+class UnsafeUrlError(ValueError):"""Raised when a URL targets a disallowed scheme or a private/internal IP."""@@ -153,7 +168,7 @@ def fetch_remote_bytes(current = assert_safe_url(url, allow_http=allow_http)with httpx.Client(follow_redirects=False, timeout=timeout) as client:for _ in range(_MAX_REDIRECTS + 1):- with client.stream("GET", current, headers=headers) as resp:+ with client.stream("GET", current, headers=_fetch_headers(headers)) as resp:if resp.is_redirect:location = resp.headers.get("location")if not location:@@ -192,7 +207,7 @@ async def fetch_remote_bytes_async("""current = assert_safe_url(url, allow_http=allow_http)for _ in range(_MAX_REDIRECTS + 1):- async with client.stream("GET", current, headers=headers) as resp:+ async with client.stream("GET", current, headers=_fetch_headers(headers)) as resp:if resp.is_redirect:location = resp.headers.get("location")if not location:diff --git a/workers/garment-forge/worker_security.py b/workers/garment-forge/worker_security.pyindex a0360fe96..f920c365c 100644--- a/workers/garment-forge/worker_security.py+++ b/workers/garment-forge/worker_security.py@@ -61,6 +61,21 @@ def require_api_key(authorization: Optional[str], api_key: str) -> None:DEFAULT_MAX_BYTES = 64 * 1024 * 1024 # 64 MiB_MAX_REDIRECTS = 4+# Hosts that enforce a User-Agent policy refuse httpx's default+# "python-httpx/<version>": upload.wikimedia.org answers it with 403 Forbidden+# and serves the same image to a descriptive agent (measured 2026-10-09, when+# model-triposg failed every job whose reference photo was a Wikimedia link).+# Callers may still pass their own User-Agent; it replaces this one.+DEFAULT_USER_AGENT = "three.ws-worker/1.0 (+https://three.ws)"+++def _fetch_headers(headers: Optional[dict]) -> dict:+ """Caller headers over the default User-Agent, matched case-insensitively."""+ merged = dict(headers or {})+ if not any(str(k).lower() == "user-agent" for k in merged):+ merged["User-Agent"] = DEFAULT_USER_AGENT+ return merged+class UnsafeUrlError(ValueError):"""Raised when a URL targets a disallowed scheme or a private/internal IP."""@@ -153,7 +168,7 @@ def fetch_remote_bytes(current = assert_safe_url(url, allow_http=allow_http)with httpx.Client(follow_redirects=False, timeout=timeout) as client:for _ in range(_MAX_REDIRECTS + 1):- with client.stream("GET", current, headers=headers) as resp:+ with client.stream("GET", current, headers=_fetch_headers(headers)) as resp:if resp.is_redirect:location = resp.headers.get("location")if not location:@@ -192,7 +207,7 @@ async def fetch_remote_bytes_async("""current = assert_safe_url(url, allow_http=allow_http)for _ in range(_MAX_REDIRECTS + 1):- async with client.stream("GET", current, headers=headers) as resp:+ async with client.stream("GET", current, headers=_fetch_headers(headers)) as resp:if resp.is_redirect:location = resp.headers.get("location")if not location:diff --git a/workers/longcat/worker_security.py b/workers/longcat/worker_security.pyindex a0360fe96..f920c365c 100644--- a/workers/longcat/worker_security.py+++ b/workers/longcat/worker_security.py@@ -61,6 +61,21 @@ def require_api_key(authorization: Optional[str], api_key: str) -> None:DEFAULT_MAX_BYTES = 64 * 1024 * 1024 # 64 MiB_MAX_REDIRECTS = 4+# Hosts that enforce a User-Agent policy refuse httpx's default+# "python-httpx/<version>": upload.wikimedia.org answers it with 403 Forbidden+# and serves the same image to a descriptive agent (measured 2026-10-09, when+# model-triposg failed every job whose reference photo was a Wikimedia link).+# Callers may still pass their own User-Agent; it replaces this one.+DEFAULT_USER_AGENT = "three.ws-worker/1.0 (+https://three.ws)"+++def _fetch_headers(headers: Optional[dict]) -> dict:+ """Caller headers over the default User-Agent, matched case-insensitively."""+ merged = dict(headers or {})+ if not any(str(k).lower() == "user-agent" for k in merged):+ merged["User-Agent"] = DEFAULT_USER_AGENT+ return merged+class UnsafeUrlError(ValueError):"""Raised when a URL targets a disallowed scheme or a private/internal IP."""@@ -153,7 +168,7 @@ def fetch_remote_bytes(current = assert_safe_url(url, allow_http=allow_http)with httpx.Client(follow_redirects=False, timeout=timeout) as client:for _ in range(_MAX_REDIRECTS + 1):- with client.stream("GET", current, headers=headers) as resp:+ with client.stream("GET", current, headers=_fetch_headers(headers)) as resp:if resp.is_redirect:location = resp.headers.get("location")if not location:@@ -192,7 +207,7 @@ async def fetch_remote_bytes_async("""current = assert_safe_url(url, allow_http=allow_http)for _ in range(_MAX_REDIRECTS + 1):- async with client.stream("GET", current, headers=headers) as resp:+ async with client.stream("GET", current, headers=_fetch_headers(headers)) as resp:if resp.is_redirect:location = resp.headers.get("location")if not location:diff --git a/workers/model-hunyuan3d/worker_security.py b/workers/model-hunyuan3d/worker_security.pyindex a0360fe96..f920c365c 100644--- a/workers/model-hunyuan3d/worker_security.py+++ b/workers/model-hunyuan3d/worker_security.py@@ -61,6 +61,21 @@ def require_api_key(authorization: Optional[str], api_key: str) -> None:DEFAULT_MAX_BYTES = 64 * 1024 * 1024 # 64 MiB_MAX_REDIRECTS = 4+# Hosts that enforce a User-Agent policy refuse httpx's default+# "python-httpx/<version>": upload.wikimedia.org answers it with 403 Forbidden+# and serves the same image to a descriptive agent (measured 2026-10-09, when+# model-triposg failed every job whose reference photo was a Wikimedia link).+# Callers may still pass their own User-Agent; it replaces this one.+DEFAULT_USER_AGENT = "three.ws-worker/1.0 (+https://three.ws)"+++def _fetch_headers(headers: Optional[dict]) -> dict:+ """Caller headers over the default User-Agent, matched case-insensitively."""+ merged = dict(headers or {})+ if not any(str(k).lower() == "user-agent" for k in merged):+ merged["User-Agent"] = DEFAULT_USER_AGENT+ return merged+class UnsafeUrlError(ValueError):"""Raised when a URL targets a disallowed scheme or a private/internal IP."""@@ -153,7 +168,7 @@ def fetch_remote_bytes(current = assert_safe_url(url, allow_http=allow_http)with httpx.Client(follow_redirects=False, timeout=timeout) as client:for _ in range(_MAX_REDIRECTS + 1):- with client.stream("GET", current, headers=headers) as resp:+ with client.stream("GET", current, headers=_fetch_headers(headers)) as resp:if resp.is_redirect:location = resp.headers.get("location")if not location:@@ -192,7 +207,7 @@ async def fetch_remote_bytes_async("""current = assert_safe_url(url, allow_http=allow_http)for _ in range(_MAX_REDIRECTS + 1):- async with client.stream("GET", current, headers=headers) as resp:+ async with client.stream("GET", current, headers=_fetch_headers(headers)) as resp:if resp.is_redirect:location = resp.headers.get("location")if not location:diff --git a/workers/model-text2motion/worker_security.py b/workers/model-text2motion/worker_security.pyindex a0360fe96..f920c365c 100644--- a/workers/model-text2motion/worker_security.py+++ b/workers/model-text2motion/worker_security.py@@ -61,6 +61,21 @@ def require_api_key(authorization: Optional[str], api_key: str) -> None:DEFAULT_MAX_BYTES = 64 * 1024 * 1024 # 64 MiB_MAX_REDIRECTS = 4+# Hosts that enforce a User-Agent policy refuse httpx's default+# "python-httpx/<version>": upload.wikimedia.org answers it with 403 Forbidden+# and serves the same image to a descriptive agent (measured 2026-10-09, when+# model-triposg failed every job whose reference photo was a Wikimedia link).+# Callers may still pass their own User-Agent; it replaces this one.+DEFAULT_USER_AGENT = "three.ws-worker/1.0 (+https://three.ws)"+++def _fetch_headers(headers: Optional[dict]) -> dict:+ """Caller headers over the default User-Agent, matched case-insensitively."""+ merged = dict(headers or {})+ if not any(str(k).lower() == "user-agent" for k in merged):+ merged["User-Agent"] = DEFAULT_USER_AGENT+ return merged+class UnsafeUrlError(ValueError):"""Raised when a URL targets a disallowed scheme or a private/internal IP."""@@ -153,7 +168,7 @@ def fetch_remote_bytes(current = assert_safe_url(url, allow_http=allow_http)with httpx.Client(follow_redirects=False, timeout=timeout) as client:for _ in range(_MAX_REDIRECTS + 1):- with client.stream("GET", current, headers=headers) as resp:+ with client.stream("GET", current, headers=_fetch_headers(headers)) as resp:if resp.is_redirect:location = resp.headers.get("location")if not location:@@ -192,7 +207,7 @@ async def fetch_remote_bytes_async("""current = assert_safe_url(url, allow_http=allow_http)for _ in range(_MAX_REDIRECTS + 1):- async with client.stream("GET", current, headers=headers) as resp:+ async with client.stream("GET", current, headers=_fetch_headers(headers)) as resp:if resp.is_redirect:location = resp.headers.get("location")if not location:diff --git a/workers/model-trellis/worker_security.py b/workers/model-trellis/worker_security.pyindex a0360fe96..f920c365c 100644--- a/workers/model-trellis/worker_security.py+++ b/workers/model-trellis/worker_security.py@@ -61,6 +61,21 @@ def require_api_key(authorization: Optional[str], api_key: str) -> None:DEFAULT_MAX_BYTES = 64 * 1024 * 1024 # 64 MiB_MAX_REDIRECTS = 4+# Hosts that enforce a User-Agent policy refuse httpx's default+# "python-httpx/<version>": upload.wikimedia.org answers it with 403 Forbidden+# and serves the same image to a descriptive agent (measured 2026-10-09, when+# model-triposg failed every job whose reference photo was a Wikimedia link).+# Callers may still pass their own User-Agent; it replaces this one.+DEFAULT_USER_AGENT = "three.ws-worker/1.0 (+https://three.ws)"+++def _fetch_headers(headers: Optional[dict]) -> dict:+ """Caller headers over the default User-Agent, matched case-insensitively."""+ merged = dict(headers or {})+ if not any(str(k).lower() == "user-agent" for k in merged):+ merged["User-Agent"] = DEFAULT_USER_AGENT+ return merged+class UnsafeUrlError(ValueError):"""Raised when a URL targets a disallowed scheme or a private/internal IP."""@@ -153,7 +168,7 @@ def fetch_remote_bytes(current = assert_safe_url(url, allow_http=allow_http)with httpx.Client(follow_redirects=False, timeout=timeout) as client:for _ in range(_MAX_REDIRECTS + 1):- with client.stream("GET", current, headers=headers) as resp:+ with client.stream("GET", current, headers=_fetch_headers(headers)) as resp:if resp.is_redirect:location = resp.headers.get("location")if not location:@@ -192,7 +207,7 @@ async def fetch_remote_bytes_async("""current = assert_safe_url(url, allow_http=allow_http)for _ in range(_MAX_REDIRECTS + 1):- async with client.stream("GET", current, headers=headers) as resp:+ async with client.stream("GET", current, headers=_fetch_headers(headers)) as resp:if resp.is_redirect:location = resp.headers.get("location")if not location:diff --git a/workers/model-triposg/test_worker_security_fetch.py b/workers/model-triposg/test_worker_security_fetch.pynew file mode 100644index 000000000..d016473f3--- /dev/null+++ b/workers/model-triposg/test_worker_security_fetch.py@@ -0,0 +1,53 @@+"""The safe fetchers send a descriptive User-Agent unless the caller sets one.++upload.wikimedia.org answers httpx's default "python-httpx/<version>" agent+with 403 Forbidden, so every job whose reference photo was a Wikimedia link+failed before inference (model-triposg, 2026-10-09). Run: pytest -q+"""++import asyncio++import httpx+import pytest++import worker_security as ws+++class _Recorder:+ def __init__(self):+ self.headers = []++ def handler(self, request: httpx.Request) -> httpx.Response:+ self.headers.append(request.headers)+ return httpx.Response(200, content=b"image-bytes")+++def recorder(monkeypatch):+ rec = _Recorder()+ transport = httpx.MockTransport(rec.handler)+ real_client, real_async = httpx.Client, httpx.AsyncClient+ monkeypatch.setattr(ws, "_resolve_safe_host", lambda host: None)+ monkeypatch.setattr(ws.httpx, "Client", lambda **kw: real_client(transport=transport, **kw))+ monkeypatch.setattr(ws.httpx, "AsyncClient", lambda **kw: real_async(transport=transport, **kw))+ return rec+++def test_sync_fetch_sends_the_default_user_agent(recorder):+ assert ws.fetch_remote_bytes("https://upload.example.org/a.jpg") == b"image-bytes"+ assert recorder.headers[0]["user-agent"] == ws.DEFAULT_USER_AGENT+++def test_async_fetch_sends_the_default_user_agent(recorder):+ async def run():+ async with httpx.AsyncClient(follow_redirects=False) as client:+ return await ws.fetch_remote_bytes_async(client, "https://upload.example.org/a.jpg")++ body = asyncio.run(run())+ assert body == b"image-bytes"+ assert recorder.headers[0]["user-agent"] == ws.DEFAULT_USER_AGENT+++def test_a_caller_user_agent_replaces_the_default_whatever_its_case(recorder):+ ws.fetch_remote_bytes("https://upload.example.org/a.jpg", headers={"user-agent": "custom/2"})+ assert recorder.headers[0].get_list("user-agent") == ["custom/2"]diff --git a/workers/model-triposg/worker_security.py b/workers/model-triposg/worker_security.pyindex a0360fe96..f920c365c 100644--- a/workers/model-triposg/worker_security.py+++ b/workers/model-triposg/worker_security.py@@ -61,6 +61,21 @@ def require_api_key(authorization: Optional[str], api_key: str) -> None:DEFAULT_MAX_BYTES = 64 * 1024 * 1024 # 64 MiB_MAX_REDIRECTS = 4+# Hosts that enforce a User-Agent policy refuse httpx's default+# "python-httpx/<version>": upload.wikimedia.org answers it with 403 Forbidden+# and serves the same image to a descriptive agent (measured 2026-10-09, when+# model-triposg failed every job whose reference photo was a Wikimedia link).+# Callers may still pass their own User-Agent; it replaces this one.+DEFAULT_USER_AGENT = "three.ws-worker/1.0 (+https://three.ws)"+++def _fetch_headers(headers: Optional[dict]) -> dict:+ """Caller headers over the default User-Agent, matched case-insensitively."""+ merged = dict(headers or {})+ if not any(str(k).lower() == "user-agent" for k in merged):+ merged["User-Agent"] = DEFAULT_USER_AGENT+ return merged+class UnsafeUrlError(ValueError):"""Raised when a URL targets a disallowed scheme or a private/internal IP."""@@ -153,7 +168,7 @@ def fetch_remote_bytes(current = assert_safe_url(url, allow_http=allow_http)with httpx.Client(follow_redirects=False, timeout=timeout) as client:for _ in range(_MAX_REDIRECTS + 1):- with client.stream("GET", current, headers=headers) as resp:+ with client.stream("GET", current, headers=_fetch_headers(headers)) as resp:if resp.is_redirect:location = resp.headers.get("location")if not location:@@ -192,7 +207,7 @@ async def fetch_remote_bytes_async("""current = assert_safe_url(url, allow_http=allow_http)for _ in range(_MAX_REDIRECTS + 1):- async with client.stream("GET", current, headers=headers) as resp:+ async with client.stream("GET", current, headers=_fetch_headers(headers)) as resp:if resp.is_redirect:location = resp.headers.get("location")if not location:diff --git a/workers/model-triposr/worker_security.py b/workers/model-triposr/worker_security.pyindex a0360fe96..f920c365c 100644--- a/workers/model-triposr/worker_security.py+++ b/workers/model-triposr/worker_security.py@@ -61,6 +61,21 @@ def require_api_key(authorization: Optional[str], api_key: str) -> None:DEFAULT_MAX_BYTES = 64 * 1024 * 1024 # 64 MiB_MAX_REDIRECTS = 4+# Hosts that enforce a User-Agent policy refuse httpx's default+# "python-httpx/<version>": upload.wikimedia.org answers it with 403 Forbidden+# and serves the same image to a descriptive agent (measured 2026-10-09, when+# model-triposg failed every job whose reference photo was a Wikimedia link).+# Callers may still pass their own User-Agent; it replaces this one.+DEFAULT_USER_AGENT = "three.ws-worker/1.0 (+https://three.ws)"+++def _fetch_headers(headers: Optional[dict]) -> dict:+ """Caller headers over the default User-Agent, matched case-insensitively."""+ merged = dict(headers or {})+ if not any(str(k).lower() == "user-agent" for k in merged):+ merged["User-Agent"] = DEFAULT_USER_AGENT+ return merged+class UnsafeUrlError(ValueError):"""Raised when a URL targets a disallowed scheme or a private/internal IP."""@@ -153,7 +168,7 @@ def fetch_remote_bytes(current = assert_safe_url(url, allow_http=allow_http)with httpx.Client(follow_redirects=False, timeout=timeout) as client:for _ in range(_MAX_REDIRECTS + 1):- with client.stream("GET", current, headers=headers) as resp:+ with client.stream("GET", current, headers=_fetch_headers(headers)) as resp:if resp.is_redirect:location = resp.headers.get("location")if not location:@@ -192,7 +207,7 @@ async def fetch_remote_bytes_async("""current = assert_safe_url(url, allow_http=allow_http)for _ in range(_MAX_REDIRECTS + 1):- async with client.stream("GET", current, headers=headers) as resp:+ async with client.stream("GET", current, headers=_fetch_headers(headers)) as resp:if resp.is_redirect:location = resp.headers.get("location")if not location:diff --git a/workers/model-video2motion/worker_security.py b/workers/model-video2motion/worker_security.pyindex a0360fe96..f920c365c 100644--- a/workers/model-video2motion/worker_security.py+++ b/workers/model-video2motion/worker_security.py@@ -61,6 +61,21 @@ def require_api_key(authorization: Optional[str], api_key: str) -> None:DEFAULT_MAX_BYTES = 64 * 1024 * 1024 # 64 MiB_MAX_REDIRECTS = 4+# Hosts that enforce a User-Agent policy refuse httpx's default+# "python-httpx/<version>": upload.wikimedia.org answers it with 403 Forbidden+# and serves the same image to a descriptive agent (measured 2026-10-09, when+# model-triposg failed every job whose reference photo was a Wikimedia link).+# Callers may still pass their own User-Agent; it replaces this one.+DEFAULT_USER_AGENT = "three.ws-worker/1.0 (+https://three.ws)"+++def _fetch_headers(headers: Optional[dict]) -> dict:+ """Caller headers over the default User-Agent, matched case-insensitively."""+ merged = dict(headers or {})+ if not any(str(k).lower() == "user-agent" for k in merged):+ merged["User-Agent"] = DEFAULT_USER_AGENT+ return merged+class UnsafeUrlError(ValueError):"""Raised when a URL targets a disallowed scheme or a private/internal IP."""@@ -153,7 +168,7 @@ def fetch_remote_bytes(current = assert_safe_url(url, allow_http=allow_http)with httpx.Client(follow_redirects=False, timeout=timeout) as client:for _ in range(_MAX_REDIRECTS + 1):- with client.stream("GET", current, headers=headers) as resp:+ with client.stream("GET", current, headers=_fetch_headers(headers)) as resp:if resp.is_redirect:location = resp.headers.get("location")if not location:@@ -192,7 +207,7 @@ async def fetch_remote_bytes_async("""current = assert_safe_url(url, allow_http=allow_http)for _ in range(_MAX_REDIRECTS + 1):- async with client.stream("GET", current, headers=headers) as resp:+ async with client.stream("GET", current, headers=_fetch_headers(headers)) as resp:if resp.is_redirect:location = resp.headers.get("location")if not location:diff --git a/workers/model-video2scene/worker_security.py b/workers/model-video2scene/worker_security.pyindex a0360fe96..f920c365c 100644--- a/workers/model-video2scene/worker_security.py+++ b/workers/model-video2scene/worker_security.py@@ -61,6 +61,21 @@ def require_api_key(authorization: Optional[str], api_key: str) -> None:DEFAULT_MAX_BYTES = 64 * 1024 * 1024 # 64 MiB_MAX_REDIRECTS = 4+# Hosts that enforce a User-Agent policy refuse httpx's default+# "python-httpx/<version>": upload.wikimedia.org answers it with 403 Forbidden+# and serves the same image to a descriptive agent (measured 2026-10-09, when+# model-triposg failed every job whose reference photo was a Wikimedia link).+# Callers may still pass their own User-Agent; it replaces this one.+DEFAULT_USER_AGENT = "three.ws-worker/1.0 (+https://three.ws)"+++def _fetch_headers(headers: Optional[dict]) -> dict:+ """Caller headers over the default User-Agent, matched case-insensitively."""+ merged = dict(headers or {})+ if not any(str(k).lower() == "user-agent" for k in merged):+ merged["User-Agent"] = DEFAULT_USER_AGENT+ return merged+class UnsafeUrlError(ValueError):"""Raised when a URL targets a disallowed scheme or a private/internal IP."""@@ -153,7 +168,7 @@ def fetch_remote_bytes(current = assert_safe_url(url, allow_http=allow_http)with httpx.Client(follow_redirects=False, timeout=timeout) as client:for _ in range(_MAX_REDIRECTS + 1):- with client.stream("GET", current, headers=headers) as resp:+ with client.stream("GET", current, headers=_fetch_headers(headers)) as resp:if resp.is_redirect:location = resp.headers.get("location")if not location:@@ -192,7 +207,7 @@ async def fetch_remote_bytes_async("""current = assert_safe_url(url, allow_http=allow_http)for _ in range(_MAX_REDIRECTS + 1):- async with client.stream("GET", current, headers=headers) as resp:+ async with client.stream("GET", current, headers=_fetch_headers(headers)) as resp:if resp.is_redirect:location = resp.headers.get("location")if not location:diff --git a/workers/rembg/worker_security.py b/workers/rembg/worker_security.pyindex a0360fe96..f920c365c 100644--- a/workers/rembg/worker_security.py+++ b/workers/rembg/worker_security.py@@ -61,6 +61,21 @@ def require_api_key(authorization: Optional[str], api_key: str) -> None:DEFAULT_MAX_BYTES = 64 * 1024 * 1024 # 64 MiB_MAX_REDIRECTS = 4+# Hosts that enforce a User-Agent policy refuse httpx's default+# "python-httpx/<version>": upload.wikimedia.org answers it with 403 Forbidden+# and serves the same image to a descriptive agent (measured 2026-10-09, when+# model-triposg failed every job whose reference photo was a Wikimedia link).+# Callers may still pass their own User-Agent; it replaces this one.+DEFAULT_USER_AGENT = "three.ws-worker/1.0 (+https://three.ws)"+++def _fetch_headers(headers: Optional[dict]) -> dict:+ """Caller headers over the default User-Agent, matched case-insensitively."""+ merged = dict(headers or {})+ if not any(str(k).lower() == "user-agent" for k in merged):+ merged["User-Agent"] = DEFAULT_USER_AGENT+ return merged+class UnsafeUrlError(ValueError):"""Raised when a URL targets a disallowed scheme or a private/internal IP."""@@ -153,7 +168,7 @@ def fetch_remote_bytes(current = assert_safe_url(url, allow_http=allow_http)with httpx.Client(follow_redirects=False, timeout=timeout) as client:for _ in range(_MAX_REDIRECTS + 1):- with client.stream("GET", current, headers=headers) as resp:+ with client.stream("GET", current, headers=_fetch_headers(headers)) as resp:if resp.is_redirect:location = resp.headers.get("location")if not location:@@ -192,7 +207,7 @@ async def fetch_remote_bytes_async("""current = assert_safe_url(url, allow_http=allow_http)for _ in range(_MAX_REDIRECTS + 1):- async with client.stream("GET", current, headers=headers) as resp:+ async with client.stream("GET", current, headers=_fetch_headers(headers)) as resp:if resp.is_redirect:location = resp.headers.get("location")if not location:diff --git a/workers/remesh/worker_security.py b/workers/remesh/worker_security.pyindex a0360fe96..f920c365c 100644--- a/workers/remesh/worker_security.py+++ b/workers/remesh/worker_security.py@@ -61,6 +61,21 @@ def require_api_key(authorization: Optional[str], api_key: str) -> None:DEFAULT_MAX_BYTES = 64 * 1024 * 1024 # 64 MiB_MAX_REDIRECTS = 4+# Hosts that enforce a User-Agent policy refuse httpx's default+# "python-httpx/<version>": upload.wikimedia.org answers it with 403 Forbidden+# and serves the same image to a descriptive agent (measured 2026-10-09, when+# model-triposg failed every job whose reference photo was a Wikimedia link).+# Callers may still pass their own User-Agent; it replaces this one.+DEFAULT_USER_AGENT = "three.ws-worker/1.0 (+https://three.ws)"+++def _fetch_headers(headers: Optional[dict]) -> dict:+ """Caller headers over the default User-Agent, matched case-insensitively."""+ merged = dict(headers or {})+ if not any(str(k).lower() == "user-agent" for k in merged):+ merged["User-Agent"] = DEFAULT_USER_AGENT+ return merged+class UnsafeUrlError(ValueError):"""Raised when a URL targets a disallowed scheme or a private/internal IP."""@@ -153,7 +168,7 @@ def fetch_remote_bytes(current = assert_safe_url(url, allow_http=allow_http)with httpx.Client(follow_redirects=False, timeout=timeout) as client:for _ in range(_MAX_REDIRECTS + 1):- with client.stream("GET", current, headers=headers) as resp:+ with client.stream("GET", current, headers=_fetch_headers(headers)) as resp:if resp.is_redirect:location = resp.headers.get("location")if not location:@@ -192,7 +207,7 @@ async def fetch_remote_bytes_async("""current = assert_safe_url(url, allow_http=allow_http)for _ in range(_MAX_REDIRECTS + 1):- async with client.stream("GET", current, headers=headers) as resp:+ async with client.stream("GET", current, headers=_fetch_headers(headers)) as resp:if resp.is_redirect:location = resp.headers.get("location")if not location:diff --git a/workers/rig/worker_security.py b/workers/rig/worker_security.pyindex a0360fe96..f920c365c 100644--- a/workers/rig/worker_security.py+++ b/workers/rig/worker_security.py@@ -61,6 +61,21 @@ def require_api_key(authorization: Optional[str], api_key: str) -> None:DEFAULT_MAX_BYTES = 64 * 1024 * 1024 # 64 MiB_MAX_REDIRECTS = 4+# Hosts that enforce a User-Agent policy refuse httpx's default+# "python-httpx/<version>": upload.wikimedia.org answers it with 403 Forbidden+# and serves the same image to a descriptive agent (measured 2026-10-09, when+# model-triposg failed every job whose reference photo was a Wikimedia link).+# Callers may still pass their own User-Agent; it replaces this one.+DEFAULT_USER_AGENT = "three.ws-worker/1.0 (+https://three.ws)"+++def _fetch_headers(headers: Optional[dict]) -> dict:+ """Caller headers over the default User-Agent, matched case-insensitively."""+ merged = dict(headers or {})+ if not any(str(k).lower() == "user-agent" for k in merged):+ merged["User-Agent"] = DEFAULT_USER_AGENT+ return merged+class UnsafeUrlError(ValueError):"""Raised when a URL targets a disallowed scheme or a private/internal IP."""@@ -153,7 +168,7 @@ def fetch_remote_bytes(current = assert_safe_url(url, allow_http=allow_http)with httpx.Client(follow_redirects=False, timeout=timeout) as client:for _ in range(_MAX_REDIRECTS + 1):- with client.stream("GET", current, headers=headers) as resp:+ with client.stream("GET", current, headers=_fetch_headers(headers)) as resp:if resp.is_redirect:location = resp.headers.get("location")if not location:@@ -192,7 +207,7 @@ async def fetch_remote_bytes_async("""current = assert_safe_url(url, allow_http=allow_http)for _ in range(_MAX_REDIRECTS + 1):- async with client.stream("GET", current, headers=headers) as resp:+ async with client.stream("GET", current, headers=_fetch_headers(headers)) as resp:if resp.is_redirect:location = resp.headers.get("location")if not location:diff --git a/workers/segment/worker_security.py b/workers/segment/worker_security.pyindex a0360fe96..f920c365c 100644--- a/workers/segment/worker_security.py+++ b/workers/segment/worker_security.py@@ -61,6 +61,21 @@ def require_api_key(authorization: Optional[str], api_key: str) -> None:DEFAULT_MAX_BYTES = 64 * 1024 * 1024 # 64 MiB_MAX_REDIRECTS = 4+# Hosts that enforce a User-Agent policy refuse httpx's default+# "python-httpx/<version>": upload.wikimedia.org answers it with 403 Forbidden+# and serves the same image to a descriptive agent (measured 2026-10-09, when+# model-triposg failed every job whose reference photo was a Wikimedia link).+# Callers may still pass their own User-Agent; it replaces this one.+DEFAULT_USER_AGENT = "three.ws-worker/1.0 (+https://three.ws)"+++def _fetch_headers(headers: Optional[dict]) -> dict:+ """Caller headers over the default User-Agent, matched case-insensitively."""+ merged = dict(headers or {})+ if not any(str(k).lower() == "user-agent" for k in merged):+ merged["User-Agent"] = DEFAULT_USER_AGENT+ return merged+class UnsafeUrlError(ValueError):"""Raised when a URL targets a disallowed scheme or a private/internal IP."""@@ -153,7 +168,7 @@ def fetch_remote_bytes(current = assert_safe_url(url, allow_http=allow_http)with httpx.Client(follow_redirects=False, timeout=timeout) as client:for _ in range(_MAX_REDIRECTS + 1):- with client.stream("GET", current, headers=headers) as resp:+ with client.stream("GET", current, headers=_fetch_headers(headers)) as resp:if resp.is_redirect:location = resp.headers.get("location")if not location:@@ -192,7 +207,7 @@ async def fetch_remote_bytes_async("""current = assert_safe_url(url, allow_http=allow_http)for _ in range(_MAX_REDIRECTS + 1):- async with client.stream("GET", current, headers=headers) as resp:+ async with client.stream("GET", current, headers=_fetch_headers(headers)) as resp:if resp.is_redirect:location = resp.headers.get("location")if not location:diff --git a/workers/stylize/worker_security.py b/workers/stylize/worker_security.pyindex a0360fe96..f920c365c 100644--- a/workers/stylize/worker_security.py+++ b/workers/stylize/worker_security.py@@ -61,6 +61,21 @@ def require_api_key(authorization: Optional[str], api_key: str) -> None:DEFAULT_MAX_BYTES = 64 * 1024 * 1024 # 64 MiB_MAX_REDIRECTS = 4+# Hosts that enforce a User-Agent policy refuse httpx's default+# "python-httpx/<version>": upload.wikimedia.org answers it with 403 Forbidden+# and serves the same image to a descriptive agent (measured 2026-10-09, when+# model-triposg failed every job whose reference photo was a Wikimedia link).+# Callers may still pass their own User-Agent; it replaces this one.+DEFAULT_USER_AGENT = "three.ws-worker/1.0 (+https://three.ws)"+++def _fetch_headers(headers: Optional[dict]) -> dict:+ """Caller headers over the default User-Agent, matched case-insensitively."""+ merged = dict(headers or {})+ if not any(str(k).lower() == "user-agent" for k in merged):+ merged["User-Agent"] = DEFAULT_USER_AGENT+ return merged+class UnsafeUrlError(ValueError):"""Raised when a URL targets a disallowed scheme or a private/internal IP."""@@ -153,7 +168,7 @@ def fetch_remote_bytes(current = assert_safe_url(url, allow_http=allow_http)with httpx.Client(follow_redirects=False, timeout=timeout) as client:for _ in range(_MAX_REDIRECTS + 1):- with client.stream("GET", current, headers=headers) as resp:+ with client.stream("GET", current, headers=_fetch_headers(headers)) as resp:if resp.is_redirect:location = resp.headers.get("location")if not location:@@ -192,7 +207,7 @@ async def fetch_remote_bytes_async("""current = assert_safe_url(url, allow_http=allow_http)for _ in range(_MAX_REDIRECTS + 1):- async with client.stream("GET", current, headers=headers) as resp:+ async with client.stream("GET", current, headers=_fetch_headers(headers)) as resp:if resp.is_redirect:location = resp.headers.get("location")if not location:diff --git a/workers/texture/worker_security.py b/workers/texture/worker_security.pyindex a0360fe96..f920c365c 100644--- a/workers/texture/worker_security.py+++ b/workers/texture/worker_security.py@@ -61,6 +61,21 @@ def require_api_key(authorization: Optional[str], api_key: str) -> None:DEFAULT_MAX_BYTES = 64 * 1024 * 1024 # 64 MiB_MAX_REDIRECTS = 4+# Hosts that enforce a User-Agent policy refuse httpx's default+# "python-httpx/<version>": upload.wikimedia.org answers it with 403 Forbidden+# and serves the same image to a descriptive agent (measured 2026-10-09, when+# model-triposg failed every job whose reference photo was a Wikimedia link).+# Callers may still pass their own User-Agent; it replaces this one.+DEFAULT_USER_AGENT = "three.ws-worker/1.0 (+https://three.ws)"+++def _fetch_headers(headers: Optional[dict]) -> dict:+ """Caller headers over the default User-Agent, matched case-insensitively."""+ merged = dict(headers or {})+ if not any(str(k).lower() == "user-agent" for k in merged):+ merged["User-Agent"] = DEFAULT_USER_AGENT+ return merged+class UnsafeUrlError(ValueError):"""Raised when a URL targets a disallowed scheme or a private/internal IP."""@@ -153,7 +168,7 @@ def fetch_remote_bytes(current = assert_safe_url(url, allow_http=allow_http)with httpx.Client(follow_redirects=False, timeout=timeout) as client:for _ in range(_MAX_REDIRECTS + 1):- with client.stream("GET", current, headers=headers) as resp:+ with client.stream("GET", current, headers=_fetch_headers(headers)) as resp:if resp.is_redirect:location = resp.headers.get("location")if not location:@@ -192,7 +207,7 @@ async def fetch_remote_bytes_async("""current = assert_safe_url(url, allow_http=allow_http)for _ in range(_MAX_REDIRECTS + 1):- async with client.stream("GET", current, headers=headers) as resp:+ async with client.stream("GET", current, headers=_fetch_headers(headers)) as resp:if resp.is_redirect:location = resp.headers.get("location")if not location: