Skip to content

Recover cloud agent shells after process exit - #16148

Open
warp-agent-staging[bot] wants to merge 8 commits into
masterfrom
factory/remote-2243-pty-respawn-implementation
Open

warp-agent-staging[bot] wants to merge 8 commits into
masterfrom
factory/remote-2243-pty-respawn-implementation

Conversation

@warp-agent-staging

@warp-agent-staging warp-agent-staging Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

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_finished delivery. 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.rs and app/src/terminal/writeable_pty/pty_controller.rs for PTY suspension and queued intent delivery. Then review app/src/ai/blocklist/action_model/execute/shell_command.rs for durable, exactly-once recovery results and app/src/terminal/model/terminal_model.rs for observed-status handling. The production-wired shared-session integration is in crates/integration/src/test/cloud_shell_recovery.rs; it now uses a hermetic local Bash session rather than requiring Docker or sbx.

Plans:

Linked Issue

https://linear.app/warpdotdev/issue/REMOTE-2243/recover-oz-cloud-sessions-when-an-agent-command-exits-the-shell

  • The linked issue is labeled ready-to-spec or ready-to-implement.
  • Where appropriate, screenshots or a short video of the implementation are included below (this change has no new visual state).

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-run with the CI RUSTFLAGS — all workspace test targets compiled.
  • Focused warp_tui recovery-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.
  • Linux CI-equivalent cargo nextest run --workspace --locked -E 'package(integration) and test(test_cloud_agent_shell_respawn)' under xvfb-run after the macOS timing fix — 1 passed, 336 skipped.
  • cargo clippy -p integration --all-targets --tests --locked -- -D warnings with the CI RUSTFLAGS after the macOS timing fix — passed.
  • Warp CI run 36637389996 passed Linux, Windows, all compile targets, and all Clippy targets; macOS exposed Bash 3.2 test races in transient session lookup and post-recovery prompt readiness. Commit 013d4b371 removes both timing assumptions.
  • macOS-specific execution is pending replacement CI because this environment has no macOS runner.
  • ./script/format — completed after the final source changes.
  • git diff --check — passed.

test_cloud_agent_shell_respawn now drives the normal ambient-agent shared-session path through local /bin/bash, without Docker or sbx. 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 external command_finished delivery with the observed exit code, continued sharing across three recoveries, and tab closure when the fourth shell death exhausts the recovery budget.

  • I have manually tested my changes locally with ./script/run — the CI-equivalent real-display integration test covers the end-to-end recovery path.

Agent Mode

  • Warp Agent Mode - This PR was created via Warp's AI Agent Mode

CHANGELOG-BUG-FIX: Recover cloud Oz sessions when an agent command exits the persistent shell.

@cla-bot cla-bot Bot added the cla-signed label Sep 24, 2026
@warp-agent-staging

Copy link
Copy Markdown
Contributor Author

This PR was generated with Warp.

Comment @warp-staging-factory on this PR to send it follow-up work.

View run View conversation View origin

@warp-agent-staging
warp-agent-staging Bot marked this pull request as ready for review September 24, 2026 20:45
@harryalbert
harryalbert force-pushed the factory/remote-2243-pty-respawn-implementation branch from d7d16fb to 89bd02f Compare September 27, 2026 19:24

Copy link
Copy Markdown
Contributor

This stack of pull requests is managed by Graphite. Learn more about stacking.

@harryalbert
harryalbert force-pushed the factory/remote-2243-pty-respawn-implementation branch from 89bd02f to 7ded432 Compare September 28, 2026 19:35
@harryalbert
harryalbert force-pushed the factory/remote-2243-pty-respawn-implementation branch from 7ded432 to 180c58e Compare September 29, 2026 20:07
@warp-agent-staging
warp-agent-staging Bot marked this pull request as draft September 29, 2026 22:05
@warp-agent-staging
warp-agent-staging Bot marked this pull request as ready for review September 29, 2026 22:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant