OpenHands / OpenHands/software-agent-sdk

[Bug]: Agent-Server Webhook Connection Failures Cause Container Crashes and Sandbox Connection Errors

Open
#4,245 12 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug docker needs-triage
Dominant language
Python
Stars
1.1k
Forks
539
Avg merge
1d 19h
Merged PRs (30d)
137

Description

Is there an existing issue for the same bug? (If one exists, thumbs up or comment on the issue instead).
  • I have checked the existing issues.
Describe the bug and reproduction steps

Summary

The agent-server containers repeatedly fail to connect to webhook endpoints at http://host.docker.internal:3000/api/v1/webhooks/*, causing:

Container crashes after webhook retry attempts are exhausted
Intermittent "500 - Cannot connect to sandbox" errors when opening new conversations
UI/backend desynchronization preventing conversation continuation after errors

Environment

OS: Windows
Network: Accessing OpenHands from multiple machines on local network (192.168.1.220:4000)
Setup: Docker standalone with custom MCP server running on host
MCP Server: Running at http://host.docker.internal:39221/sse (Windows automation tools)

Reproduction Steps

Launch OpenHands with this configuration:

docker run -d --rm ^
  -v /var/run/docker.sock:/var/run/docker.sock ^
  -v %USERPROFILE%\.openhands:/.openhands ^
  -p 4000:3000 ^
  --add-host host.docker.internal:host-gateway ^
  -e OH_WEB_URL=http://192.168.1.220:4000 ^
  -e SANDBOX_CONTAINER_URL_PATTERN=http://192.168.1.220:{port} ^
  docker.openhands.dev/openhands/openhands:main
  1. Start a conversation with agent
  2. Allow agent to execute MCP tools
  3. Observe webhook connection failures in logs
  4. Container eventually crashes or becomes unresponsive

Observed Behavior

Webhook Errors (from agent-server logs):
{"levelname": "WARNING", "message": "Webhook post attempt 1 failed: All connection attempts failed"}
{"levelname": "WARNING", "message": "Webhook post attempt 2 failed: All connection attempts failed"}
{"levelname": "WARNING", "message": "Webhook post attempt 3 failed: All connection attempts failed"}
{"levelname": "WARNING", "message": "Webhook post attempt 4 failed: All connection attempts failed"}
{"levelname": "ERROR", "message": "Failed to post events to webhook http://host.docker.internal:3000/api/v1/webhooks/events/{conversation_id} after 4 attempts"}
{"levelname": "ERROR", "message": "Failed to post conversation info to webhook http://host.docker.internal:3000/api/v1/webhooks/conversations after 4 attempts"}
MCP Timeout Error (after webhook failures):
TimeoutError
  File "openhands/sdk/utils/async_executor.py", line 81, in _with_timeout
  File "contextlib.py", line 158, in __exit__
  File "anyio/_core/_tasks.py", line 123, in fail_after

The above exception was the direct cause of the following exception:

openhands.sdk.conversation.exceptions.ConversationRunError: Conversation run failed

Symptoms:

Agent executes MCP tools successfully (verified in MCP server logs)
Webhook connection failures begin immediately
After 4 retry attempts, conversation crashes
UI shows conversation as stuck/unresponsive
Clicking "Continue" does nothing - UI and backend are desynchronized
Opening new conversations sometimes results in "500 - Cannot connect to sandbox" error
Only way to recover is restarting containers

Expected Behavior

  1. Agent-server containers should be able to communicate status updates back to the main container
  2. Webhook failures should not crash conversations
  3. UI should remain synchronized with backend state even after errors
  4. Opening new conversations should not fail after previous conversation errors

Additional Context

Main Container Logs (successful MCP communication):
INFO:     172.17.0.1:33514 - "POST /mcp/mcp HTTP/1.1" 200 OK
INFO:mcp.server.lowlevel.server:Processing request of type ListToolsRequest
INFO:mcp.server.streamable_http:Terminating session: None

ALL-4958 - Similar webhook/MCP configuration issues
ALL-4693 - Agent-server containers missing network configuration

OpenHands Installation

Docker command in README

OpenHands Version

main

Model Name

sonnet 4.5

Operating System

WSL on Windows

Logs, Errors, Screenshots, and Additional Context

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Docker command in the README and the agent-server webhook errors, then trace the failure around openhands/sdk/utils/async_executor.py and the webhook endpoints. Reproduce the Windows Docker setup with the listed host and sandbox URL settings. Done means webhook failures no longer crash conversations, UI state remains synchronized, and new conversations continue to open after an error.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, python
Domain
backend, devops, distributed-systems, networking
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.