Repository navigation
fix(workspace): send the completion callback from Docker and Apptainer exit - #6594
Conversation
…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.
Coverage Report •
|
||||||||||||||||||||||||||||||
REST API breakage checks (OpenAPI) — ✅ PASSEDResult: ✅ PASSED |
all-hands-bot
left a comment
There was a problem hiding this comment.
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 wereself.cleanup()only, so the new tests'post.assert_called_once()fails onmain— 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 everyRemoteWorkspacesubclass 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 existingmock_docker_workspace/mock_apptainer_workspacefixtures 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_URLthe callback is a no-op and exit behavior is unchanged.
No material findings.
✅ APPROVED
HUMAN:
just fixing a bug
AGENT:
Why
RemoteWorkspace.__exit__sends the completion callback configured throughAUTOMATION_CALLBACK_URL, and its docstring asks subclasses that override__exit__to callsuper().__exit__(...).DockerWorkspace.__exit__andApptainerWorkspace.__exit__only callself.cleanup(), so an automation run in either workspace never reports completion, whileAPIRemoteWorkspaceandAgentSandboxWorkspacedo.Summary
__exit__methods, callsuper().__exit__(...)first and runself.cleanup()in afinally, the same shape asAgentSandboxWorkspace.__exit__. The container is still always cleaned up, even if the callback raises.xfailmarkers, using the existingmock_docker_workspace/mock_apptainer_workspacefixtures.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
Both
test_exit_sends_completion_callbacktests fail onmain(no POST) and pass here; the two files pass (32). WithoutAUTOMATION_CALLBACK_URLset the callback is a no-op, so exiting behaves as before.Type
🐳 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
eclipse-temurin:17-jdkpython-node-runtimepython-node-runtimepython-node-runtimegolang: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:f754142-pythonRun
All tags pushed for this build
About Multi-Architecture Support
f754142-python) is a multi-arch manifest supporting both amd64 and arm64f754142-python-amd64) are also available if needed