Repository navigation
fix(agentos): wait for a spawned process to start before reading its output - #2024
Conversation
|
This PR was not deployed automatically as @eersnington does not have access to the Railway project. In order to get automatic PR deploys, please add @eersnington to your workspace on Railway. |
| // request lands or fails, so a read never reaches the sidecar before the process exists. | ||
| loop { |
There was a problem hiding this comment.
🟠 Medium · Track spawn acknowledgement separately from the optional kernel PID
kernel_pid is not a reliable acknowledgement flag: ProcessStartedResponse.pid is explicitly optional, and run_spawn accepts a successful response while only updating this watch channel for Some(pid). With a valid process_started response containing no PID, a long-running process leaves both started as None and outcome as Pending, so this call waits indefinitely even though replay is already available. Add a dedicated spawn-result/readiness watch (as the shell path does), and signal it on every successful send_execute response rather than overloading the optional PID mapping.
AgentOs::spawn_processreturns the pid before the sidecar has the process. TheExecuterequest goes out from a background task.read_process_outputcall sentReadProcessOutputRequestright away, so a read soon after a spawn, or after a launch that failed, gotESRCH. The launch error (for example a missing command) was recorded only in the local exit state, so callers never saw it.read_process_outputwaits until the process has a kernel pid or a settled outcome, then reads, or returns the launch error.wait_processalready waits the same way.The
signal_process_awaitedandresize_process_pty_awaitedcalls also send the process id before the launch lands. They are not changed here.Adds
output_read_right_after_a_failed_spawn_returns_the_launch_errortocrates/client/tests/process_e2e.rs: a read right after spawning a missing command returnsENOENT. Onmainit returnsESRCH.