Skip to content

Report Oz run failure instead of "Cancelled by user" when the agent's command exits the shell#13210

Open
seemeroland wants to merge 6 commits into
masterfrom
roland/manually-canceled-shell-exit
Open

Report Oz run failure instead of "Cancelled by user" when the agent's command exits the shell#13210
seemeroland wants to merge 6 commits into
masterfrom
roland/manually-canceled-shell-exit

Conversation

@seemeroland

@seemeroland seemeroland commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Description

When an agent-issued command caused the shell process to exit mid-run (e.g. it ran exit, or a failing command after set -e), the Oz / ambient agent run was reported as "Cancelled by user" instead of a failure. The shell exit closed the pane, which cancelled the conversation with a ManuallyCancelled reason, so the terminal status was misclassified.

This PR makes a shell exit during an in-flight run a terminal failure with a clear explanation, and refactors the status/cancellation plumbing it touched:

  • Shell-exit failure reporting: added RenderableAIError::AgentExitedShell and CancellationReason::AgentExitedShell. The terminal view's shell-exit handler now finalizes the conversation as a failure (finishing any in-flight stream with the error, cancelling pending actions, and otherwise setting a terminal Error carrying the structured error) so the run reports FAILED with a message instead of "Cancelled by user".
  • Exhaustive cancellation outcomes: replaced the confusing should_preserve_in_progress_status boolean with CancellationReason::conversation_outcome()CancellationOutcome { KeepInProgress, Succeeded, Cancelled, FinalizedExternally }, mapped exhaustively (no wildcard). This also fixes an optimistic-completion case that could land on Cancelled instead of Success.
  • Single structured status error: replaced the conversation's status_error_message: Option<String> with status_error: Option<RenderableAIError> — one source of truth for both the message and the FAILED-vs-ERROR classification. Both status reporters (the Oz task sync model and the ambient SDK driver) read it, so the driver's terminal write no longer downgrades the failure to a generic ERROR. Added RenderableAIError::other(message, is_user_error); the sites that set an Error from a bare string (child-launch and skill-resolution failures, cloud-mode Failed) now go through it.

Linked Issue

https://linear.app/warpdotdev/issue/REMOTE-1987/cloud-agent-session-cancelled-mid-turn-with-inaccurate-cancelled-by

Testing

  • Added/updated unit tests:

    • map_conversation_status: AgentExitedShell and an out-of-band status_error classify as FAILED (InvalidRequest); an is_user_error: false Other classifies as ERROR; end-to-end-via-setter coverage.
    • Exhaustive CancellationReason::conversation_outcome() mapping + an optimistic-completion regression test (in-flight stream ends Success, not Cancelled).
  • Reproduced manually with a local Oz run whose agent command exits the shell: the ambient task now ends as Failed (is_user_error=true) with the shell-exit message, from both the sync-model and SDK-driver paths.

  • cargo check -p warp --tests, cargo nextest run -p warp (affected suites), cargo fmt -p warp, and cargo clippy -p warp --lib --tests -- -D warnings all pass.

  • I have manually tested my changes locally

Before changes, this would repro the oz run being marked canceled by user. After changes, it's failed with error message:
Screenshot 2026-06-29 at 5 46 09 PM
Screenshot 2026-06-29 at 5 46 15 PM

Agent Mode

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

Oz conversation

Plans:

CHANGELOG-BUG-FIX: Fixed local Oz/ambient agent runs reporting "Cancelled by user" when an agent-issued command exited the shell; the run now reports as failed with an explanation.

Co-Authored-By: Oz oz-agent@warp.dev

@cla-bot cla-bot Bot added the cla-signed label Jun 30, 2026
@oz-for-oss

oz-for-oss Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

@seemeroland

I'm starting a first review of this pull request.

You can view the conversation on Warp.

I completed the review and no human review was requested for this pull request.

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

@oz-for-oss oz-for-oss Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overview

This PR changes Oz/local ambient agent failure handling so shell exits during an in-flight run are reported as failed with a structured error instead of cancelled by user, and refactors cancellation/status plumbing around that behavior. No approved spec context was available for implementation-vs-spec validation, and I did not find a concrete security concern in the supplied diff.

Concerns

  • For this user-facing behavioral change, please include screenshots or a screen recording demonstrating the shell-exit failure state end to end. The PR description notes manual reproduction, but repository review guidance requires visual evidence for user-visible behavior changes.

Verdict

Found: 0 critical, 1 important, 0 suggestions

Request changes

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

@seemeroland seemeroland requested a review from dmichelin June 30, 2026 01:43
if !reason.should_preserve_in_progress_status() {
if matches!(
reason.conversation_outcome(),
CancellationOutcome::Cancelled

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@advait-m Did some refactoring so the cancellation reason maps to expected conversation statuses, so optimistic cli subagent cancellation can't result in canceled status here (also renamed that reason to be clearer it's only for inline agent view)

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