Skip to content

fix(workspace): send the completion callback from Docker and Apptainer exit - #6594

Merged
VascoSch92 merged 2 commits into
mainfrom
vasco/workspace-exit-callback
Nov 7, 2026
Merged

VascoSch92 merged 2 commits into
mainfrom
vasco/workspace-exit-callback

Conversation

@VascoSch92

@VascoSch92 VascoSch92 commented Nov 7, 2026 •

Copy link
Copy Markdown
Member

HUMAN:

just fixing a bug


AGENT:

Why

RemoteWorkspace.__exit__ sends the completion callback configured through AUTOMATION_CALLBACK_URL, and its docstring asks subclasses that override __exit__ to call super().__exit__(...). DockerWorkspace.__exit__ and ApptainerWorkspace.__exit__ only call self.cleanup(), so an automation run in either workspace never reports completion, while APIRemoteWorkspace and AgentSandboxWorkspace do.

Summary

Issue Number

Part of #6348 (items: "DockerWorkspace.exit skips RemoteWorkspace.exit, so the AUTOMATION_CALLBACK_URL completion callback is never sent" and the same for ApptainerWorkspace).

How to Test

uv run pytest tests/workspace/test_docker_workspace.py tests/workspace/test_apptainer_workspace.py

Both test_exit_sends_completion_callback tests fail on main (no POST) and pass here; the two files pass (32). Without AUTOMATION_CALLBACK_URL set the callback is a no-op, so exiting behaves as before.

Type

  • Bug fix
  • Feature
  • Refactor
  • Breaking change
  • Docs / chore

🐳 Agent Server images for this PR — GHCR package, pull/run commands, and all pushed tags (click to expand)

• GHCR package: https://github.com/OpenHands/agent-sdk/pkgs/container/agent-server

Variants & Base Images

Variant Architectures Base Image Docs / Tags
java amd64, arm64 eclipse-temurin:17-jdk Link
python-slim amd64, arm64 python-node-runtime Link
python-minimal amd64, arm64 python-node-runtime Link
python amd64, arm64 python-node-runtime Link
golang amd64, arm64 golang:1.21-bookworm Link

Pull (multi-arch manifest)

# Each variant is a multi-arch manifest supporting both amd64 and arm64
docker pull ghcr.io/openhands/agent-server:f754142-python

Run

docker run -it --rm \
  -p 8000:8000 \
  --name agent-server-f754142-python \
  ghcr.io/openhands/agent-server:f754142-python

All tags pushed for this build

