Skip to main content
The run_streaming_command() method is designed for executing long-running or interactive commands inside your sandbox while receiving real-time output streams. Unlike run_command(), this method does not block until completion — it allows you to process live logs or incremental output as the command runs.

async run_streaming_command(cmd: str, args: Optional[List[str]] = None, stdin: Optional[str] = None, on_stdout: Optional[Callable[[str], None]] = None, on_stderr: Optional[Callable[[str], None]] = None) -> CommandResult

Description:
Executes a long-running command inside the sandbox and streams output in real time. Callbacks are triggered as new stdout or stderr data chunks arrive.

Parameters:
Returns: CommandResult object with the following attributes:
  • stdout: str - Complete accumulated output
  • stderr: str - Complete accumulated error output
  • exit_code: int - Process exit code (0 = success)
Example