Handle claude code StopFailure hook#13784
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 adds Claude Code stop_failure event parsing, introduces a CLI session Failed state, maps that state into task updates, and suppresses duplicate runtime-pattern failures when the plugin reports failure first.
Concerns
StopFailuredoes not persist the failed turn's query/response intosession_context, so user-facing notifications and conversation surfaces that read context can show fallback or empty details despite the event including the data.- The task-state mapping leaves user-actionable Claude Code request failures such as
model_not_found,invalid_request, andmax_output_tokensclassified asError, including the invalid-model scenario described in this PR. - For this user-facing status/notification change, please include screenshots or a screen recording demonstrating the failed Claude Code run moving to the expected failed/error state end to end.
Verdict
Found: 0 critical, 3 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
| let task_state = match error_type.as_deref() { | ||
| Some("authentication_failed" | "oauth_org_not_allowed" | "billing_error") => { | ||
| AgentTaskState::Failed | ||
| } | ||
| _ => AgentTaskState::Error, | ||
| }; |
There was a problem hiding this comment.
Failed; with the current _ arm, the invalid-model case from the PR description reports as a provider/Warp Error instead of a user-fixable failure.
| let task_state = match error_type.as_deref() { | |
| Some("authentication_failed" | "oauth_org_not_allowed" | "billing_error") => { | |
| AgentTaskState::Failed | |
| } | |
| _ => AgentTaskState::Error, | |
| }; | |
| let task_state = match error_type.as_deref() { | |
| Some( | |
| "authentication_failed" | |
| | "oauth_org_not_allowed" | |
| | "billing_error" | |
| | "invalid_request" | |
| | "model_not_found" | |
| | "max_output_tokens", | |
| ) => AgentTaskState::Failed, | |
| _ => AgentTaskState::Error, | |
| }; |
There was a problem hiding this comment.
This list is intentional. The other error categories mean warp configured something incorrectly
| "could not be refreshed", | ||
| // Generically check for invalid request errors. | ||
| // Keep this last so more specific patterns can be matched first. | ||
| "\"type\": \"invalid_request_error\"", |
There was a problem hiding this comment.
Codex doesn't have an equivalent hook. We add this runtime pattern match to fix this run not properly being marked as errored https://oz.staging.warp.dev/runs/019f6324-bb99-70fa-aa53-d200dd806dca
|
/oz-review |
|
I'm re-reviewing this pull request in response to a review 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 adds support for Claude Code StopFailure hook events by parsing stop_failure, introducing a failed CLI session status, updating notifications, suppressing duplicate runtime-pattern failures, and syncing terminal task state as failed or errored.
Concerns
model_not_foundis classified asERROR, but the PR’s own test case uses an invalid selected model and Claude Code documents that as a request/configuration error. That will mark a user-actionable model selection problem as a system/provider error instead of a failed task.- This is a user-facing behavior change: it changes the displayed Oz task status and failure notification flow. For this user-facing change, please include screenshots or a screen recording demonstrating it working end to end.
- No security findings.
- No approved or repository spec context was provided, so there is no spec drift to report.
Verdict
Found: 0 critical, 2 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
| let task_state = match error_type.as_deref() { | ||
| Some("authentication_failed" | "oauth_org_not_allowed" | "billing_error") => { | ||
| AgentTaskState::Failed | ||
| } | ||
| _ => AgentTaskState::Error, | ||
| }; |
There was a problem hiding this comment.
model_not_found is a user-actionable bad model selection (the PR’s testing reproduces this with an invalid ANTHROPIC_MODEL), so mapping it through _ => Error misclassifies the task as a system/provider error.
| let task_state = match error_type.as_deref() { | |
| Some("authentication_failed" | "oauth_org_not_allowed" | "billing_error") => { | |
| AgentTaskState::Failed | |
| } | |
| _ => AgentTaskState::Error, | |
| }; | |
| let task_state = match error_type.as_deref() { | |
| Some( | |
| "authentication_failed" | |
| | "oauth_org_not_allowed" | |
| | "billing_error" | |
| | "model_not_found", | |
| ) => AgentTaskState::Failed, | |
| _ => AgentTaskState::Error, | |
| }; |
There was a problem hiding this comment.
This is incorrect. Warp is responsible for setting the model and validating it before starting the worker
liliwilson
left a comment
There was a problem hiding this comment.
Nice, really awesome that claude supports this
Description
Resolves https://linear.app/warpdotdev/issue/REMOTE-1997/oz-shows-claude-code-run-as-running-after-anthropic-api-500-error
Handle the StopFailure hook from Claude Code. We use the error type to map to Failed or Error status.
There is technically a race between this and scanning for
runtime_error_patterns. But most of the time this will win since it's instant, and the scan forruntime_error_patternswill be suppressed. In the event thatruntime_error_patternsscanning happens first, we'll end up with a duplicate task status update from the hook which is okay.Testing
./script/runTested locally with warpdotdev/claude-code-warp#73
Run claude code with invalid model and using local plugin build:
ANTHROPIC_MODEL=claude-4-8-opus-high claude --plugin-dir ~/claude-code-warp/plugins/warpSend a query, see a log in warp