Skip to content

fix(agent-server): await conversation teardown in EventService.close() - #2734

Merged
neubig merged 1 commit into
mainfrom
vasco/fix-2603
Apr 9, 2026
Merged

neubig merged 1 commit into
mainfrom
vasco/fix-2603

Conversation

@VascoSch92

@VascoSch92 VascoSch92 commented Apr 7, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Await run_in_executor in EventService.close(): the conversation close was fire-and-forget, meaning callers (conversation deletion, server shutdown) could proceed before MCP clients and other resources were actually torn down. Now close() properly waits for conversation.close() to finish.
  • Clear self._conversation after close — prevents double-close and makes is_open() return False after teardown.
  • Add tests for close lifecycle — verify that close awaits teardown, clears the reference, and is idempotent.

Partial fix for #2603 (point 1 of the short-term fixes).

Test plan

  • TestEventServiceClose::test_close_awaits_conversation_close — proves close blocks until conversation teardown finishes
  • TestEventServiceClose::test_close_clears_conversation_reference — verifies _conversation is None after close
  • TestEventServiceClose::test_close_is_idempotent — calling close twice doesn't raise or double-close

Checklist

  • If the PR is changing/adding functionality, are there tests to reflect this?
  • If there is an example, have you run the example to make sure that it works?
  • If there are instructions on how to run the code, have you followed the instructions and made sure that it works?
  • If the feature is significant enough to require documentation, is there a PR open on the OpenHands/docs repository with the same branch name?
  • Is the github CI passing?

Agent Server images for this PR

• 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 amd64, arm64 nikolaik/python-nodejs:python3.13-nodejs22-slim 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:f36e022-python

Run

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

All tags pushed for this build

ghcr.io/openhands/agent-server:f36e022-golang-amd64
ghcr.io/openhands/agent-server:f36e022-golang_tag_1.21-bookworm-amd64
ghcr.io/openhands/agent-server:f36e022-golang-arm64
ghcr.io/openhands/agent-server:f36e022-golang_tag_1.21-bookworm-arm64
ghcr.io/openhands/agent-server:f36e022-java-amd64
ghcr.io/openhands/agent-server:f36e022-eclipse-temurin_tag_17-jdk-amd64
ghcr.io/openhands/agent-server:f36e022-java-arm64
ghcr.io/openhands/agent-server:f36e022-eclipse-temurin_tag_17-jdk-arm64
ghcr.io/openhands/agent-server:f36e022-python-amd64
ghcr.io/openhands/agent-server:f36e022-nikolaik_s_python-nodejs_tag_python3.13-nodejs22-slim-amd64
ghcr.io/openhands/agent-server:f36e022-python-arm64
ghcr.io/openhands/agent-server:f36e022-nikolaik_s_python-nodejs_tag_python3.13-nodejs22-slim-arm64
ghcr.io/openhands/agent-server:f36e022-golang
ghcr.io/openhands/agent-server:f36e022-java
ghcr.io/openhands/agent-server:f36e022-python

About Multi-Architecture Support

  • Each variant tag (e.g., f36e022-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., f36e022-python-amd64) are also available if needed

@github-actions

github-actions Bot commented Apr 7, 2026

Copy link
Copy Markdown
Contributor

Python API breakage checks — ✅ PASSED

Result: ✅ PASSED

Action log

@github-actions

github-actions Bot commented Apr 7, 2026

Copy link
Copy Markdown
Contributor

REST API breakage checks (OpenAPI) — ✅ PASSED

Result: ✅ PASSED

Action log

@VascoSch92
VascoSch92 requested a review from all-hands-bot April 7, 2026 08:34
@github-actions

github-actions Bot commented Apr 7, 2026

Copy link
Copy Markdown
Contributor

Coverage

Coverage Report •
FileStmtsMissCoverMissing
openhands-agent-server/openhands/agent_server
   event_service.py3388873%55–56, 74–76, 85–89, 92–95, 115, 219, 236, 277, 287, 311–312, 316, 324, 327, 367–368, 384, 386, 390–392, 396, 405–406, 408, 412, 418, 420, 450–455, 600, 602–603, 607, 621–623, 625, 629–632, 636–639, 647–650, 670–671, 673–680, 682–683, 692–693, 695–696, 703–704, 706–707, 711, 717, 726–727
TOTAL222361003654% 

@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.

🟢 Good taste - Simple, correct fix for a real problem.

Key insight: Fire-and-forget executor calls are silent bugs. This fix properly awaits teardown and ensures clean state. The tests verify real behavior (not just mocks), and the idempotency check is solid defensive programming.

✅ LGTM - Worth merging.

@VascoSch92
VascoSch92 requested a review from neubig April 7, 2026 08:37
@neubig
neubig merged commit c78c3c2 into main Apr 9, 2026
34 of 35 checks passed
@neubig
neubig deleted the vasco/fix-2603 branch April 9, 2026 19:55
StressTestor pushed a commit to StressTestor/software-agent-sdk that referenced this pull request Jun 1, 2026
pengzhang-create pushed a commit to Pyromind-Dynamics/software-agent-sdk that referenced this pull request Aug 13, 2026
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.

3 participants