Repository navigation
Fix RemoteConversation.run() timeout issues with async polling - #1444
Conversation
- Server: Modify EventService.run() to run conversation in background task
using asyncio.create_task() instead of awaiting, returning immediately
- Client: Add blocking parameter to RemoteConversation.run() (default True)
to allow non-blocking calls
- Client: Add polling logic to wait for completion when blocking=True
- Add comprehensive tests for both server and client changes
This fixes timeout issues ('The read operation timed out', 'Server
disconnected without sending a response') by:
1. Server triggers run and returns immediately (no long-held connection)
2. Client polls GET /api/conversations/{id} for status until complete
3. Users can opt-out of blocking with blocking=False for fire-and-forget
Co-authored-by: openhands <openhands@all-hands.dev>
Coverage Report •
|
||||||||||||||||||||||||||||||
|
cc @simonrosenberg @juanmichelini this supposedly should help fixing these two issues commonly seen in evaluation: I'm running an eval to validate in this PR: OpenHands/benchmarks#179 Would appreciate an 👀 here in case i missed smth - but it is pretty smooth so far! |
juanmichelini
left a comment
There was a problem hiding this comment.
LGTM! assuming the eval OpenHands/benchmarks#179 runs smoothly, I will run a large split tomorrow.
|
@juanmichelini i've been running ~293 instances so far, didn't see a single instance of yet |
|
LGTM @OpenHands Do you see any footguns? /codereview-roasted Investigate the repo and keep your analysis grounded in reality, not disconnected hypotheticals. |
|
I'm on it! enyst can track my progress at all-hands.dev |
Summary of my review(you asked for footguns) Overall: The async “trigger + poll” approach is a solid, pragmatic fix for the timeout issues. It removes long-held connections and keeps the default blocking behavior via polling. A few server-side concurrency and lifecycle edges are worth tightening to avoid subtle runtime issues. Critical footguns (must-fix)
Improvements (nice-to-have but recommended)
Verdict
|
|
@OpenHands can you review the two footguns: #1444 (comment) Are they valid? If so, can you try fix the critical ones - make minimal edits necessary (we already tested most of the PR, if we change it too much, we might need to re-run an expensive eval) |
|
I'm on it! xingyaoww can track my progress at all-hands.dev |
- Add asyncio.Lock to make check-and-set atomic, preventing race conditions when concurrent POST /run requests arrive - Catch and log exceptions in _run_and_publish to prevent 'Task exception was never retrieved' warnings - Clear _run_task in finally block for proper lifecycle hygiene - Handle 'already running' in respond_to_confirmation as no-op success to prevent 500 errors when confirmation arrives during active run Co-authored-by: openhands <openhands@all-hands.dev>
SummaryI reviewed the two critical footguns identified in the PR comment and confirmed they are valid. I've implemented minimal fixes for all three critical issues: Fixes Applied
Verification
Changes
The changes have been pushed to the |
|
Hi! I started running the integration tests on your PR. You will receive a comment with the results shortly. |
|
Thanks @enyst for the feedback - Just got OH fixed it, lmk if you have concerns there and happy to fix in follow-up PRs |
🧪 Integration Tests ResultsOverall Success Rate: 97.8% 📁 Detailed Logs & ArtifactsClick the links below to access detailed agent/LLM logs showing the complete reasoning process for each model. On the GitHub Actions page, scroll down to the 'Artifacts' section to download the logs.
📊 Summary
📋 Detailed Resultslitellm_proxy_gpt_5.1_codex_max
litellm_proxy_mistral_devstral_2512
Skipped Tests:
Failed Tests:
litellm_proxy_vertex_ai_gemini_3_pro_preview
litellm_proxy_claude_sonnet_4_5_20250929
litellm_proxy_deepseek_deepseek_chat
Skipped Tests:
litellm_proxy_moonshot_kimi_k2_thinking
Skipped Tests:
|
|
🍰 |
…ands#1444) Co-authored-by: openhands <openhands@all-hands.dev>
Problem
We were experiencing intermittent timeout issues when calling
RemoteConversation.run():The read operation timed outServer disconnected without sending a responseThese errors occurred because the client held a single HTTP request open for the entire duration of the conversation run (up to 30 minutes), which is prone to network timeouts and connection drops.
Solution
This PR makes the run operation async with polling:
Server-side changes (
EventService.run())asyncio.create_task()instead of awaitingfinallyblock to ensure it happens even on error)Client-side changes (
RemoteConversation.run())blockingparameter (defaultTrue) to allow non-blocking callspoll_intervalparameter (default1.0seconds) to control polling frequencytimeoutparameter (default1800seconds / 30 minutes) for maximum wait timeblocking=True, pollsGET /api/conversations/{id}for status until completeUsage
Testing
EventService.run()background task behaviorAgent Server images for this PR
• GHCR package: https://github.com/OpenHands/agent-sdk/pkgs/container/agent-server
Variants & Base Images
eclipse-temurin:17-jdknikolaik/python-nodejs:python3.12-nodejs22golang: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:6fa7a2f-pythonRun
All tags pushed for this build
About Multi-Architecture Support
6fa7a2f-python) is a multi-arch manifest supporting both amd64 and arm646fa7a2f-python-amd64) are also available if needed