Skip to content

Fix DockerWorkspace execute_command timeout issue - #871

Merged
xingyaoww merged 1 commit into
mainfrom
openhands/fix-docker-workspace-timeout
Oct 23, 2025
Merged

xingyaoww merged 1 commit into
mainfrom
openhands/fix-docker-workspace-timeout

Conversation

@neubig

@neubig neubig commented Oct 23, 2025 •

Copy link
Copy Markdown
Member

Summary

Fixes #870 - Resolves the timeout issue when using execute_command in RemoteWorkspace.

Root Cause Analysis

The SDK was calling the wrong API endpoint for asynchronous command execution:

  1. Wrong endpoint used: /api/bash/execute_bash_command

    • This is a synchronous endpoint that waits for command completion
    • Returns BashOutput with id=output_event_id and a separate command_id field
  2. ID mismatch: SDK used the wrong ID for polling

    • SDK extracted bash_command["id"] which was the output event ID
    • Used this output event ID to poll for bash events
    • Polling endpoint searches by command ID, not output event ID
    • Result: 0 events found → timeout after 30 seconds
  3. Correct endpoint: /api/bash/start_bash_command

    • This is the asynchronous endpoint designed for polling
    • Returns BashCommand with id=command_id
    • SDK's existing polling logic works correctly with this command ID

Changes Made

  • Changed API endpoint from execute_bash_command to start_bash_command in remote_workspace_mixin.py
  • Updated test to reflect the correct endpoint URL

Testing

✅ All existing tests pass
✅ Manual integration test with actual RemoteWorkspace confirms commands execute successfully without timeout

Impact

  • Minimal code change: Single line endpoint URL change
  • No breaking changes: All existing functionality preserved
  • Fixes critical bug: Commands that previously timed out now work correctly

Agent Server images for this PR

• GHCR package: https://github.com/OpenHands/agent-sdk/pkgs/container/agent-server

Variants & Base Images

Variant Base Image Docs / Tags
golang golang:1.21-bookworm Link
java eclipse-temurin:17-jdk Link
python nikolaik/python-nodejs:python3.12-nodejs22 Link

Pull (multi-arch manifest)

docker pull ghcr.io/openhands/agent-server:cd99d7f-python

Run

docker run -it --rm \
  -p 8000:8000 \
  --name agent-server-cd99d7f-python \
  ghcr.io/openhands/agent-server:cd99d7f-python

All tags pushed for this build

ghcr.io/openhands/agent-server:cd99d7f-golang
ghcr.io/openhands/agent-server:v1.0.0a3_golang_tag_1.21-bookworm_binary
ghcr.io/openhands/agent-server:cd99d7f-java
ghcr.io/openhands/agent-server:v1.0.0a3_eclipse-temurin_tag_17-jdk_binary
ghcr.io/openhands/agent-server:cd99d7f-python
ghcr.io/openhands/agent-server:v1.0.0a3_nikolaik_s_python-nodejs_tag_python3.12-nodejs22_binary

The cd99d7f tag is a multi-arch manifest (amd64/arm64); your client pulls the right arch automatically.

@github-actions

github-actions Bot commented Oct 23, 2025 •

Copy link
Copy Markdown
Contributor

Coverage

Coverage Report •
FileStmtsMissCoverMissing
openhands-sdk/openhands/sdk/workspace/remote
   remote_workspace_mixin.py927419%27–28, 32–35, 56, 59, 63–64, 66, 68, 75–77, 79, 82–85, 87, 89, 100–101, 104–111, 114–115, 118, 121–124, 127–128, 130, 138–140, 164–165, 167, 169, 171–172, 175–176, 179, 187–188, 191, 199–201, 224–225, 227, 229, 231, 234, 241, 244, 247–248, 250, 257–259
TOTAL7987342557% 

@neubig
neubig marked this pull request as ready for review October 23, 2025 01:38
@neubig
neubig marked this pull request as draft October 23, 2025 03:53
The SDK was calling /api/bash/execute_bash_command which is a
synchronous endpoint that returns BashOutput immediately. However,
the SDK code was treating it as async and trying to poll for results
using the wrong ID (output event ID instead of command ID).

Root cause:
- execute_bash_command returns BashOutput with id=output_event_id
- SDK used this output event ID to poll for bash events
- Polling found 0 results since output events are not searchable
- After 30s timeout, command failed

Fix:
- Use /api/bash/start_bash_command which is the correct async endpoint
- This endpoint returns BashCommand with id=command_id
- SDK's existing polling logic works correctly with this command ID

Fixes #870

Co-authored-by: openhands <openhands@all-hands.dev>
@neubig
neubig force-pushed the openhands/fix-docker-workspace-timeout branch from 3538a40 to dd3a749 Compare October 23, 2025 04:05
@juanmichelini

Copy link
Copy Markdown
Collaborator

Fixes #864 #866 #870 (tested on all three)

@neubig
neubig marked this pull request as ready for review October 23, 2025 21:23
@juanmichelini
juanmichelini self-requested a review October 23, 2025 21:23

@juanmichelini juanmichelini left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM fixes #864 #866 #870 (tested on all three)

@xingyaoww
xingyaoww merged commit 54c5858 into main Oct 23, 2025
@xingyaoww
xingyaoww deleted the openhands/fix-docker-workspace-timeout branch October 23, 2025 21:28
xingyaoww pushed a commit that referenced this pull request Oct 23, 2025
This test verifies that the correct /api/bash/start_bash_command endpoint
is used when executing bash commands. This is a regression test for issue #866
where the incorrect endpoint /api/bash/execute_bash_command was being used,
causing command execution to timeout.

The fix was implemented in PR #871, and this test ensures that the correct
endpoint continues to be used and prevents future regressions.

Co-authored-by: openhands <openhands@all-hands.dev>
vivekvjnk pushed a commit to vivekvjnk/agent-sdk that referenced this pull request Nov 17, 2025
Co-authored-by: openhands <openhands@all-hands.dev>
StressTestor pushed a commit to StressTestor/software-agent-sdk that referenced this pull request Jun 1, 2026
Co-authored-by: openhands <openhands@all-hands.dev>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DockerWorkspace execute_command timeout

4 participants