Skip to content

Commit aabf407

Browse files
fix(ci): use SDK_SHA for docker image tags in examples
The built-in GITHUB_SHA resolves to the merge-commit SHA on pull_request events, which does not match the agent-server image tags built from the PR head commit. The agent-server build workflow already uses SDK_SHA for this reason. Switch run-examples.yml to export SDK_SHA (matching the server workflow) and update all remote-agent-server examples to prefer SDK_SHA, falling back to GITHUB_SHA for backward compatibility. Co-authored-by: openhands <openhands@all-hands.dev>
1 parent 9e90afa commit aabf407

7 files changed

Lines changed: 27 additions & 27 deletions

.github/workflows/run-examples.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ jobs:
7676
PR_NUMBER: ${{ github.event.pull_request.number }}
7777
REPO_OWNER: ${{ github.repository_owner }}
7878
REPO_NAME: ${{ github.event.repository.name }}
79-
GITHUB_SHA: ${{ github.event.pull_request.head.sha }}
79+
SDK_SHA: ${{ github.event.pull_request.head.sha || github.sha }}
8080
OPENHANDS_CLOUD_API_KEY: ${{ secrets.ALLHANDS_BOT_OPENHANDS_SAAS_API_KEY }}
8181
# ACP agents (Claude Code, Codex) route through LiteLLM proxy
8282
ANTHROPIC_BASE_URL: https://llm-proxy.app.all-hands.dev

examples/02_remote_agent_server/02_convo_with_docker_sandboxed_server.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@ def get_server_image():
4040
"""Get the server image tag, using PR-specific image in CI."""
4141
platform_str = detect_platform()
4242
arch = "arm64" if "arm64" in platform_str else "amd64"
43-
# If GITHUB_SHA is set (e.g. running in CI of a PR), use that to ensure consistency
44-
# Otherwise, use the latest image from main
45-
github_sha = os.getenv("GITHUB_SHA")
46-
if github_sha:
47-
return f"ghcr.io/openhands/agent-server:{github_sha[:7]}-python-{arch}"
43+
# SDK_SHA is the canonical commit SHA set by CI workflows (avoids the
44+
# built-in GITHUB_SHA which resolves to the merge-commit on PRs).
45+
sha = os.getenv("SDK_SHA") or os.getenv("GITHUB_SHA")
46+
if sha:
47+
return f"ghcr.io/openhands/agent-server:{sha[:7]}-python-{arch}"
4848
return "ghcr.io/openhands/agent-server:latest-python"
4949

5050

examples/02_remote_agent_server/03_browser_use_with_docker_sandboxed_server.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@ def get_server_image():
3535
"""Get the server image tag, using PR-specific image in CI."""
3636
platform_str = detect_platform()
3737
arch = "arm64" if "arm64" in platform_str else "amd64"
38-
# If GITHUB_SHA is set (e.g. running in CI of a PR), use that to ensure consistency
39-
# Otherwise, use the latest image from main
40-
github_sha = os.getenv("GITHUB_SHA")
41-
if github_sha:
42-
return f"ghcr.io/openhands/agent-server:{github_sha[:7]}-python-{arch}"
38+
# SDK_SHA is the canonical commit SHA set by CI workflows (avoids the
39+
# built-in GITHUB_SHA which resolves to the merge-commit on PRs).
40+
sha = os.getenv("SDK_SHA") or os.getenv("GITHUB_SHA")
41+
if sha:
42+
return f"ghcr.io/openhands/agent-server:{sha[:7]}-python-{arch}"
4343
return "ghcr.io/openhands/agent-server:latest-python"
4444

4545

examples/02_remote_agent_server/04_convo_with_api_sandboxed_server.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@
4545
exit(1)
4646

4747

48-
# If GITHUB_SHA is set (e.g. running in CI of a PR), use that to ensure consistency
49-
# Otherwise, use the latest image from main
50-
server_image_sha = os.getenv("GITHUB_SHA") or "main"
48+
# SDK_SHA is the canonical commit SHA set by CI workflows (avoids the
49+
# built-in GITHUB_SHA which resolves to the merge-commit on PRs).
50+
server_image_sha = os.getenv("SDK_SHA") or os.getenv("GITHUB_SHA") or "main"
5151
server_image = f"ghcr.io/openhands/agent-server:{server_image_sha[:7]}-python-amd64"
5252
logger.info(f"Using server image: {server_image}")
5353

examples/02_remote_agent_server/05_vscode_with_docker_sandboxed_server.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ def get_server_image():
3737
"""Get the server image tag, using PR-specific image in CI."""
3838
platform_str = detect_platform()
3939
arch = "arm64" if "arm64" in platform_str else "amd64"
40-
# If GITHUB_SHA is set (e.g. running in CI of a PR), use that to ensure consistency
41-
# Otherwise, use the latest image from main
42-
github_sha = os.getenv("GITHUB_SHA")
43-
if github_sha:
44-
return f"ghcr.io/openhands/agent-server:{github_sha[:7]}-python-{arch}"
40+
# SDK_SHA is the canonical commit SHA set by CI workflows (avoids the
41+
# built-in GITHUB_SHA which resolves to the merge-commit on PRs).
42+
sha = os.getenv("SDK_SHA") or os.getenv("GITHUB_SHA")
43+
if sha:
44+
return f"ghcr.io/openhands/agent-server:{sha[:7]}-python-{arch}"
4545
return "ghcr.io/openhands/agent-server:latest-python"
4646

4747

examples/02_remote_agent_server/08_convo_with_apptainer_sandboxed_server.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@ def get_server_image():
4040
"""Get the server image tag, using PR-specific image in CI."""
4141
platform_str = detect_platform()
4242
arch = "arm64" if "arm64" in platform_str else "amd64"
43-
# If GITHUB_SHA is set (e.g. running in CI of a PR), use that to ensure consistency
44-
# Otherwise, use the latest image from main
45-
github_sha = os.getenv("GITHUB_SHA")
46-
if github_sha:
47-
return f"ghcr.io/openhands/agent-server:{github_sha[:7]}-python-{arch}"
43+
# SDK_SHA is the canonical commit SHA set by CI workflows (avoids the
44+
# built-in GITHUB_SHA which resolves to the merge-commit on PRs).
45+
sha = os.getenv("SDK_SHA") or os.getenv("GITHUB_SHA")
46+
if sha:
47+
return f"ghcr.io/openhands/agent-server:{sha[:7]}-python-{arch}"
4848
return "ghcr.io/openhands/agent-server:latest-python"
4949

5050

examples/02_remote_agent_server/09_acp_agent_with_remote_runtime.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@
4141
runtime_api_key = os.getenv("RUNTIME_API_KEY")
4242
assert runtime_api_key, "RUNTIME_API_KEY required"
4343

44-
# If GITHUB_SHA is set (e.g. running in CI of a PR), use that to ensure consistency
45-
# Otherwise, use the latest image from main
46-
server_image_sha = os.getenv("GITHUB_SHA") or "main"
44+
# SDK_SHA is the canonical commit SHA set by CI workflows (avoids the
45+
# built-in GITHUB_SHA which resolves to the merge-commit on PRs).
46+
server_image_sha = os.getenv("SDK_SHA") or os.getenv("GITHUB_SHA") or "main"
4747
server_image = f"ghcr.io/openhands/agent-server:{server_image_sha[:7]}-python-amd64"
4848
logger.info(f"Using server image: {server_image}")
4949

0 commit comments

Comments
 (0)