Repository navigation
feat: support pre-built base images for faster rebuilds - #2542
Conversation
Add two-phase build support for SWE-bench images:
Phase 1: Build pre-built base images (base-image-minimal stage)
- New script: benchmarks/swebench/build_base_images.py
- Tags as ghcr.io/openhands/eval-base:{custom_tag}
- SDK-independent, only rebuilds when upstream SWE-bench image changes
Phase 2: Build agent images using pre-built bases
- New --use-prebuilt-bases flag in build_images.py
- Passes prebuilt_base through build_utils → SDK BuildOptions
- SDK Dockerfile's SOURCE_MINIMAL_BASE ARG skips base-image-minimal
Expected impact: new SDK with same instances goes from ~5-6h to ~30-45min.
Depends on: OpenHands/software-agent-sdk#2542
Closes #538
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
82003c2 to
b067387
Compare
Python API breakage checks — ✅ PASSEDResult: ✅ PASSED |
REST API breakage checks (OpenAPI) — ✅ PASSEDResult: ✅ PASSED |
Coverage Report •
|
||||||||||||||||||||
all-hands-bot
left a comment
There was a problem hiding this comment.
🟡 Acceptable - Pragmatic solution to a real problem (5-6h → 30-45min builds). Core design is solid with good backward compatibility. A couple of clarifications needed before merge.
|
Addressed both review comments in 6e1b312:
|
all-hands-bot
left a comment
There was a problem hiding this comment.
🟢 Good taste - Pragmatic solution that cuts build time from 5-6h to 30-45min. The empty context optimization for base-only targets is exactly right—skip expensive work when it's not needed. Clean, backward compatible, well-commented. LGTM!
Add Dockerfile ARGs (SOURCE_MINIMAL_BASE, SOURCE_BASE) that allow final build targets to reference a pre-built base image instead of always building base-image-minimal from scratch. When the ARG is left at its default the behaviour is identical to before; when overridden with an image reference (e.g. ghcr.io/openhands/eval-base:tag) Docker pulls the cached base and skips the base-image-minimal stage entirely. Also adds: - `prebuilt_base` field to BuildOptions - Automatic --build-arg injection in build_with_telemetry() when prebuilt_base is set - base-image-minimal / base-image as valid build targets (for building and pushing base images independently) - Empty build context for base-only targets (skips uv build --sdist) This enables a two-phase build workflow where base images are built once and agent images are rebuilt in seconds on SDK changes. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Allows building and pushing just the builder stage independently, enabling three-phase builds where the builder output is shared across all images. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The Pydantic validator uses the Literal type, not VALID_TARGETS set. Without this, BuildOptions(target="builder") fails validation. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Raises ValueError when prebuilt_base is set with a target other than source-minimal or source. Updated field description to document this. Addresses review feedback. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
63b1336 to
e8ddc72
Compare
Co-authored-by: Debug Agent <debug@example.com>
Co-authored-by: Debug Agent <debug@example.com>
Summary
Add explicit Docker build targets that support phased benchmark image builds.
This PR adds support for building these stages directly from the SDK Dockerfile:
base-image-minimalbase-imagebuilderIt also keeps the base-only build path efficient by using an empty build context for targets that do not need the SDK source tree.
What This Enables
The benchmarks repo can use the SDK Dockerfile as the source of truth for the shared image components:
builderimage keyed by SDK SHAbase-image-minimalimages keyed by SWE-bench instance tagThis keeps the SDK side focused on exposing the reusable build primitives, while the benchmarks repo owns orchestration.
Changes
builder,base-image-minimal, andbase-imageas valid build targets inbuild.pyTargetTypeBackward Compatibility
Existing builds for the standard targets continue to work as before. This PR extends the target surface; it does not replace the normal build flow.
Dependency
Used by:
Validation
Agent Server images for this PR
• GHCR package: https://github.com/OpenHands/agent-sdk/pkgs/container/agent-server
Variants & Base Images
eclipse-temurin:17-jdknikolaik/python-nodejs:python3.13-nodejs22golang:1.21-bookwormPull (multi-arch manifest)
# Each variant is a multi-arch manifest supporting both amd64 and arm64 docker pull ghcr.io/openhands/agent-server:f3c8e24-pythonRun
All tags pushed for this build
About Multi-Architecture Support
f3c8e24-python) is a multi-arch manifest supporting both amd64 and arm64f3c8e24-python-amd64) are also available if needed