Repository navigation
refactor(agent-server): typed "already running" errors instead of string matching - #7007
Conversation
EventService.run and the goal loop raise ConversationAlreadyRunning and GoalAlreadyRunning (ValueError subclasses with the same messages), and callers catch the type instead of comparing str(e). The goal loop's sender becomes the GOAL_LOOP_SENDER constant. Co-authored-by: openhands <openhands@all-hands.dev> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013ArwwJH94xGSYwfoyccT4E
REST API breakage checks (OpenAPI) — ✅ PASSEDResult: ✅ PASSED |
Agent-server conversation start benchmarkBase
How this is measuredEach create is a Canvas-shaped
A timing is flagged when the 95% CIs do not overlap and the medians differ by at least 50 ms, or when a row with at least 8 samples per side moves by at least 150 ms and 25%. A create stalled the server when its slowest |
Coverage Report •
|
|||||||||||||||||||||||||||||||||||||||||||||
⏳ Review waiting on checksThe current head
No action is needed. The scheduled scan retries once every check on the head reports a conclusion. This is an automated check - no AI was used to generate this comment. |
all-hands-bot
left a comment
There was a problem hiding this comment.
This review was posted by an AI agent (OpenHands).
Review
The refactor is correct and behavior-preserving. ConversationAlreadyRunning and GoalAlreadyRunning subclass ValueError and keep the exact previous messages, so every caller that still catches ValueError or matches the message (e.g. tests/agent_server/test_goal_loop.py pytest.raises(ValueError, match=...)) keeps working. All raise sites in EventService.run(), start_goal_loop(), and resume_goal_loop() were converted, and I traced each converted catch site against the base behavior: the send_message paths, the ACP-supersede path, and the confirm-acceptance path swallow/propagate other ValueErrors exactly as before, and the re-arm block in _run_and_publish still lets ServiceInactive and ConversationRunLimitExceeded propagate. GOAL_LOOP_SENDER is a pure constant extraction; no sender="goal" literals remain. REST semantics are unchanged (same 409 Conflict / 400 Invalid mapping, no OpenAPI change).
Verification on the current head 74a03a1b:
tests/agent_server/test_conversation_router.py,test_goal_loop.py,test_run_admission.py, andtests/sdk/conversation: 1274 passed.ruff checkandruff format --checkpass on the changed files.- The full
tests/agent_serverrun in this sandbox shows 30 failures, all incanvas_extensions/,credential_binding, and launch-parity modules untouched by this diff; I reproduced two of them identically onorigin/main, confirming they are pre-existing environment issues (sandbox git/config), not regressions. - GitHub CI on this head: all test, lint, type, OpenAPI, and compat checks green. The only failures are in the per-arch Docker
Build & Pushpublish jobs (python-arm64failed;java/golang/python-amd64were cancelled downstream, and the manifest-consolidation summary job was cancelled with them). That is an image-publishing pipeline issue unrelated to this diff, so it does not block this refactor, but the failed image jobs may need a re-run before release automation picks up the74a03a1-pythontags.
Scope check: the change lives entirely in this repository's ownership (Agent Server exceptions/REST error mapping and SDK conversation types), matching the linked issue #7008 (ready-for-dev). No cross-repository or REST-contract concerns.
APPROVED
HUMAN:
AGENT:
Why
EventService.runand the goal loop refused a busy conversation withValueError("conversation_already_running")orValueError("goal_already_running"), and every caller comparedstr(e)to tell those apart from otherValueErrors. The goal loop's messages also used the bare literal"goal"as theirsender. This was split out of #6602, which builds on both.Summary
ConversationAlreadyRunningandGoalAlreadyRunninginopenhands/agent_server/exceptions.py. Both areValueErrorsubclasses with the same messages as before, so callers that still catchValueErrorand match the message keep working.event_service.pyraises them, andevent_service.pyandconversation_router.pycatch the type instead of the string. Behavior is unchanged: otherValueErrors are still swallowed or re-raised exactly where they were.GOAL_LOOP_SENDER = "goal"inopenhands.sdk.conversation.types, used by the goal runner andEventService.send_message.The third item Engel listed, the moved
ASK_USERdefinition, is diff noise inside #6602 and has nothing to change on main, so it's fixed there instead.Issue Number
Fixes #7008
How to Test
uv run pytest -n 8 tests/agent_server tests/sdk/conversation: 4414 passed, 1 failed. The failure,test_canvas_extension_backend.py::test_exited_leader_descendant_does_not_block_recovery[status], also fails onmainin this environment.ruff check,ruff formatandpyrightpass on the changed files.Video/Screenshots
Not a visual change.
Type
Notes
#6602 keeps a copy of this change until this PR merges.
🤖 Generated with Claude Code
https://claude.ai/code/session_013ArwwJH94xGSYwfoyccT4E
🐳 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:74a03a1-pythonRun
All tags pushed for this build
About Multi-Architecture Support
74a03a1-python) is a multi-arch manifest supporting both amd64 and arm6474a03a1-python-amd64) are also available if needed