OpenHands / OpenHands/software-agent-sdk
[Bug]:bserved Behavior: The agent remains idle. No visual feedback or error notification is shown in the interface.
Nobody has claimed this yet.
- 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?
- I have searched existing issues and this is not a duplicate.
Bug Description
This log indicates a timeout error occurring within an OpenHands environment, specifically when attempting to initialize Model Context Protocol (MCP) tools.
The core issue is that the system waited for 30 seconds to list the available tools from your MCP servers (default, tavily, and sse_e6f83bd3), but the request failed to complete in time, triggering an asyncio.exceptions.CancelledError and subsequently an MCPTimeoutError.
Analysis of the Error
The traceback highlights that the failure happens during the initialization phase (_initialize -> init_state). The system is trying to connect to the MCP servers to understand what capabilities (tools) they offer, but one or more of these servers is unresponsive or slow.
Primary Causes
Network Latency: The connection to tavily or the sse (Server-Sent Events) endpoint is lagging.
Server Deadlock: One of the MCP servers might be hanging or stuck in a loop.
Resource Constraints: The environment might be underpowered, causing the Python anyio and asyncio tasks to exceed their deadlines.
Recommended Solutions
-
Increase the Timeout
If the servers are simply slow to start, you can increase the default 30-second window. Look for your OpenHands configuration (often in a .env file or a config.toml) and search for an MCP timeout setting. -
Verify MCP Server Health
Since three servers are listed, one might be the culprit:
tavily: Check your API key and internet connectivity.
sse_e6f83bd3: This looks like a dynamic or local SSE connection. Ensure the process providing this stream is actually running.
Test Isolation: Try disabling one MCP server at a time to identify which one is failing to respond to the list_tools request.
- Debugging via Terminal
Since you have a TerminalExecutor active in /workspace/project, you can attempt to manually curl the health endpoints of your local MCP servers to see if they respond within a reasonable timeframe.
Note: If you are running this in a Docker container (as suggested by the 172.17.0.1 IP), ensure that the container has sufficient CPU/Memory allocated, as asyncio timeouts are common when the event loop is starved of resources.
Expected Behavior
Bug Report: UI Hangs During Agent Initialization Due to MCP Timeout
Description
When opening the UI and waiting for the agent to load, I provide an instruction and click send. The system becomes unresponsive; the message is sent, but the agent does not process it or provide any feedback. No error messages are displayed in the UI, but the backend logs reveal a critical timeout during the MCP (Model Context Protocol) tool initialization.
Steps to Reproduce
Launch the OpenHands UI.
Wait for the agent to initialize.
Type an instruction in the chat input and press enter.
Observed Behavior: The agent does nothing. There is no visual feedback or error notification in the interface.
Technical Logs
The agent logs show that the TerminalExecutor initializes correctly, but the process hangs while listing tools from the configured MCP servers (default, tavily, sse_e6f83bd3).
Error Snippet:
Plaintext
openhands.sdk.mcp.exceptions.MCPTimeoutError: MCP tool listing timed out after 30 seconds.
MCP servers configured: default, tavily, sse_e6f83bd3
Full Traceback Highlights:
Exception: asyncio.exceptions.CancelledError: Cancelled via cancel scope; reason: deadline exceeded
Root Cause: TimeoutError during _connect_and_list_tools in fastmcp/client/client.py.
Context: This occurs during the _ensure_agent_ready and init_state sequence.
Environment Information
Date of Occurrence: 2026-03-26
Component: openhands.agent_server.sockets / openhands.sdk.mcp
Internal IP: 172.17.0.1 (Docker Bridge)
Possible Impact
The UI lacks a "loading" or "error" state for MCP initialization failures, leading to a "zombie" session where the user can send messages that are never processed because the agent state is stuck in an uninitialized loop.
Actual Behavior
UI Logs
INFO: 172.18.0.1:58264 - "GET /api/conversations/c1e2474be8554f49a27c5dd430a07212/config HTTP/1.1" 200 OK
15:31:28 - openhands.app_server.app_conversation.skill_loader:INFO: skill_loader.py:356 - Loaded 38 skills from agent-server: sources={'sandbox': 1, 'sdk_base': 36, 'org': 0, 'project': 1}, names=['work_hosts', 'babysit-pr', 'agent-sdk-builder', 'datadog', 'init', 'gitlab', 'openhands-api', 'theme-factory', 'docker', 'flarglebargle', 'frontend-design', 'github', 'learn-from-code-review', 'releasenotes', 'security', 'code-review', 'linear', 'agent-memory', 'azure-devops', 'github-pr-review', 'bitbucket', 'uv', 'onboarding-agent', 'swift-linux', 'add-skill', 'pdflatex', 'skill-creator', 'notion', 'deno', 'ssh', 'npm', 'codereview-roasted', 'jupyter', 'discord', 'kubernetes', 'vercel', 'readiness-report', 'repo']
15:31:28 - openhands.app_server.app_conversation.app_conversation_service_base:INFO: app_conversation_service_base.py:118 - Loaded 38 total skills from agent-server: ['work_hosts', 'babysit-pr', 'agent-sdk-builder', 'datadog', 'init', 'gitlab', 'openhands-api', 'theme-factory', 'docker', 'flarglebargle', 'frontend-design', 'github', 'learn-from-code-review', 'releasenotes', 'security', 'code-review', 'linear', 'agent-memory', 'azure-devops', 'github-pr-review', 'bitbucket', 'uv', 'onboarding-agent', 'swift-linux', 'add-skill', 'pdflatex', 'skill-creator', 'notion', 'deno', 'ssh', 'npm', 'codereview-roasted', 'jupyter', 'discord', 'kubernetes', 'vercel', 'readiness-report', 'repo']
15:31:28 - openhands.app_server.app_conversation.app_conversation_router:INFO: app_conversation_router.py:550 - Loaded 38 skills for conversation c1e2474b-e855-4f49-a27c-5dd430a07212: ['work_hosts', 'babysit-pr', 'agent-sdk-builder', 'datadog', 'init', 'gitlab', 'openhands-api', 'theme-factory', 'docker', 'flarglebargle', 'frontend-design', 'github', 'learn-from-code-review', 'releasenotes', 'security', 'code-review', 'linear', 'agent-memory', 'azure-devops', 'github-pr-review', 'bitbucket', 'uv', 'onboarding-agent', 'swift-linux', 'add-skill', 'pdflatex', 'skill-creator', 'notion', 'deno', 'ssh', 'npm', 'codereview-roasted', 'jupyter', 'discord', 'kubernetes', 'vercel', 'readiness-report', 'repo']
INFO: 172.18.0.1:55738 - "GET /api/v1/app-conversations/c1e2474be8554f49a27c5dd430a07212/skills HTTP/1.1" 200 OK
INFO: 172.18.0.1:33418 - "POST /mcp/mcp HTTP/1.1" 200 OK
INFO:mcp.server.streamable_http:Terminating session: None
INFO: 172.18.0.1:33434 - "POST /mcp/mcp HTTP/1.1" 202 Accepted
INFO:mcp.server.streamable_http:Terminating session: None
INFO: 172.18.0.1:33448 - "POST /api/v1/webhooks/events/c1e2474be8554f49a27c5dd430a07212 HTTP/1.1" 200 OK
INFO: 172.18.0.1:51580 - "GET /api/conversations/c1e2474be8554f49a27c5dd430a07212 HTTP/1.1" 200 OK
INFO: 172.18.0.1:55122 - "GET /api/v1/web-client/config HTTP/1.1" 200 OK
15:36:38 - openhands.app_server.app_conversation.app_conversation_router:INFO: app_conversation_router.py:538 - Loading skills for conversation c1e2474b-e855-4f49-a27c-5dd430a07212
INFO: 172.18.0.1:55142 - "GET /api/conversations/c1e2474be8554f49a27c5dd430a07212/config HTTP/1.1" 200 OK
INFO: 172.18.0.1:55118 - "GET /api/user/info HTTP/1.1" 200 OK
INFO: 172.18.0.1:55118 - "GET /api/conversations/c1e2474be8554f49a27c5dd430a07212 HTTP/1.1" 200 OK
INFO: 172.18.0.1:55142 - "GET /api/options/models HTTP/1.1" 200 OK
INFO: 172.18.0.1:55142 - "GET /api/options/agents HTTP/1.1" 200 OK
INFO: 172.18.0.1:55142 - "GET /api/options/security-analyzers HTTP/1.1" 200 OK
15:36:40 - openhands:WARNING: utils.py:197 - Unknown config key "load_timeout" in [core] section
15:36:40 - openhands:WARNING: utils.py:197 - Unknown config key "runtime_extra_deps" in [core] section
INFO: 172.18.0.1:55118 - "GET /api/settings HTTP/1.1" 200 OK
15:36:41 - openhands.app_server.app_conversation.skill_loader:INFO: skill_loader.py:356 - Loaded 38 skills from agent-server: sources={'sandbox': 1, 'sdk_base': 36, 'org': 0, 'project': 1}, names=['work_hosts', 'babysit-pr', 'agent-sdk-builder', 'datadog', 'init', 'gitlab', 'openhands-api', 'theme-factory', 'docker', 'flarglebargle', 'frontend-design', 'github', 'learn-from-code-review', 'releasenotes', 'security', 'code-review', 'linear', 'agent-memory', 'azure-devops', 'github-pr-review', 'bitbucket', 'uv', 'onboarding-agent', 'swift-linux', 'add-skill', 'pdflatex', 'skill-creator', 'notion', 'deno', 'ssh', 'npm', 'codereview-roasted', 'jupyter', 'discord', 'kubernetes', 'vercel', 'readiness-report', 'repo']
15:36:41 - openhands.app_server.app_conversation.app_conversation_service_base:INFO: app_conversation_service_base.py:118 - Loaded 38 total skills from agent-server: ['work_hosts', 'babysit-pr', 'agent-sdk-builder', 'datadog', 'init', 'gitlab', 'openhands-api', 'theme-factory', 'docker', 'flarglebargle', 'frontend-design', 'github', 'learn-from-code-review', 'releasenotes', 'security', 'code-review', 'linear', 'agent-memory', 'azure-devops', 'github-pr-review', 'bitbucket', 'uv', 'onboarding-agent', 'swift-linux', 'add-skill', 'pdflatex', 'skill-creator', 'notion', 'deno', 'ssh', 'npm', 'codereview-roasted', 'jupyter', 'discord', 'kubernetes', 'vercel', 'readiness-report', 'repo']
15:36:41 - openhands.app_server.app_conversation.app_conversation_router:INFO: app_conversation_router.py:550 - Loaded 38 skills for conversation c1e2474b-e855-4f49-a27c-5dd430a07212: ['work_hosts', 'babysit-pr', 'agent-sdk-builder', 'datadog', 'init', 'gitlab', 'openhands-api', 'theme-factory', 'docker', 'flarglebargle', 'frontend-design', 'github', 'learn-from-code-review', 'releasenotes', 'security', 'code-review', 'linear', 'agent-memory', 'azure-devops', 'github-pr-review', 'bitbucket', 'uv', 'onboarding-agent', 'swift-linux', 'add-skill', 'pdflatex', 'skill-creator', 'notion', 'deno', 'ssh', 'npm', 'codereview-roasted', 'jupyter', 'discord', 'kubernetes', 'vercel', 'readiness-report', 'repo']
INFO: 172.18.0.1:55138 - "GET /api/v1/app-conversations/c1e2474be8554f49a27c5dd430a07212/skills HTTP/1.1" 200 OK
INFO: 172.18.0.1:55122 - "GET /api/v1/app-conversations?ids=c1e2474be8554f49a27c5dd430a07212 HTTP/1.1" 200 OK
INFO: 172.18.0.1:55122 - "POST /api/v1/sandboxes/oh-agent-server-7KYCYDvJI4J5RdaKQFpNpy/resume HTTP/1.1" 200 OK
Steps to Reproduce
No response
OpenHands Installation Method
Local GUI (Docker web interface)
If you selected "Other", please specify
https://github.com/afonsoft/dev-tools-ia/blob/main/docker-compose.yml
OpenHands Version
1.5
Version Confirmation
- I have confirmed this bug exists on the LATEST version of OpenHands
Model Name
gemini-2.5-flash-lite
Operating System
WSL on Windows
Browser (if using web UI)
No response
Logs and Error Messages
Log from oh-agent-server
[03/26/26 15:31:46] INFO Proxy detected connected client - proxy.py:646
reusing existing session for all
requests. This may cause context
mixing in concurrent scenarios.
{"asctime": "2026-03-26 15:31:46,342", "levelname": "INFO", "name": "openhands.tools.terminal.impl", "filename": "impl.py", "lineno": 59, "message": "TerminalExecutor initialized with working_dir: /workspace/project, username: None, terminal_type: TerminalSession"}
INFO Proxy detected connected client - proxy.py:646
reusing existing session for all
requests. This may cause context
mixing in concurrent scenarios.
{"asctime": "2026-03-26 15:31:48,988", "levelname": "INFO", "name": "uvicorn.access", "message": "172.17.0.1:45460 - \"GET /health HTTP/1.1\" 200", "http.client_ip": "172.17.0.1:45460", "http.method": "GET", "http.url": "/health", "http.version": "1.1", "http.status_code": 200}
{"asctime": "2026-03-26 15:32:15,991", "levelname": "ERROR", "name": "openhands.agent_server.sockets", "filename": "sockets.py", "lineno": 130, "message": "error_in_subscription", "exc_info": "Traceback (most recent call last):\n File \"anyio/_core/_tasks.py\", line 120, in fail_after\n File \"openhands/sdk/utils/async_executor.py\", line 82, in _with_timeout\n File \"openhands/sdk/mcp/utils.py\", line 36, in _connect_and_list_tools\n File \"openhands/sdk/mcp/client.py\", line 51, in connect\n File \"fastmcp/client/client.py\", line 482, in __aenter__\n File \"fastmcp/client/client.py\", line 522, in _connect\n File \"anyio/_backends/_asyncio.py\", line 1783, in wait\n File \"asyncio/locks.py\", line 212, in wait\nasyncio.exceptions.CancelledError: Cancelled via cancel scope 7f94f374be60; reason: deadline exceeded\n\nDuring handling of the above exception, another exception occurred:\n\nTraceback (most recent call last):\n File \"openhands/sdk/mcp/utils.py\", line 61, in create_mcp_tools\n File \"openhands/sdk/mcp/client.py\", line 67, in call_async_from_sync\n File \"openhands/sdk/utils/async_executor.py\", line 84, in run_async\n File \"anyio/from_thread.py\", line 321, in call\n File \"concurrent/futures/_base.py\", line 456, in result\n File \"concurrent/futures/_base.py\", line 401, in __get_result\n File \"anyio/from_thread.py\", line 252, in _call_func\n File \"openhands/sdk/utils/async_executor.py\", line 81, in _with_timeout\n File \"contextlib.py\", line 158, in __exit__\n File \"anyio/_core/_tasks.py\", line 123, in fail_after\nTimeoutError\n\nThe above exception was the direct cause of the following exception:\n\nTraceback (most recent call last):\n File \"openhands/agent_server/sockets.py\", line 124, in events_socket\n File \"openhands/agent_server/event_service.py\", line 312, in send_message\n File \"concurrent/futures/thread.py\", line 59, in run\n File \"lmnr/opentelemetry_lib/decorators/__init__.py\", line 189, in wrap\n File \"openhands/sdk/conversation/impl/local_conversation.py\", line 485, in send_message\n File \"openhands/sdk/conversation/impl/local_conversation.py\", line 463, in _ensure_agent_ready\n File \"openhands/sdk/agent/agent.py\", line 121, in init_state\n File \"openhands/sdk/agent/base.py\", line 311, in init_state\n File \"openhands/sdk/agent/base.py\", line 338, in _initialize\n File \"concurrent/futures/_base.py\", line 456, in result\n File \"concurrent/futures/_base.py\", line 401, in __get_result\n File \"concurrent/futures/thread.py\", line 59, in run\n File \"openhands/sdk/mcp/utils.py\", line 78, in create_mcp_tools\nopenhands.sdk.mcp.exceptions.MCPTimeoutError: MCP tool listing timed out after 30 seconds.\nMCP servers configured: default, tavily, sse_e6f83bd3\n\nPossible solutions:\n 1. Increase the timeout value (default is 30 seconds)\n 2. Check if the MCP server is running and responding\n 3. Verify network connectivity to the MCP server\n", "stack_info": "Stack (most recent call last):\n File \"__main__.py\", line 168, in <module>\n File \"__main__.py\", line 157, in main\n File \"uvicorn/server.py\", line 67, in run\n File \"asyncio/runners.py\", line 195, in run\n File \"asyncio/runners.py\", line 118, in run\n File \"asyncio/base_events.py\", line 678, in run_until_complete\n File \"asyncio/base_events.py\", line 645, in run_forever\n File \"asyncio/base_events.py\", line 1999, in _run_once\n File \"asyncio/events.py\", line 88, in _run\n File \"uvicorn/protocols/websockets/wsproto_impl.py\", line 235, in run_asgi\n File \"uvicorn/middleware/proxy_headers.py\", line 60, in __call__\n File \"fastapi/applications.py\", line 1134, in __call__\n File \"starlette/applications.py\", line 107, in __call__\n File \"starlette/middleware/errors.py\", line 151, in __call__\n File \"starlette/middleware/cors.py\", line 79, in __call__\n File \"starlette/middleware/exceptions.py\", line 63, in __call__\n File \"starlette/_exception_handler.py\", line 42, in wrapped_app\n File \"fastapi/middleware/asyncexitstack.py\", line 18, in __call__\n File \"starlette/routing.py\", line 716, in __call__\n File \"starlette/routing.py\", line 736, in app\n File \"starlette/routing.py\", line 364, in handle\n File \"fastapi/routing.py\", line 145, in app\n File \"starlette/_exception_handler.py\", line 42, in wrapped_app\n File \"fastapi/routing.py\", line 142, in app\n File \"fastapi/routing.py\", line 507, in app\n File \"openhands/agent_server/sockets.py\", line 130, in events_socket"}
{"asctime": "2026-03-26 15:35:09,129", "levelname": "INFO", "name": "uvicorn.access", "message": "172.17.0.1:38468 - \"GET /health HTTP/1.1\" 200", "http.client_ip": "172.17.0.1:38468", "http.method": "GET", "http.url": "/health", "http.version": "1.1", "http.status_code": 200}
{"asctime": "2026-03-26 15:35:09,141", "levelname": "INFO", "name": "uvicorn.access", "message": "172.17.0.1:38468 - \"GET /api/conversations?ids=c1e2474b-e855-4f49-a27c-5dd430a07212 HTTP/1.1\" 200", "http.client_ip": "172.17.0.1:38468", "http.method": "GET", "http.url": "/api/conversations?ids=c1e2474b-e855-4f49-a27c-5dd430a07212", "http.version": "1.1", "http.status_code": 200}
Screenshots and Additional Context
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Inspect the initialization path around _ensure_agent_ready, init_state, and _connect_and_list_tools in openhands.agent_server.sockets and openhands.sdk.mcp; reproduce the timeout with the listed MCP servers. Trace how MCPTimeoutError reaches the UI, then verify that stalled initialization shows loading or error feedback instead of accepting an unprocessed message.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, python
- Domain
- backend, frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100