Bug description
E2B PTY output collection appears to wake only when stdout/stderr/PTY output arrives. If a process exits after its final output chunk, or exits without output, pty_exec_start / pty_write_stdin can wait until the full yield_time_s window before observing completion.
This adds up to avoidable latency for E2B-backed tool calls, especially across multi-turn episodes.
Expected behavior
When the underlying E2B process/session exits, output collection should wake promptly and return the observed exit code instead of waiting for another output chunk or the yield timeout.
Why this happens
Both E2B execution paths return an AsyncCommandHandle:
tty=false: sandbox.commands.run(..., background=True, ...)
tty=true: sandbox.pty.create(...)
Output and process completion are separate signals. The collector checks for an exit code, but process exit does not currently wake the collector when no further output arrives.
Suggested fix
Treat E2B process/session exit as an output-collection wakeup signal, similar to the existing Daytona sandbox implementation.
A small waiter task can await AsyncCommandHandle.wait(), cache the exit code, and set the existing output notification event so the collector wakes on exit as well as output.
Additional context
This should not require a public API change. The behavior change is internal to the E2B sandbox adapter.
Bug description
E2B PTY output collection appears to wake only when stdout/stderr/PTY output arrives. If a process exits after its final output chunk, or exits without output,
pty_exec_start/pty_write_stdincan wait until the fullyield_time_swindow before observing completion.This adds up to avoidable latency for E2B-backed tool calls, especially across multi-turn episodes.
Expected behavior
When the underlying E2B process/session exits, output collection should wake promptly and return the observed exit code instead of waiting for another output chunk or the yield timeout.
Why this happens
Both E2B execution paths return an
AsyncCommandHandle:tty=false:sandbox.commands.run(..., background=True, ...)tty=true:sandbox.pty.create(...)Output and process completion are separate signals. The collector checks for an exit code, but process exit does not currently wake the collector when no further output arrives.
Suggested fix
Treat E2B process/session exit as an output-collection wakeup signal, similar to the existing Daytona sandbox implementation.
A small waiter task can await
AsyncCommandHandle.wait(), cache the exit code, and set the existing output notification event so the collector wakes on exit as well as output.Additional context
This should not require a public API change. The behavior change is internal to the E2B sandbox adapter.