Repository navigation
fix(local): rewrite URLs on this machine for the local containers they're handed to - #104
Merged
Merged
Conversation
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…container-urls # Conflicts: # src/agent_env/task_step/context.py
…ts get peer URLs as they are Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Collaborator
Author
|
Chaos run on the local provider: macOS (Rancher Desktop) and Linux (native Docker 29, x86).
Mixed topology: a
* Nothing was left running on either machine. |
…cker bridge address Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
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.
What and why
A container on a
localsandbox can't reach this machine atlocalhost. Model endpoints, agent URLs and gateway URLs that agent-env handed into such containers were passed through unchanged. As a result:The rewrite
LocalSandboxProvider.get_external_urlnow rewrites only a loopback host (localhost,127.x,::1,0.0.0.0) tohost.docker.internal. Before, it replaced the substring anywhere in the URL.host_url_for(url, sandbox_type)rewrites a URL on this machine for a container on alocalsandbox. Every other provider gets the URL unchanged.URLs rewritten for the container that receives them
deploy_agentand the agent judge. The agent's owndefault_env_varsare left alone.env_varsandstep_params, and forinstall_agentin container mode.Linux
host.docker.internal, soSandbox.extra_hostscarrieshost.docker.internal:host-gatewayon a Linux local sandbox.run_docker_container, and to agents placed on an existing local sandbox. Before, those agents got it only when local grants were on.AGENTS.mdand.agentenv/config.example.tomlsay to bind it to the bridge address (for example172.17.0.1) and use that in its URL. That keeps it off the network; binding0.0.0.0works too but exposes it.Remote providers see no change.
How it was tested
make unit-test: 6583 passed, including tests for each rewritten URL and for URLs wherelocalhostis not the host.check_plugin_api.pyreports no break.enable_dockeragent on its sidecar network;172.17.0.1. Bound to127.0.0.1only, containers are refused.modal_vmgateway with one local agent and one Modal agent: URLs from beyond this machine pass through unchanged and are reached.🤖 Generated with Claude Code
The PR appears safe to merge; no outstanding issue was established.
What we checked:
require_gateway_urlrejects records without a gateway first. Gateway records havesandbox_type.Summary
Local containers now get host-reachable addresses for URLs that point back to this machine, while remote sandbox URLs stay unchanged. The change covers model, peer, gateway, and CLI URLs, and adds Linux host-name mapping support.
Diagram
%%{init: {'theme': 'neutral'}}%% flowchart LR A[URL on this machine] --> B{Recipient runs in a local container?} B -- Yes --> C{Loopback host?} C -- Yes --> D[Use host.docker.internal] C -- No --> E[Keep URL] B -- No --> EReviews (4) · Last reviewed commit: "refactor(local): drop an always-true che..." · Reviewed by Greptile