ghcr.io/openhands/agent-server:f754142-golang-amd64
ghcr.io/openhands/agent-server:f7541425cdb2c58ab9454af30ff1da655fab95cc-golang-amd64
ghcr.io/openhands/agent-server:vasco-workspace-exit-callback-golang-amd64
ghcr.io/openhands/agent-server:f754142-golang_tag_1.21-bookworm-amd64
ghcr.io/openhands/agent-server:f754142-golang-arm64
ghcr.io/openhands/agent-server:f7541425cdb2c58ab9454af30ff1da655fab95cc-golang-arm64
ghcr.io/openhands/agent-server:vasco-workspace-exit-callback-golang-arm64
ghcr.io/openhands/agent-server:f754142-golang_tag_1.21-bookworm-arm64
ghcr.io/openhands/agent-server:f754142-java-amd64
ghcr.io/openhands/agent-server:f7541425cdb2c58ab9454af30ff1da655fab95cc-java-amd64
ghcr.io/openhands/agent-server:vasco-workspace-exit-callback-java-amd64
ghcr.io/openhands/agent-server:f754142-eclipse-temurin_tag_17-jdk-amd64
ghcr.io/openhands/agent-server:f754142-java-arm64
ghcr.io/openhands/agent-server:f7541425cdb2c58ab9454af30ff1da655fab95cc-java-arm64
ghcr.io/openhands/agent-server:vasco-workspace-exit-callback-java-arm64
ghcr.io/openhands/agent-server:f754142-eclipse-temurin_tag_17-jdk-arm64
ghcr.io/openhands/agent-server:f754142-python-amd64
ghcr.io/openhands/agent-server:f7541425cdb2c58ab9454af30ff1da655fab95cc-python-amd64
ghcr.io/openhands/agent-server:vasco-workspace-exit-callback-python-amd64
ghcr.io/openhands/agent-server:f754142-python-node-runtime-amd64
ghcr.io/openhands/agent-server:f754142-python-arm64
ghcr.io/openhands/agent-server:f7541425cdb2c58ab9454af30ff1da655fab95cc-python-arm64
ghcr.io/openhands/agent-server:vasco-workspace-exit-callback-python-arm64
ghcr.io/openhands/agent-server:f754142-python-node-runtime-arm64
ghcr.io/openhands/agent-server:f754142-python-minimal-amd64
ghcr.io/openhands/agent-server:f7541425cdb2c58ab9454af30ff1da655fab95cc-python-minimal-amd64
ghcr.io/openhands/agent-server:vasco-workspace-exit-callback-python-minimal-amd64
ghcr.io/openhands/agent-server:f754142-python-node-runtime-minimal-amd64
ghcr.io/openhands/agent-server:f754142-python-minimal-arm64
ghcr.io/openhands/agent-server:f7541425cdb2c58ab9454af30ff1da655fab95cc-python-minimal-arm64
ghcr.io/openhands/agent-server:vasco-workspace-exit-callback-python-minimal-arm64
ghcr.io/openhands/agent-server:f754142-python-node-runtime-minimal-arm64
ghcr.io/openhands/agent-server:f754142-python-slim-amd64
ghcr.io/openhands/agent-server:f7541425cdb2c58ab9454af30ff1da655fab95cc-python-slim-amd64
ghcr.io/openhands/agent-server:vasco-workspace-exit-callback-python-slim-amd64
ghcr.io/openhands/agent-server:f754142-python-node-runtime-slim-amd64
ghcr.io/openhands/agent-server:f754142-python-slim-arm64
ghcr.io/openhands/agent-server:f7541425cdb2c58ab9454af30ff1da655fab95cc-python-slim-arm64
ghcr.io/openhands/agent-server:vasco-workspace-exit-callback-python-slim-arm64
ghcr.io/openhands/agent-server:f754142-python-node-runtime-slim-arm64
ghcr.io/openhands/agent-server:f754142-golang
ghcr.io/openhands/agent-server:f7541425cdb2c58ab9454af30ff1da655fab95cc-golang
ghcr.io/openhands/agent-server:vasco-workspace-exit-callback-golang
ghcr.io/openhands/agent-server:f754142-golang_tag_1.21-bookworm
ghcr.io/openhands/agent-server:f754142-java
ghcr.io/openhands/agent-server:f7541425cdb2c58ab9454af30ff1da655fab95cc-java
ghcr.io/openhands/agent-server:vasco-workspace-exit-callback-java
ghcr.io/openhands/agent-server:f754142-eclipse-temurin_tag_17-jdk
ghcr.io/openhands/agent-server:f754142-python-minimal
ghcr.io/openhands/agent-server:f7541425cdb2c58ab9454af30ff1da655fab95cc-python-minimal
ghcr.io/openhands/agent-server:vasco-workspace-exit-callback-python-minimal
ghcr.io/openhands/agent-server:f754142-python-node-runtime-minimal
ghcr.io/openhands/agent-server:f754142-python-slim
ghcr.io/openhands/agent-server:f7541425cdb2c58ab9454af30ff1da655fab95cc-python-slim
ghcr.io/openhands/agent-server:vasco-workspace-exit-callback-python-slim
ghcr.io/openhands/agent-server:f754142-python-node-runtime-slim
ghcr.io/openhands/agent-server:f754142-python
ghcr.io/openhands/agent-server:f7541425cdb2c58ab9454af30ff1da655fab95cc-python
ghcr.io/openhands/agent-server:vasco-workspace-exit-callback-python
ghcr.io/openhands/agent-server:f754142-python-node-runtime

