fix(litellm): bind host proxy to 0.0.0.0 when the docker gateway is unbindable - #947
Open
manunicholasjacob wants to merge 1 commit into
Open
Conversation
Contributor
There was a problem hiding this comment.
Your trial has ended. Reactivate Greptile to resume code reviews.
…nbindable
On Docker Desktop's WSL2/Hyper-V backend the docker bridge gateway reported by
`docker network inspect bridge` (172.17.0.1) belongs to the Docker VM, not to
the distro benchflow runs in. _host_bind_address validates it with
socket.inet_aton, which only checks that the string parses as IPv4, then binds
it directly, so bind() fails with EADDRNOTAVAIL and every `--sandbox docker`
run aborts before the agent starts:
ERROR: [Errno 99] error while attempting to bind on address
('172.17.0.1', 41495): cannot assign requested address
RuntimeError: LiteLLM proxy failed to start
The existing fallback to 0.0.0.0 only triggers when the gateway is a hostname
(host.docker.internal, as on macOS), so this configuration never reaches it.
Probe whether the address can actually be bound rather than only that it
parses, and when it cannot, take the path already used for macOS: bind
0.0.0.0 and advertise host.docker.internal so the container can still reach
the proxy.
No behaviour change on native Linux, where the gateway is bindable and the
existing branch is taken.
Signed-off-by: Manu Nicholas Jacob <manunicholasjacob@gmail.com>
manunicholasjacob
force-pushed
the
fix/litellm-bind-docker-desktop
branch
from
August 6, 2026 02:55
3668a96 to
e1423f4
Compare
Contributor
There was a problem hiding this comment.
Your trial has ended. Reactivate Greptile to resume code reviews.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Every
bench eval run --sandbox dockerfails on Docker Desktop's WSL2/Hyper-V backend. The host LiteLLM proxy tries to bind the docker bridge gateway directly, but under Docker Desktop that address belongs to the Docker VM rather than to the distro benchflow runs in, so the bind fails and the run aborts before the agent starts.benchflow already handles this network shape correctly — it is the macOS path (bind
0.0.0.0, advertisehost.docker.internal). The bug is only in how the path is chosen: the code assumes any syntactically valid IPv4 gateway is bindable.Reproduction
Environment: Windows 11, Docker Desktop 4.85.0 (WSL2 backend), Ubuntu 26.04, Docker 29.6.2. The daemon is reachable from the distro and images build fine.
Actual result
Reproduces on every task, with
n_tool_calls=0— the agent never runs.Cause
In
src/benchflow/providers/litellm_runtime.py:_docker_host_address()shells out todocker network inspect bridgeand gets172.17.0.1. That is correct for the daemon, which under Docker Desktop lives in its own VM._host_bind_address()validates it withsocket.inet_aton(), which only checks that the string parses as IPv4, then returns it as the bind address.172.17.0.1is not configured on any interface inside the WSL distro, sobind()returnsEADDRNOTAVAIL.The existing fallback to
0.0.0.0only triggers when the gateway is a hostname (host.docker.internal, as on macOS), so this configuration never reaches it.Fix
Probe whether the address can actually be bound rather than only that it parses, and when it cannot, take the path already used for macOS.
_agent_endpoint_for_environmentis updated to match, so the container is advertisedhost.docker.internalrather than a gateway it also cannot reach.Behaviour after the fix, same machine:
The proxy then starts and the container reaches it, verified end to end by a task completing with
reward 1.0anderrors=0on the same setup that previously failed on every run.No behaviour change on native Linux, where the gateway is bindable and the existing branch is taken.
Tests
tests/test_litellm_hardening.py:test_host_bind_address_docker_unbindable_gateway_falls_back— new, covers the Docker Desktop case.test_agent_endpoint_docker_unbindable_gateway_advertises_host_name— new, covers the endpoint the container is told to call.test_host_bind_address_docker_uses_bridge_ip— existing, now pins_address_is_localexplicitly. Without this it would depend on whether the CI runner happens to havedocker0configured, which would make it pass on Linux CI and fail elsewhere. The original intent (a bindable gateway is used directly) is preserved.uv run --with pytest --with pytest-asyncio python -m pytest tests/test_litellm_hardening.py→ 53 passed.Note for anyone reproducing: without
pytest-asyncioinstalled, the async tests in this file surface asPytestUnknownMarkWarningand report as failures rather than being skipped.Two smaller things found alongside
Happy to open these separately if useful, not included here to keep the diff focused:
geminiagent'sdefault_modelisgemini-2.5-flash, which now returns404 ... This model is no longer available to new usersfor recently issued AI Studio API keys.bench eval run --helpdocuments--sandboxas acceptingdocker, daytona, agentcore, while the README also mentions Modal and Apple Container.