Add StopFailure hook#73
Conversation
harryalbert
left a comment
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
approving to unblock but +1 to Harry's version bump suggestion
|
@harryalbert @liliwilson Do you know if I should update |
|
You don't need to update |
## 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"} ```
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/warpSend a query, see a log in warp