About Multi-Architecture Support

  • Each variant tag (e.g., f754142-python) is a multi-arch manifest supporting both amd64 and arm64
  • Docker automatically pulls the correct architecture for your platform
  • Individual architecture tags (e.g., f754142-python-amd64) are also available if needed

…r exit

DockerWorkspace and ApptainerWorkspace override __exit__ with only
self.cleanup(), so RemoteWorkspace.__exit__ never ran and the
AUTOMATION_CALLBACK_URL completion callback was never sent. Call super()
first and clean up in a finally, as AgentSandboxWorkspace already does.
@github-actions

github-actions Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

Coverage

Coverage Report •
FileStmtsMissCoverMissing
openhands-workspace/openhands/workspace/apptainer
   workspace.py1816664%162, 171, 174–175, 182, 195, 227–228, 230, 233–235, 237–239, 241, 244, 250–252, 256–257, 265, 270–272, 330–331, 335–345, 347–350, 354–355, 357–363, 366, 368, 373–374, 378, 399, 408–415
openhands-workspace/openhands/workspace/docker
   workspace.py1984378%30–32, 50, 148, 174, 198, 202, 209, 221–222, 234, 261, 298, 307, 314–315, 319–320, 324, 327–328, 330–336, 339–340, 349–351, 355–357, 361, 374–375, 398, 418, 435
TOTAL535712659450% 

@github-actions

github-actions Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

REST API breakage checks (OpenAPI) — ✅ PASSED

Result: ✅ PASSED

Action log

@VascoSch92
VascoSch92 marked this pull request as ready for review November 7, 2026 16:24
@VascoSch92
VascoSch92 requested review from all-hands-bot and removed request for all-hands-bot November 7, 2026 21:52

@all-hands-bot all-hands-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This review was posted by an AI agent (OpenHands).

Scope: Workspace lifecycle code owned by this repository. The linked issue #6348 (bug, ready-for-dev) pins both __exit__ gaps as separate items, so the change has the direction it needs.

Assessment: The fix is minimal and correct. On main, DockerWorkspace.__exit__ and ApptainerWorkspace.__exit__ only called self.cleanup(), dropping the completion callback that RemoteWorkspace.__exit__ sends via _send_completion_callback(). The fix calls super().__exit__(...) first — which sends the callback — and runs self.cleanup() in finally, matching the established AgentSandboxWorkspace shape. Cleanup remains guaranteed on every exit path: _send_completion_callback already swallows its own POST failures (except Exception → warning log), so an unreachable callback URL still cannot orphan the container.

Verification on head f754142:

  • Confirmed base behavior at 20ddae0: both __exit__ methods were self.cleanup() only, so the new tests' post.assert_called_once() fails on main — the regression tests genuinely pin the bug rather than mirroring the implementation.
  • Read RemoteWorkspace.__exit__ (openhands-sdk/openhands/sdk/workspace/remote/base.py): callback fires before cleanup, and every RemoteWorkspace subclass now honors the documented subclass contract (APIRemoteWorkspace, AgentSandboxWorkspace, OpenHandsCloudWorkspace, plus the two fixed here). __del__ intentionally stays callback-free, consistent with the other workspace classes.
  • uv run pytest tests/workspace/test_docker_workspace.py tests/workspace/test_apptainer_workspace.py: 32 passed. Tests reuse the existing mock_docker_workspace / mock_apptainer_workspace fixtures and mock only the HTTP boundary.
  • CI on this exact head is green (49 checks passed; the single non-passing entry is the expected macOS matrix skip). No side effects outside the reported bug: without AUTOMATION_CALLBACK_URL the callback is a no-op and exit behavior is unchanged.

No material findings.

✅ APPROVED

@VascoSch92
VascoSch92 merged commit c989a85 into main Nov 7, 2026
53 of 54 checks passed
@VascoSch92
VascoSch92 deleted the vasco/workspace-exit-callback branch November 7, 2026 22:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants