Repository navigation
Kill shell tool process groups on timeout - #5258
Conversation
|
Thanks for the contribution, and apologies for the slow response. We received many PRs, and we're just now getting through the backlog. It looks like this PR has gone stale. If you're still interested in submitting it, could you please resolve the merge conflicts and prepare it for review? Thanks! |
| JsonSchema::Number { | ||
| description: Some( | ||
| "Maximum time in milliseconds to wait for output after writing the input." | ||
| "Maximum time in milliseconds to wait for output after writing the input (default: 1000)." |
There was a problem hiding this comment.
Where is this default value coming from?
There was a problem hiding this comment.
DEFAULT_TIMEOUT_MS. We should remove these for now and make the change separately if we think the model is confused.
| // run _after_ the parent (i.e., the Codex process) has already | ||
| // exited, then the parent is the _init_ process (which will never | ||
| // die), so we should just terminate the child process now. | ||
| if libc::getppid() == 1 { |
There was a problem hiding this comment.
There was recently a PR merged around mishandling Codex run as PID 1: #4200
|
I also want to make note of #1852, which admittedly I never made time to review. |
| } | ||
| } | ||
| _ = tokio::signal::ctrl_c() => { | ||
| kill_child_process_group(&mut child)?; |
There was a problem hiding this comment.
Should the child.start_kill() call be moved into kill_child_process_group()? Is it necessary if killpg succeeds?
revert author's comment
undo property description changes for now
another docstring change
linux only gepid
add move keyword that got lost
added a test
remove hashmap import in test block; already at top of file
Summary
Original Bug
Long-lived shell tool commands hang indefinitely because the timeout handler only terminated the direct child process; any grandchildren it spawned kept running and held the PTY open, preventing Codex from regaining control.
Repro Original Bug
Install next.js and run
next dev(which is a long-running shell process with children). On openai:main, it will cause the agent to permanently get stuck here until human intervention. On this branch, this command will be terminated successfully after timeout_ms which will unblock the agent. This is a critical fix for unmonitored / lightly monitored agents that don't have immediate human observation to unblock them.