Skip to content

Add StopFailure hook#73

Merged
seemeroland merged 3 commits into
mainfrom
roland/add-stop-failure-hook
Jul 16, 2026
Merged

Add StopFailure hook#73
seemeroland merged 3 commits into
mainfrom
roland/add-stop-failure-hook

Conversation

@seemeroland

@seemeroland seemeroland commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Resolves https://linear.app/warpdotdev/issue/REMOTE-1997/oz-shows-claude-code-run-as-running-after-anthropic-api-500-error

Claude code has a hook on failures that warp can use. See https://code.claude.com/docs/en/hooks#stopfailure

This extracts the error and last_assistant_message fields

Testing

Tested locally with warpdotdev/warp#13784

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/warp

Send a query, see a log in warp

12:45:03.758 [INFO] [warp::terminal::model::ansi] Received OSC 777 notification: title=Some("warp://cli-agent"), body={"v":1,"agent":"claude","event":"stop_failure","session_id":"8c574469-befe-4e9a-802a-6e3350ab2f5a","cwd":"/Users/rolandhuang","project":"rolandhuang","query":"here is another test","response":"There's an issue with the selected model (claude-4-8-opus-high). It may not exist or you may not have access to it. Run /model to pick a different model.","error_type":"model_not_found","transcript_path":"/Users/rolandhuang/.claude/projects/-Users-rolandhuang/8c574469-befe-4e9a-802a-6e3350ab2f5a.jsonl"}

@seemeroland
seemeroland marked this pull request as ready for review July 15, 2026 19:51

@harryalbert harryalbert 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.

We should probably also bump the advertised version for the plugin to 2.2.0 (version lives in plugins/warp/.claude-plugin/plugin.json and .claude-plugin/marketplace.json). This will allow Warp to encourage users to update to this plugin version, which seems worthwhile given the new hook/state

@liliwilson liliwilson 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.

approving to unblock but +1 to Harry's version bump suggestion

@seemeroland

Copy link
Copy Markdown
Contributor Author

@harryalbert @liliwilson Do you know if I should update oz-harness-support hooks and version as well? The main purpose of this change is so that the oz run using claude code gets updated to failed if claude code encounters a failure. Which plugin is installed?

@liliwilson

Copy link
Copy Markdown
Contributor

You don't need to update oz-harness-support - just warp. We use warp for lifecycle events and notifications, which this one is. We install both plugins when using cloud agents

seemeroland added a commit to warpdotdev/warp that referenced this pull request Jul 16, 2026
## 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 for `runtime_error_patterns` will be suppressed.
In the event that `runtime_error_patterns` scanning happens first, we'll
end up with a duplicate task status update from the hook which is okay.

## Testing

- [x] I have manually tested my changes locally with `./script/run`

Tested 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/warp`

Send a query, see a log in warp
```
12:45:03.758 [INFO] [warp::terminal::model::ansi] Received OSC 777 notification: title=Some("warp://cli-agent"), body={"v":1,"agent":"claude","event":"stop_failure","session_id":"8c574469-befe-4e9a-802a-6e3350ab2f5a","cwd":"/Users/rolandhuang","project":"rolandhuang","query":"here is another test","response":"There's an issue with the selected model (claude-4-8-opus-high). It may not exist or you may not have access to it. Run /model to pick a different model.","error_type":"model_not_found","transcript_path":"/Users/rolandhuang/.claude/projects/-Users-rolandhuang/8c574469-befe-4e9a-802a-6e3350ab2f5a.jsonl"}
```
@seemeroland
seemeroland merged commit e0e18e1 into main Jul 16, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants