Skip to content

perf(proxy): compile the baked proxy's bytecode as the image is built - #587

Merged
earakely-scale merged 1 commit into
mainfrom
edgararakelyan/proxy-bytecode
Nov 10, 2026
Merged

earakely-scale merged 1 commit into
mainfrom
edgararakelyan/proxy-bytecode

Conversation

@earakely-scale

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

Copy link
Copy Markdown
Collaborator

Summary

A task image that bakes in AgentEnv's proxy (agents/agents/proxy/bake.sh, #578) installed its venv without compiled bytecode. So every fresh task container compiled the proxy's whole dependency tree on its first import, and 128 episodes starting at once spent their CPU compiling the same packages. bake.sh now installs the venv with uv pip install --compile-bytecode, once, as the image is built.

Images baked before this keep working, since the install's marker check is unchanged; they just start slower.

Measured

128 concurrent episodes, as 4 processes × 32, over 16 task images, on one c6i.12xlarge with agentenv-framework 0.9.1491. Each task: deploy_sandbox → run_docker_container from an image artifact with the proxy baked in → install_agent → a turn, ended at once → a container grader. Means over the four processes; one episode in 256 failed, on the local document store's write lock.

Time to first turn install_agent Turn end to reward Episode, all told 128 episodes, wall clock
Baked, as released 22.2 s 11.2 s 18.6 s 45.5 s 54 s
Baked, bytecode compiled 17.3 s 4.8 s 7.7 s 29.0 s 37 s

The time from turn end to reward dropped too, because the grader and the turn bookkeeping no longer compete with 128 containers compiling.

Tests

On Linux (Ubuntu 24.04, Python 3.12, Docker 29.9):

  • tst/integration/agent/proxy_local_container_test.py passes. Its baked case builds a task image through bake.sh and plays an episode through the baked proxy.
  • tst/integration/agent/proxy_container_install_test.py passes.
  • tst/unit/agents/proxy passes (13 tests).
  • ruff check is clean.

🤖 Generated with Claude Code

RetriggerView in GreptileConfidence Score: 5/5

This PR appears safe to merge.

Summary

bake.sh now compiles dependency bytecode during image builds instead of leaving that work to each fresh container.

  • Baked proxy images compile dependencies before task containers start.

Reviews (1) · Last reviewed commit: "perf(proxy): compile the baked proxy's b..." · Reviewed by Greptile

Every fresh task container compiled the proxy's dependencies on first
import, so 128 episodes starting at once spent their CPU compiling the same
packages. bake.sh now installs the venv with --compile-bytecode.

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 10, 2026 02:22
@earakely-scale
earakely-scale merged commit 32087c8 into main Nov 10, 2026
79 of 88 checks passed
@earakely-scale
earakely-scale deleted the edgararakelyan/proxy-bytecode branch November 10, 2026 03:30
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