Repository navigation
[AI-2644] Let a stopped Pi agent exit on closed stdin before killing it - #1205
Conversation
Pi's abort RPC ends only the current turn, so every stop fell through to a tree kill and exit 137. Pi ends its session and exits 0 on stdin EOF. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
PR Summary by QodoLet hosted Pi exit cleanly when stopped
AI Description
Diagram
High-Level Assessment
Files changed (7)
|
Code Review by Qodo
1.
|
The terminate that follows every stop cancels the read pump, so frames Pi wrote as it exited were dropped unless the stop waited for the pump. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Closes #845 — AI-2644
What & why
Stopping a hosted Pi agent sent only the
abortRPC, which ends the current turn but not the process, so every stop waited out the grace and tree-killed Pi (exit 137). The stop now closes Pi's stdin after the abort; Pi ends its session and exits 0 on EOF, and the kill remains only for a child that outlives the grace. The status-report and SIGHUP halves of the issue were already fixed on main by #846 and #841.Where to look
PiRpcProcess.CloseInputAsynctakes the stdin write gate with a timeout, so a write blocked on a child that stopped reading cannot hang the stop — it falls through to the kill.Verification
pi --mode rpc </dev/nullwith Pi 0.85.1: exits 0.RequestGracefulStopAsync_lets_a_child_that_exits_on_closed_stdin_exit_cleanlyandAn_owner_stop_lets_pi_exit_cleanly_and_reports_completed.AgentOrchestrator*249/249,Pi*206 passed + 17 skipped,*Status*65/65,*Reap*41/41.🤖 Generated with Claude Code