Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: tee command output to stdout/stderr in /execute_action endpoint #5267

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

rbren
Copy link
Collaborator

@rbren rbren commented Nov 25, 2024

This PR adds functionality to tee the command output to both the response and the real stdout/stderr in the /execute_action endpoint. This is useful for debugging and monitoring command execution in real-time.

Changes:

  • Modified BashSession._continue_bash to print output character by character in real-time
  • Added real-time output printing with print(char, end="", flush=True)
  • Modified run and run_ipython methods to print their output to stdout
  • Added flush=True to ensure output is written immediately

The changes ensure that:

  1. Command output appears in real-time on stdout/stderr as it is being produced
  2. The same output is collected and returned in the response
  3. Long-running commands can be monitored in real-time while still getting the full output in the response

To run this PR locally, use the following command:

docker run -it --rm   -p 3000:3000   -v /var/run/docker.sock:/var/run/docker.sock   --add-host host.docker.internal:host-gateway   -e SANDBOX_RUNTIME_CONTAINER_IMAGE=docker.all-hands.dev/all-hands-ai/runtime:0054ef7-nikolaik   --name openhands-app-0054ef7   docker.all-hands.dev/all-hands-ai/openhands:0054ef7

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.

2 participants