Report Oz run failure instead of "Cancelled by user" when the agent's command exits the shell#13210
Report Oz run failure instead of "Cancelled by user" when the agent's command exits the shell#13210seemeroland wants to merge 6 commits into
Conversation
|
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 Powered by Oz |
There was a problem hiding this comment.
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
| if !reason.should_preserve_in_progress_status() { | ||
| if matches!( | ||
| reason.conversation_outcome(), | ||
| CancellationOutcome::Cancelled |
There was a problem hiding this comment.
@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)
Description
When an agent-issued command caused the shell process to exit mid-run (e.g. it ran
exit, or a failing command afterset -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 aManuallyCancelledreason, 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:
RenderableAIError::AgentExitedShellandCancellationReason::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 terminalErrorcarrying the structured error) so the run reports FAILED with a message instead of "Cancelled by user".should_preserve_in_progress_statusboolean withCancellationReason::conversation_outcome()→CancellationOutcome { KeepInProgress, Succeeded, Cancelled, FinalizedExternally }, mapped exhaustively (no wildcard). This also fixes an optimistic-completion case that could land onCancelledinstead ofSuccess.status_error_message: Option<String>withstatus_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. AddedRenderableAIError::other(message, is_user_error); the sites that set anErrorfrom a bare string (child-launch and skill-resolution failures, cloud-modeFailed) 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:AgentExitedShelland an out-of-bandstatus_errorclassify as FAILED (InvalidRequest); anis_user_error: falseOtherclassifies as ERROR; end-to-end-via-setter coverage.CancellationReason::conversation_outcome()mapping + an optimistic-completion regression test (in-flight stream endsSuccess, notCancelled).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, andcargo clippy -p warp --lib --tests -- -D warningsall 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:


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