Recover cloud agent shells after process exit - #16148
Open
warp-agent-staging[bot] wants to merge 8 commits into
Open
warp-agent-staging[bot] wants to merge 8 commits into
warp-agent-staging[bot] wants to merge 8 commits into
Conversation
Contributor
Author
|
This PR was generated with Warp. Comment |
harryalbert
force-pushed
the
factory/remote-2243-pty-respawn-implementation
branch
from
September 27, 2026 19:24
d7d16fb to
89bd02f
Compare
harryalbert
force-pushed
the
factory/remote-2243-pty-respawn-implementation
branch
from
September 28, 2026 19:35
89bd02f to
7ded432
Compare
harryalbert
force-pushed
the
factory/remote-2243-pty-respawn-implementation
branch
from
September 29, 2026 20:07
7ded432 to
180c58e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.




Description
Recover cloud Oz sessions when an attributable agent command terminates the persistent Bash shell. Warp completes the interrupted tool call with the observed status and recovery guidance, then creates a fresh PTY/Bash in the existing sandbox without replaying the command.
Recovery now distinguishes a temporarily suspended event loop from a terminal disconnect. Resize and input intents queue while the replacement PTY bootstraps, then drain in order after reconnection. Recovery completion no longer depends on a live output waiter: a result persists until a later read consumes it exactly once.
The replacement follows the production ambient-agent shared-session path and preserves external
command_finisheddelivery. Signal and unavailable outcomes remain explicit in stable output but do not fabricate an exit code; an observed zero remains distinguishable from an unknown status throughout the terminal model and API conversion.Approved design and review requirements: #16144
Review guide
Start with
app/src/terminal/local_tty/terminal_manager.rsandapp/src/terminal/writeable_pty/pty_controller.rsfor PTY suspension and queued intent delivery. Then reviewapp/src/ai/blocklist/action_model/execute/shell_command.rsfor durable, exactly-once recovery results andapp/src/terminal/model/terminal_model.rsfor observed-status handling. The production-wired shared-session integration is incrates/integration/src/test/cloud_shell_recovery.rs; it now uses a hermetic local Bash session rather than requiring Docker orsbx.Plans:
Linked Issue
https://linear.app/warpdotdev/issue/REMOTE-2243/recover-oz-cloud-sessions-when-an-agent-command-exits-the-shell
ready-to-specorready-to-implement.Testing
cargo nextest run -p warp -E 'test(replacement_sender_queues_resize_and_input_while_suspended) | test(shell_recovery)'— 15 passed.cargo nextest run -p ai -E 'test(recovered_signal_and_unavailable_omit_wire_exit_code) | test(recovered_observed_zero_is_explicit_in_stable_output) | test(recovered_nonzero_exit_code_is_serialized)'— 3 passed.cargo nextest run --workspace --locked --no-runwith the CIRUSTFLAGS— all workspace test targets compiled.warp_tuirecovery-call-site tests — 8 passed.cargo check -p warp --tests— passed.cargo check -p ai --tests— passed.cargo check -p integration— passed.cargo clippy --locked --workspace --all-targets --tests -- -D warnings— passed.cargo clippy --locked --target wasm32-unknown-unknown --profile release-wasm-debug_assertions -- -D warnings— passed.cargo clippy -p warp --all-targets --tests --no-deps -- -D warnings— passed.cargo clippy -p ai --all-targets --tests --no-deps -- -D warnings— passed.cargo clippy -p integration --all-targets --tests --no-deps -- -D warnings— passed.cargo nextest run --workspace --locked -E 'package(integration) and test(test_cloud_agent_shell_respawn)'underxvfb-runafter the macOS timing fix — 1 passed, 336 skipped.cargo clippy -p integration --all-targets --tests --locked -- -D warningswith the CIRUSTFLAGSafter the macOS timing fix — passed.013d4b371removes both timing assumptions../script/format— completed after the final source changes.git diff --check— passed.test_cloud_agent_shell_respawnnow drives the normal ambient-agent shared-session path through local/bin/bash, without Docker orsbx. It resolves recovery state from durable action metadata and waits for the replacement shell's post-bootstrap prompt before submitting another command. It verifies setup through the agent command executor, working-directory/environment/filesystem preservation, no command replay, exactly-once externalcommand_finisheddelivery with the observed exit code, continued sharing across three recoveries, and tab closure when the fourth shell death exhausts the recovery budget../script/run— the CI-equivalent real-display integration test covers the end-to-end recovery path.Agent Mode
CHANGELOG-BUG-FIX: Recover cloud Oz sessions when an agent command exits the persistent shell.