Skip to content

feat(proxy): start a proxy a task image bakes in, and fetch less per install - #578

Merged
earakely-scale merged 6 commits into
mainfrom
edgararakelyan/proxy-in-image
Nov 10, 2026
Merged

earakely-scale merged 6 commits into
mainfrom
edgararakelyan/proxy-in-image

Conversation

@earakely-scale

@earakely-scale earakely-scale commented Nov 9, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

When an episode plays an agent installed into a task container (install_agent with container_name), it installs AgentEnv's proxy there from scratch, every episode:

  • the host fetches uv from GitHub;
  • the container downloads a managed Python and the proxy's requirements (about 50 MB, by the bench below);
  • a throwaway docker run of the proxy image reads its card;
  • the agent card is polled every 5 s.

At 128 concurrent episodes, that was most of an episode's start.

  • A proxy baked into the task image. agents/agents/proxy/bake.sh installs the proxy into an image as it's built, into /opt/agentenv-proxy. It also writes a marker naming the requirements.txt the proxy was built from. A task image ends its Dockerfile with three lines (in the README). install.sh's container install checks the marker: a baked proxy that holds this proxy's requirements is only started, with one file copied in. Any other container gets the full install, as before. bake.sh is plain sh, for images with no bash, and uv picks the image's own glibc or musl Python as it builds.
  • uv kept on the host. The full install caches the uv archive per version and CPU, checked against its checksum each time, so it isn't fetched from GitHub per episode.
  • The card read once. install_agent reads an agent image's install/v1 extension once per process, keyed by the image's name and digest, which name its content.
  • Faster card polling. It now polls for the agent card every 0.5 s instead of 5 s.
  • Test cleanup. The bundle task image test from feat(run-docker-container): run a docker_image artifact without building #574 now removes the image it builds, since teardown keeps it for a next run.

Measured

128 concurrent episodes, as 4 processes × 32, of tasks whose agent is installed into a task container on the local sandbox (16 task images, each episode's first turn ended at once). Run on a c6i.12xlarge, after a warm-up round of one episode per task. Means over the 4 processes; no episode failed in any arm.

Time to first turn, mean (p95) run_docker_container install_agent 128 episodes, wall Downloaded
v0.9.1487: per-episode build FROM a prebuilt base, full proxy install 115 s (172 s) 54 s 57 s 210 s 9.1 GB
v0.9.1488 (image_artifact_id, #574), full proxy install 111 s (158 s) 4 s 92 s 236 s 6.8 GB
This PR: image_artifact_id + baked proxy, card read once, 0.5 s poll 23 s (28 s) 4 s 9 s 46 s 1 MB

Without the card cache and the faster poll, the baked arm was 28 s to first turn with 16 s of install.

The remaining 9 s of install is mostly the proxy's own start under that load: the card wait still averages about 4.5 s at a 0.5 s poll.

Tests

  • tst/unit/agents/proxy/test_proxy_agent.py:
    • install.sh's container install against a fake docker: a container whose image baked this proxy only gets a2a_server.py copied and the baked venv's Python started, with no curl; one with none baked, or with other requirements baked, goes to the full install.
    • bake.sh parses as sh.
    • The README's and bake.sh's uv image name the uv version install.sh brings.
  • tst/unit/task_step/install_agent_test.py: an image's install extension is read once, and read again for another digest.
  • tst/integration/agent/proxy_local_container_test.py (slow tier): an episode on the local sandbox whose agent is installed into a task container, from an image with the proxy baked in and from one without. Both play the turn through the proxy and pass the task's tests; only the second gets uv.
  • On Linux (Ubuntu 24.04, Python 3.12, Docker 29.9):
    • The new and changed tests pass.
    • make unit-test passes apart from two MCP CLI codegen tests that also fail on main on that box: 14,168 passed, 9 skipped.
    • ruff check is clean.

🤖 Generated with Claude Code

RetriggerView in GreptileConfidence Score: 5/5

The PR appears safe to merge; the previous test failure is fixed and no new issues were found.

Summary

This PR reduces proxy startup work:

  • Task images can start a ready-made proxy instead of installing it each episode.
  • Agent installs reuse image cards and find live cards sooner.
  • Integration tests clean up built images and wait for commands to start.

The latest change fixes the previous finding by copying versions.sh into the integration test’s temporary folder. No new issues were found.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Install proxy in task container] --> B{Baked requirements match?}
  B -->|Yes| C[Use baked Python environment]
  B -->|No| D[Reuse checked uv archive or download it]
  D --> E[Install Python and proxy requirements]
  C --> F[Copy current proxy server]
  E --> F
  F --> G[Start proxy and wait for its card]
Loading

Reviews (6) · Last reviewed commit: "test(proxy): copy versions.sh with the i..." · Reviewed by Greptile

…install

An episode installed AgentEnv's proxy into its task container from scratch:
uv fetched from GitHub on the host, a managed Python and the proxy's
requirements downloaded into the container, and a throwaway docker run of the
proxy image just to read its card. At 128 concurrent episodes that was most
of an episode's start.

- bake.sh installs the proxy into an image as it's built, with a marker
  naming the requirements it holds; install.sh's container install only
  starts a baked proxy that holds this proxy's requirements, else installs as
  before.
- The full install keeps uv on the host, checked against its checksum, so it
  isn't fetched from GitHub per episode.
- install_agent reads an agent image's install extension once per process,
  by the image's name and digest, and polls for the agent card every 0.5 s.
- The bundle task image test removes the image it builds.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@earakely-scale
earakely-scale requested a review from a team as a code owner November 9, 2026 22:20
earakely-scale and others added 4 commits November 9, 2026 14:35
Key the install extension cache by the image artifact's id and version: an
image loaded from a tarball has no digest, so two versions under one name
would have shared a card. Installs at once share one in-flight read, and a
failed read, or one made on another event loop, is made again. Test the full
install's host copy of uv: a good one is used, a corrupt or missing one is
fetched.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The full install checks uv against its published checksum; the bake recipe
took ghcr.io/astral-sh/uv:0.13.1 by tag. Pin it to the image index's digest,
which covers linux/amd64 and linux/arm64, and test that the README and
bake.sh name the same pinned reference for the uv version install.sh brings.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The Ctrl-C and SIGTERM cases signalled as soon as the nap step's line
printed, sometimes before its command had written nap.pid, so the check
for the stopped nap found no file. Wait for the pid first, as the
killed-outright case does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
uv's version, its checksums and its image digest, the Python version and
the bake root were spread over install.sh, bake.sh and the tests, and
bake.sh read the Python version out of install.sh's text. Both scripts now
source versions.sh, and the tests render the bake recipe from it and check
the README and bake.sh give that recipe. Drop a local import of a name the
module already imports.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
install.sh sources versions.sh beside it, and the container install test
copied only install.sh and a2a_server.py into its folder.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@earakely-scale
earakely-scale merged commit edcfb90 into main Nov 10, 2026
34 checks passed
@earakely-scale
earakely-scale deleted the edgararakelyan/proxy-in-image branch November 10, 2026 00:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant