Repository navigation
fix(async): move remote image fetches off the event loop for Snowflake, Bedrock invoke Claude, Mantle and Gemini - #39839
Conversation
…e, Bedrock invoke Claude, Mantle and Gemini
Greptile SummaryThis PR moves remote-media processing off async request event loops while preserving provider-specific payload behavior.
Confidence Score: 5/5The PR appears safe to merge because no actionable new issue or outstanding previous finding remains. There are no changes after the previous review SHA, all earlier findings are resolved, and the current diff preserves Gemini Files API pass-through while adding tested asynchronous media processing. The DNS-guidance thread was manually resolved without explanation; the two rule-related false positives were conceded, and the remaining compatibility thread was resolved.
|
| Filename | Overview |
|---|---|
| litellm/litellm_core_utils/prompt_templates/image_handling.py | Adds bounded asynchronous remote-media discovery, fetching, cancellation, deduplication, and immutable message reconstruction. |
| litellm/litellm_core_utils/url_utils.py | Moves DNS-backed URL validation to a worker thread for asynchronous safe fetches. |
| litellm/llms/custom_httpx/llm_http_handler.py | Dispatches opted-in async provider transforms and moves signing and pre-call logging off the event loop. |
| litellm/llms/bedrock/chat/invoke_transformations/anthropic_claude3_transformation.py | Routes Bedrock Invoke Claude remote media through the shared async inlining path before synchronous payload shaping. |
| litellm/llms/bedrock/chat/mantle/transformation.py | Uses shared asynchronous media inlining while retaining Mantle-specific request restoration. |
| litellm/llms/gemini/chat/transformation.py | Preserves Gemini Files API references instead of attempting to download them. |
| litellm/llms/vertex_ai/gemini/transformation.py | Asynchronously inlines media only where required while preserving Gemini Files API, GCS, and MIME-hinted pass-through behavior. |
| litellm/llms/snowflake/chat/transformation.py | Enables shared asynchronous media inlining for Snowflake Claude requests. |
| litellm/llms/black_forest_labs/image_edit/transformation.py | Downloads URL-based image and mask inputs asynchronously before applying the existing image-edit transform. |
| litellm/llms/base_llm/image_edit/transformation.py | Adds a default asynchronous image-edit transform hook that preserves existing provider behavior. |
| litellm/main.py | Honors an injected Snowflake HTTP client while retaining the existing fallback client lifecycle. |
| tests/test_litellm/litellm_core_utils/test_image_handling.py | Covers remote-media shapes, concurrency limits, deduplication, cancellation, immutability, and SSRF failure behavior. |
Reviews (8): Last reviewed commit: "Merge remote-tracking branch 'origin/lit..." | Re-trigger Greptile
| ) | ||
| if not remote_urls: | ||
| return messages | ||
| data_urls: Final = await asyncio.gather(*(async_convert_url_to_base64(url) for url in remote_urls)) |
There was a problem hiding this comment.
Low: Unbounded concurrent media downloads
An authenticated caller can include an arbitrary number of unique remote media parts, causing gather to start all downloads concurrently and retain every base64 result. The per-file size limit does not cap aggregate memory or connection usage, so a small request containing many URLs can exhaust a proxy worker. Use a bounded worker pool or semaphore, enforce a maximum URL count and aggregate byte limit, and cancel remaining downloads when one fails.
PR overviewThis pull request moves remote image fetching off the event loop for Snowflake, Bedrock Claude invocation, Mantle, and Gemini integrations. It also updates shared media handling and Gemini request transformation behavior. Two security issues remain open after one was addressed. Gemini file references can bypass tenant ownership controls, allowing an authenticated caller who knows another tenant’s file URI to expose that file through the shared Gemini credentials. Remote media downloads also lack concurrency and aggregate resource limits, which could allow authenticated callers to exhaust proxy worker resources. Open issues (2)
Fixed/addressed: 1 · PR risk: 7/10 |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Gemini AI Studio file URIs under generativelanguage.googleapis.com/v1beta/files/ answer 403 when fetched and must pass through as file_data.file_uri, which the sync transform already did. Give the shared walker a skip_url_prefixes parameter, pass that prefix from the Gemini body builder, and skip it in the AI Studio message transform for both image_url and file parts
|
|
||
| if _openai_messages_may_need_sync_gcs_metadata_fetch(messages): | ||
| inlined_messages: Final = ( | ||
| await async_inline_remote_media(messages, skip_url_prefixes=(GEMINI_FILES_API_URI_PREFIX,)) |
There was a problem hiding this comment.
Medium: Gemini file references bypass tenant ownership
This exemption, together with the new checks in litellm/llms/gemini/chat/transformation.py, forwards any caller-supplied Gemini Files API URI under the proxy's shared Gemini credentials. An authenticated user who obtains another tenant's file URI can reference it in a completion and ask the model to return its contents; validate the file against a proxy-managed owner/team record before forwarding it, or reject raw Files API URIs from untrusted requests.
There was a problem hiding this comment.
Raw Gemini Files API URIs already passed through unchanged at the merge base. This PR keeps that. Ownership checks belong in the managed files layer.
There was a problem hiding this comment.
Thanks for the detail. I can't automatically confirm this is safe to dismiss, so I'm leaving the thread open for a maintainer to make the call.
|
bugbot run |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
Autofix Details
Bugbot Autofix prepared a fix for the issue found in the latest run.
- ✅ Fixed: Document URLs still block the event loop
- Extended async_inline_remote_media to also recognize native Anthropic image and document blocks with source.type=url so URL fetches always run on the async client instead of falling through to the sync converter or being forwarded to the provider.
Or push these changes by commenting:
@cursor push af7ca373d1
Preview (af7ca373d1)
diff --git a/litellm/litellm_core_utils/prompt_templates/image_handling.py b/litellm/litellm_core_utils/prompt_templates/image_handling.py
--- a/litellm/litellm_core_utils/prompt_templates/image_handling.py
+++ b/litellm/litellm_core_utils/prompt_templates/image_handling.py
@@ -149,6 +149,15 @@
url: str
+@dataclass(frozen=True, slots=True)
+class _RemoteAnthropicSource:
+ part: Mapping[str, object]
+ url: str
+
+
+_ANTHROPIC_MEDIA_BLOCK_TYPES: Final = frozenset({"image", "document"})
+
+
def _as_mapping(value: object) -> Mapping[str, object] | None:
return value if isinstance(value, Mapping) else None # pyright: ignore[reportUnknownVariableType] # fields are parsed one by one
@@ -157,18 +166,27 @@
return candidate if isinstance(candidate, str) and candidate.startswith(_REMOTE_URL_PREFIXES) else None
-def _parse_remote_part(part: object) -> _RemoteImage | _RemoteFile | None:
+def _parse_remote_part(part: object) -> _RemoteImage | _RemoteFile | _RemoteAnthropicSource | None:
fields: Final = _as_mapping(part)
if fields is None:
return None
- if fields.get("type") == "image_url":
+ part_type: Final = fields.get("type")
+ if part_type == "image_url":
image_url: Final = fields.get("image_url")
image_url_fields: Final = _as_mapping(image_url)
url: Final = _remote_url(image_url_fields.get("url") if image_url_fields is not None else image_url)
return _RemoteImage(fields, image_url_fields, url) if url is not None else None
- file: Final = _as_mapping(fields.get("file")) if fields.get("type") == "file" else None
- file_url: Final = _remote_url(file.get("file_id")) if file is not None else None
- return _RemoteFile(fields, file, file_url) if file is not None and file_url is not None else None
+ if part_type == "file":
+ file: Final = _as_mapping(fields.get("file"))
+ file_url: Final = _remote_url(file.get("file_id")) if file is not None else None
+ return _RemoteFile(fields, file, file_url) if file is not None and file_url is not None else None
+ if part_type in _ANTHROPIC_MEDIA_BLOCK_TYPES:
+ source: Final = _as_mapping(fields.get("source"))
+ source_url: Final = (
+ _remote_url(source.get("url")) if source is not None and source.get("type") == "url" else None
+ )
+ return _RemoteAnthropicSource(fields, source_url) if source_url is not None else None
+ return None
_PDF_FORMAT: Final = MappingProxyType({"format": "application/pdf"})
@@ -187,12 +205,19 @@
return {**kept, **_inferred_format(file, url), "file_data": data_url} # mutable-ok: json-serialized part
-def _inline(remote: _RemoteImage | _RemoteFile, data_url: str) -> Mapping[str, object]:
+def _inlined_anthropic_source(data_url: str) -> Mapping[str, object]:
+ media_type, _, data = data_url.removeprefix("data:").partition(";base64,")
+ return {"type": "base64", "media_type": media_type, "data": data} # mutable-ok: json-serialized source block
+
+
+def _inline(remote: _RemoteImage | _RemoteFile | _RemoteAnthropicSource, data_url: str) -> Mapping[str, object]:
match remote:
case _RemoteImage(part, image_url, _):
return {**part, "image_url": _inlined_image_url(image_url, data_url)} # mutable-ok: json-serialized part
case _RemoteFile(part, file, url):
return {**part, "file": _inlined_file(file, url, data_url)} # mutable-ok: json-serialized message part
+ case _RemoteAnthropicSource(part, _):
+ return {**part, "source": _inlined_anthropic_source(data_url)} # mutable-ok: json-serialized message part
def _content_parts(message: Mapping[str, object]) -> tuple[object, ...]:
diff --git a/tests/test_litellm/litellm_core_utils/test_image_handling.py b/tests/test_litellm/litellm_core_utils/test_image_handling.py
--- a/tests/test_litellm/litellm_core_utils/test_image_handling.py
+++ b/tests/test_litellm/litellm_core_utils/test_image_handling.py
@@ -371,6 +371,53 @@
assert async_only_image_fetch.fetched == []
+async def test_async_inline_remote_media_inlines_native_anthropic_url_sources(async_only_image_fetch):
+ """Native Anthropic ``image`` / ``document`` blocks with ``source.type=url`` must
+ also be walked, otherwise their URLs leak past the async inliner and get
+ fetched by the sync fallback on the event loop (Bedrock invoke) or forwarded
+ to the provider as-is (Mantle)."""
+ image_source_url = f"http://img.example/{uuid.uuid4()}.png"
+ document_source_url = f"http://docs.example/{uuid.uuid4()}.png"
+ messages = [
+ {
+ "role": "user",
+ "content": [
+ {"type": "image", "source": {"type": "url", "url": image_source_url}},
+ {
+ "type": "document",
+ "source": {"type": "url", "url": document_source_url},
+ "title": "Doc",
+ },
+ {
+ "type": "image",
+ "source": {"type": "base64", "media_type": "image/png", "data": "AAA="},
+ },
+ ],
+ }
+ ]
+ snapshot = copy.deepcopy(messages)
+
+ inlined = await async_inline_remote_media(messages)
+
+ assert inlined[0]["content"] == [
+ {
+ "type": "image",
+ "source": {"type": "base64", "media_type": "image/png", "data": async_only_image_fetch.base64_png},
+ },
+ {
+ "type": "document",
+ "source": {"type": "base64", "media_type": "image/png", "data": async_only_image_fetch.base64_png},
+ "title": "Doc",
+ },
+ {
+ "type": "image",
+ "source": {"type": "base64", "media_type": "image/png", "data": "AAA="},
+ },
+ ]
+ assert sorted(async_only_image_fetch.fetched) == sorted([image_source_url, document_source_url])
+ assert messages == snapshot
+
+
async def test_async_inline_remote_media_raises_image_fetch_error_when_the_fetch_fails(monkeypatch):
async def serve_404(client, url, **kwargs):
return Response(404, request=Request("GET", url))You can send follow-ups to the cloud agent here.
…blocks in the async walker
|
bugbot run |
… the event loop The SSRF check in async_safe_get resolved DNS on the event loop and a blocked address was retried three times; validate_url now runs in a thread and an SSRFError fails the fetch on the first attempt in both fetchers. The shared HTTP handler signed the request and ran pre_call logging on the loop after an async transform; both now run in a thread. Vertex AI Gemini still fetched http:// images and https images without an inferrable mime type with the sync converter inside its async body builder; the walker takes a should_inline predicate and Vertex AI inlines exactly those URLs, leaving https images with a known mime type and Files API refs to Google. When one download fails the other in-flight downloads for that request are now cancelled instead of finishing in the background
…itellm_async_remote_image_fetch
…y verdict from callers The image edit handler now awaits BaseImageEditConfig.async_transform_image_edit_request, and Black Forest Labs overrides it so URL images and masks download through async_safe_get instead of the blocking safe_get on the event loop. Rejected image fetches raise a fixed policy message with the user_url_allowed_hosts hint rather than echoing the resolver's verdict (resolved IP, DNS failure) back to the caller. The test fixture also fails any request-path call of the sync convert_url_to_base64 so a regression cannot pass unnoticed.
… instead of blaming the URL policy validate_url raises HostResolutionError, a SSRFError subclass, for the two DNS outcomes (lookup failed, no addresses). The image fetch helper maps that to a "host could not be resolved" message and keeps the user_url_allowed_hosts hint for the policy verdicts it can actually fix.
…error text cannot probe internal hostnames
…itellm_async_remote_image_fetch # Conflicts: # litellm/llms/black_forest_labs/image_edit/transformation.py
1 similar comment
|
bugbot run |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 59e000d. Configure here.
9700f66
into
litellm_internal_staging

TLDR
Problem this solves:
How it solves it:
async_transform_requestfor configs that opt inhttp://, or https with no known mime type)documentandimageblocks with url sources go through the same walker, so the async path leaves nothing for the sync converteruser_url_allowed_hosts), so the error text does not tell a caller which internal hostnames exist; the real verdict goes to the proxy log at warning level. Two callers outside this graph still forward the verdict (auth_utils,langfuse_endpoints), tracked in LIT-7045async_transform_image_edit_requesthook that the async handler awaits; Black Forest Labs uses it to download a URL image and mask with the async fetcher before its sync transform runsUser Flow
Before: a developer whose app sends chat completions with remote image URLs to a Snowflake Cortex Claude, Bedrock invoke Claude, Gemini or Vertex AI Gemini deployment stalls everyone else on the same proxy workers while the images download
gemini-flash(gemini/gemini-3.8-flash),vertex-gemini(vertex_ai/gemini-3.8-flash),bedrock-claude(bedrock/invoke/us.anthropic.claude-sonnet-5),bedrock-mantle(bedrock/mantle/anthropic.claude-sonnet-5) andsnowflake-claude(snowflake/claude-sonnet-4-6) deploymentsgemini-flashat once, each with animage_urlpart whose host takes 8 seconds to serve the image"content": "Green"after 19.0, 19.0, 21.2 and 22.1 seconds, because each worker downloads its images one after anotherbedrock-claudecome back in two waves (44 after 10.1 to 11.2 seconds, 16 after 17.8 to 23.2 seconds); sixty sent tosnowflake-claudecome back in two waves the same way (40 after 9.3 to 9.8 seconds, 20 after 16.6 to 16.9 seconds), and a text-only POST https://litellm-domain/v1/chat/completions togemini-flashsent 1.5 seconds into the Bedrock fan-out waits 8.3 seconds for a free executor thread (0.7 seconds during the Snowflake fan-out, which left four threads free)input_image), POST https://litellm-domain/v1/messages (imagewith a url source) or streaming POST https://litellm-domain/v1/chat/completions togemini-flashhang GET https://litellm-domain/health/liveliness for 8.1, 7.5 and 15.5 seconds and come back after 11.6 to 26.1, 9.7 to 26.6 and 17.8 to 22.2 secondsvertex-geminiwith anhttp://image hang GET https://litellm-domain/health/liveliness for 16.1 seconds and come back after 19.6, 20.2, 20.4 and 21.9 secondsgemini-flashcarrying 25 distinct images from a host that takes 2 seconds per image comes back after 55.0 seconds, because the images download one after anotherbedrock-mantlecomes back 200 after 10.0 seconds; four POST https://litellm-domain/v1/messages requests tobedrock-claudewith a url image source come back 400 in 1.6 seconds because Bedrock rejects url sources itself ("URL content sources are not yet supported for this model")image_urlpointing at a blocked private address comes back 400 "Unable to fetch image from URL after 3 attempts" on every deploymentimage_urlon a host that does not resolve is looked up three times before the same "after 3 attempts" 400 comes backopenai-image-edit(openai/gpt-image-2) with a PNG upload comes back 200 with the edited image (b64_json) and 226 usage tokens after 11.9 secondsbedrock-claudeand two tobedrock-mantlestream"Green"back after 9.9 to 10.3 and 9.8 to 10.8 seconds, and four tosnowflake-claudeget the stand-in's 401 after 8.2 to 8.5 seconds once the image is downloaded and inlined; GET https://litellm-domain/health/liveliness stays at 131, 94 and 111 milliseconds at worst, because these streaming downloads queue on executor threads rather than the loop and four at a time never fill the pool (step 5 does)After: the same requests come back with the same answers, and the rest of the traffic on those workers keeps flowing while the images download
gemini-flashwith the same slowimage_url"content": "Green"together after 14.5 to 15.6 seconds, because the downloads now run side by sidebedrock-claudeall come back 200 in one wave (9.7 to 11.8 seconds); sixty tosnowflake-claudefinish in one wave too (8.5 to 9.8 seconds), and the text-onlygemini-flashrequest sent 1.5 seconds into that fan-out answers in 0.7 seconds (1.0 seconds during the Snowflake fan-out)gemini-flashleave GET https://litellm-domain/health/liveliness at milliseconds (82, 106 and 429 milliseconds at worst) and come back after 9.8 to 10.5, 9.6 to 10.5 and 9.5 to 12.2 secondsvertex-geminiwith anhttp://image leave GET https://litellm-domain/health/liveliness at 87 milliseconds at worst and come back after 10.2 to 10.6 secondsbedrock-mantlerequest comes back 200 after 10.8 seconds, and the four POST https://litellm-domain/v1/messages requests tobedrock-claudestill come back 400 from Bedrock in 1.4 to 2.1 seconds: that route hands url sources to Bedrock untouched, before and afteruser_url_allowed_hostshint, with no resolved IP or DNS detail in the response, on every deploymentasync_transform_image_edit_requestdefault the async handler now awaits hands OpenAI the same request, and OpenAI's answer is unchangedbedrock-claudeafter 10.7 to 11.1 seconds,bedrock-mantleafter 10.4 to 10.5 seconds andsnowflake-claudewith the stand-in's 401 after 9.9 to 10.9 seconds, with GET https://litellm-domain/health/liveliness at 141, 168 and 173 milliseconds at worst; their downloads now run on the loop's async client instead of executor threads, which is why sixty of them no longer form waves (step 5)Relevant issues
Follow-up to the unresolved review thread on #39453
Linear ticket
Resolves LIT-6923
Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
uv run pytest tests/test_litellm/<your_test_file>.py -v. Leave the suites (make test-unit-*,make test-unit) to CI: it finishes in ~15 minutes where a laptop takes an hour or more@greptileaito re-request a review after pushing changes)Delays in PR merge?
If you're seeing a delay in your PR being merged, ping the LiteLLM Team on Slack (#pr-review).
Screenshots / Proof of Fix
Shared setup for both legs: one proxy process per leg booted with
--num_workers 2(two uvicorn workers), no database, real Gemini, Vertex AI and Bedrock calls costing real money. No Snowflake Cortex credentials are available, so a local stand-in takes the Snowflake requests: it dumps every request body, logs the content sources it receives and answers 401, which still shows the image was downloaded and inlined before the request left the proxy. Every image URL carries a cache-busting query string (?delay=8&label=<leg>&n=<case-request>), so the proxy's image cache never short-circuits a download. The box ran at load 17 to 26 on 18 cores with swap full for the whole run (about twenty other agents on it), so absolute timings are inflated on both sides; the shapes (probe stalls, waves, serial vs parallel downloads) are the evidenceconfig.yaml
slow_image_server.py (GET sleeps `delay` seconds, then serves a 1x1 PNG; POST dumps the body, logs the Anthropic content sources and answers 401)
legs2.sh (the fourteen cases and their request bodies)
Boot commands:
Before (29ac88e)
Leg A: four slow-image POST /v1/chat/completions requests to gemini-flash while probing GET /health/liveliness
./legs2.sh 27860 33721 before(this case is its Leg A block)Observed:
Leg B: sixty slow-image POST /v1/chat/completions requests to bedrock-claude, then a text-only gemini-flash request 1.5s later
./legs2.sh 27860 33721 before(this case is its Leg B block)Observed:
Leg C: sixty slow-image POST /v1/chat/completions requests to snowflake-claude, then a text-only gemini-flash request 1.5s later
./legs2.sh 27860 33721 before(this case is its Leg C block)Observed:
Leg D: four slow-image POST /v1/responses requests to gemini-flash while probing GET /health/liveliness
./legs2.sh 27860 33721 before(this case is its Leg D block)Observed:
Leg E: four slow-image POST /v1/messages requests to gemini-flash while probing GET /health/liveliness
./legs2.sh 27860 33721 before(this case is its Leg E block)Observed:
Leg F: one POST /v1/chat/completions to gemini-flash carrying 25 distinct slow images (2s each) while probing GET /health/liveliness
./legs2.sh 27860 33721 before(this case is its Leg F block)Observed:
Leg G: four slow-image streaming POST /v1/chat/completions requests to gemini-flash while probing GET /health/liveliness
./legs2.sh 27860 33721 before(this case is its Leg G block)Observed:
Leg H: four slow-image POST /v1/chat/completions requests to vertex-gemini (http:// image) while probing GET /health/liveliness
./legs2.sh 27860 33721 before(this case is its Leg H block)Observed:
Leg I: four slow-image POST /v1/messages requests to bedrock-claude while probing GET /health/liveliness
./legs2.sh 27860 33721 before(this case is its Leg I block)Observed:
Leg J: one slow-image POST /v1/chat/completions request to bedrock-mantle
./legs2.sh 27860 33721 before(this case is its Leg J block)Observed:
Leg K: one multipart POST /v1/images/edits to openai-image-edit (openai/gpt-image-2) with a 64x64 PNG upload
./legs2.sh 27860 33721 before(this case is its Leg K block)Observed:
Leg L: four slow-image streaming POST /v1/chat/completions requests to bedrock-claude while probing GET /health/liveliness
./legs2.sh 27860 33721 before(this case is its Leg L block)Observed:
Leg M: two slow-image streaming POST /v1/chat/completions requests to bedrock-mantle while probing GET /health/liveliness
./legs2.sh 27860 33721 before(this case is its Leg M block)Observed:
Leg N: four slow-image streaming POST /v1/chat/completions requests to snowflake-claude while probing GET /health/liveliness
./legs2.sh 27860 33721 before(this case is its Leg N block)Observed:
The Snowflake stand-in logged what the proxy sent it, image already inlined as base64, and dumped every request body from Legs C and N; the md5 set is what the byte-for-byte comparison below uses:
After (59e000d)
Leg A: four slow-image POST /v1/chat/completions requests to gemini-flash while probing GET /health/liveliness
./legs2.sh 40862 33721 after(this case is its Leg A block)Observed:
Leg B: sixty slow-image POST /v1/chat/completions requests to bedrock-claude, then a text-only gemini-flash request 1.5s later
./legs2.sh 40862 33721 after(this case is its Leg B block)Observed:
Leg C: sixty slow-image POST /v1/chat/completions requests to snowflake-claude, then a text-only gemini-flash request 1.5s later
./legs2.sh 40862 33721 after(this case is its Leg C block)Observed:
Leg D: four slow-image POST /v1/responses requests to gemini-flash while probing GET /health/liveliness
./legs2.sh 40862 33721 after(this case is its Leg D block)Observed:
Leg E: four slow-image POST /v1/messages requests to gemini-flash while probing GET /health/liveliness
./legs2.sh 40862 33721 after(this case is its Leg E block)Observed:
Leg F: one POST /v1/chat/completions to gemini-flash carrying 25 distinct slow images (2s each) while probing GET /health/liveliness
./legs2.sh 40862 33721 after(this case is its Leg F block)Observed:
Leg G: four slow-image streaming POST /v1/chat/completions requests to gemini-flash while probing GET /health/liveliness
./legs2.sh 40862 33721 after(this case is its Leg G block)Observed:
Leg H: four slow-image POST /v1/chat/completions requests to vertex-gemini (http:// image) while probing GET /health/liveliness
./legs2.sh 40862 33721 after(this case is its Leg H block)Observed:
Leg I: four slow-image POST /v1/messages requests to bedrock-claude while probing GET /health/liveliness
./legs2.sh 40862 33721 after(this case is its Leg I block)Observed:
Leg J: one slow-image POST /v1/chat/completions request to bedrock-mantle
./legs2.sh 40862 33721 after(this case is its Leg J block)Observed:
Leg K: one multipart POST /v1/images/edits to openai-image-edit (openai/gpt-image-2) with a 64x64 PNG upload
./legs2.sh 40862 33721 after(this case is its Leg K block)Observed:
Leg L: four slow-image streaming POST /v1/chat/completions requests to bedrock-claude while probing GET /health/liveliness
./legs2.sh 40862 33721 after(this case is its Leg L block)Observed:
Leg M: two slow-image streaming POST /v1/chat/completions requests to bedrock-mantle while probing GET /health/liveliness
./legs2.sh 40862 33721 after(this case is its Leg M block)Observed:
Leg N: four slow-image streaming POST /v1/chat/completions requests to snowflake-claude while probing GET /health/liveliness
./legs2.sh 40862 33721 after(this case is its Leg N block)Observed:
The Snowflake stand-in logged what the proxy sent it, image already inlined as base64, and dumped every request body from Legs C and N; the md5 set is what the byte-for-byte comparison below uses:
Observations from the run:
4aa896f8c3ad70b4c208a76a21b16d1a) and the four streaming Leg N bodies to another (3fa89044cf314831a5112345c9659ca0), and both md5s are identical Before and After, so the bytes Snowflake receives are unchangedhttp://image on Vertex AI went through the sync fetcher inside the async body builder and stalled the loop for 16.1 seconds; After: the walker inlines it and the probes stay at milliseconds/v1/messagesroute never downloads anything on either side; it passes url sources to Bedrock, which rejects them in under a second. This PR does not touch that routeasync_transform_image_edit_requestdefault every image-edit provider now runs through, live against OpenAI, with the same 226 usage tokens on both sidesChild process [13663] diedin the proxy log, a memorystatus kill storm in the system log at the same second, no Python crash report). The After leg was re-run in full once the box recovered, on the same proxy process with its replacement worker, and that run is the one aboveDependents check at this tip (
lprr_delta3.sh, same two proxies): a blocked private address and a host that does not resolve both fail on the first attempt with the same fixed message instead of "after 3 attempts", with the same 400; Vertex AI still handsgs://URIs and mime-hinted https URLs to Google unchanged (Google's robots.txt rejection is identical on both sides), and only downloads the extensionless https andhttp://cases itself. Empty or cut-off answers on the 20-token probes are Gemini 3.8 flash spending the budget on reasoning, not a proxy difference: the same extensionless request withmax_tokens: 200answers "Puppy" before and "Dog" afterlprr_delta3.sh and both logs
Before (29ac88e):
After (59e000d):
CI: the CircleCI pipelines at 5c8016e (89161) and 3920cf4 (89180) passed in full (43 of 43 jobs at 3920cf4); the two reds seen at earlier tips were staging breakages folded in by the staging merge: the integrations GitHub Actions job (LIT-7021, #39848) and proxy_store_model_in_db_tests (LIT-6949, #39842). The pipeline at 59e000d (89185) passed in full as well (43 of 43 jobs)
Type
🐛 Bug Fix
Caveats (if any)
Medium
SnowflakeCortexClaudeConfigthrough the async transformLow
http://images, every remote image on Vertex AI Anthropic (force_base64), Ollama images and HF tokenizer fetches still download on the executor thread; those paths never blocked the loop and moving them means restructuring the Anthropic handler and the Ollama prompt factory, tracked in LIT-7028/v1/images/editsroute hands the transform uploaded bytes, so the on-loop download was reachable only from Python SDK callers passing an image URL, and there is no Black Forest Labs key to run a live edit against. Leg K proves the sharedasync_transform_image_edit_requestdefault that every image-edit provider now runs through, live against OpenAItransform_requeststill runs on the loop insideasync_transform_request; only the downloads, the SSRF DNS lookup, signing and pre-call logging leave it, and a thread hop for the string work would cost more than it savesasync_transform_image_edit_requestdefault calls the synctransform_image_edit_requeston the loop with no thread hop; only the Black Forest Labs override downloads off it, and Leg K is a no-regression check for OpenAI edits, not proof of an off-loop transformasync_transform_requestoverride is only used by the OpenAI SDK handler and is deliberately not switched on here/v1/messagesroute passes url image sources straight to Bedrock, which rejects them with a 400, before and after this PRgenerativelanguage.googleapis.com/v1beta/files/...) pass through unfetched, as before; other AI Studiofile_idURLs that fail to download now return 400 naming the URL and status instead of passing through to Googledocumentblock whose URL ends in.pdfis sent asapplication/pdfwhatever the host's content type, as the deleted converter did; url-sourcedimageblocks, which no path converted before, are now inlined tooFinal Attestation
The tests check the right things, including the edge cases, and regressions in the respective real-world customer use-cases are not possible after this PR
59e000d passes /live-pr-risk