Repository navigation
refactor(agent-server): typed ServiceInactive instead of the "inactive_service" string - #6910
Conversation
…e" string
ConversationService and EventService raised ValueError("inactive_service")
in 52 places when used outside their running lifetime, and two event routes
told it apart from bad requests by comparing str(exc). ServiceInactive
replaces the string. It stays a ValueError with the same message, so REST
answers and error classification do not change; the routes now catch the
type.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013ArwwLYPA4zfbsUTU75ee4
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: In-repo and correctly placed — the agent server is owned by this repository, and the change follows the typed-refusal style established in #6602 (ValueError subclasses that keep the old message).
Verified against issue #6909's acceptance criteria on head 6a39a25a:
- No
raise ValueError("inactive_service")and nostr(exc) == "inactive_service"remain in the agent server; all 52 raise sites now useServiceInactive(18 inconversation_service.py, 34 inevent_service.py). The only remaining"inactive_service"strings are the exception's own message and theerror_classificationtext list, both intentional. - External behavior is preserved:
ServiceInactiveis still aValueErrorwith message"inactive_service", so routes that mapValueErrorto 400 keep doing so (e.g.switch_llm,switch_acp_model/effort,add_mcp_servers,load_plugin), anderror_classification's substring match still classifies it asCONFIG. The substring-based handlers innavigateandforkare unaffected ("inactive_service"contains none ofevent_id/already exists/from_event_id, so those re-raise as before). react_to_messageandanswer_ask_userre-raise the typed exception before the genericValueError→ 400 mapping, matching the previous string-comparison behavior, with new router tests covering it.- No REST/OpenAPI contract change (REST API OpenAPI and schema checks pass on this head).
Testing: Focused suites for all seven changed test files pass in the workspace (test_reactions_router, test_ask_user_router, test_event_socket_races, test_conversation_response, test_conversation_service, test_event_service, test_conversation_router — 436 tests). Completed CI on this head is green for the code checks (agent-server-api, agent-server-stress-tests, pre-commit, REST API (OpenAPI), Check OpenAPI Schema, security, sdk/workspace/tools/windows tests, smoke-test, endpoint-audit, public-type-budget, persisted-settings).
Note on the one failing check: "Validate PR description" fails only because linked issue #6909 (created 2026-11-16T23:03Z, after the rollout date) carries neither ready-for-dev nor a pre-rollout creation date. That is the repository's issue-readiness governance gate, not a defect in this head; issue labeling is owned by the automation flow and outside this review's scope.
No material correctness, security, or compatibility findings.
✅ APPROVED
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 •
|
|||||||||||||||||||||||||||||||||||
Projects' own inactive_service raises and the coordinator delivery now use ServiceInactive too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013ArwwJH94xGSYwfoyccT4E
HUMAN:
AGENT:
Why
The agent server says "this service is not running" with
raise ValueError("inactive_service"), and code that must tell it apart from a bad-inputValueErrorcompares strings (if str(exc) == "inactive_service": raise). A reworded message or a typo would silently turn a server-state error into a 400. A type says the same thing and lets callers catch it.Where
"inactive_service"came fromConversationServiceraised it when_event_servicesisNone, i.e. the service is used before__aenter__or after__aexit__(get/search/count/start/pause/resume/delete conversation).EventServiceraised it when_conversationisNone, i.e. beforestart()or after close (get/search/count events, send message).main(18 inconversation_service.py, 34 inevent_service.py; 87 lines mention the string across code and tests).ask_useranswer route (feat: ask_user tool for decision cards, behind an experimental feature #6852) re-raise it before mapping otherValueErrors to 400.error_classification(feat(sdk): classify conversation errors #4316) lists"inactive_service"among the configuration-error texts it matches.Summary
ServiceInactive(ValueError)inevent_service.py, next toCondensationUnavailable; its message is still"inactive_service". All 52 raises use it.ask_userroutes catchServiceInactiveand re-raise it, instead of comparingstr(exc).ask_userroutes do not turn it into a 400.ValueErrorwith the same message, so routes that mapValueErrorto 400 still do, anderror_classification's text match still works.Issue Number
Fixes #6909
How to Test
uv run pytest -n 8 tests/agent_server uv run pre-commit run --files $(git diff --name-only origin/main)Locally:
tests/agent_server3288 passed, 8 skipped, 1 failed. The failure,test_canvas_extension_backend.py::test_exited_leader_descendant_does_not_block_recovery[status], fails the same way onmainwithout this change. Pre-commit (ruff, pycodestyle, pyright, the repo's custom checks) passes on the changed files.grep -rn 'ValueError("inactive_service")\|== "inactive_service"' openhands-agent-serverfinds nothing.Video/Screenshots
Not a visual change.
Type
Notes
ConversationAlreadyRunning,GoalAlreadyRunning,HeldForUser): aValueErrorsubclass that keeps the old message. Those strings are also onmain; feat(agent-server): projects API, coordinator tools, board groups and artifacts #6602 types them, so this PR leaves them alone.Unavailable, 503) would be cleaner still, but it changes status codes for several routes, so it is left for a separate decision.Generated by Claude Code
🐳 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:6a39a25-pythonRun
All tags pushed for this build
About Multi-Architecture Support
6a39a25-python) is a multi-arch manifest supporting both amd64 and arm646a39a25-python-amd64) are also available if needed