Skip to content

The cross-harness, self-improving memory layer for AI agents. Join our community: https://discord.com/invite/zdNChS2fBu

fix: classify Qwen interrupted tools as failures in emitPostToolObserved

Cursor Agent61bd1ba2a6f9
diff --git a/cli/beacon-hooks/cmd/post_tool.go b/cli/beacon-hooks/cmd/post_tool.go
index a7e912aa..b34a6789 100644
--- a/cli/beacon-hooks/cmd/post_tool.go
+++ b/cli/beacon-hooks/cmd/post_tool.go
@@ -339,6 +339,12 @@ func emitPostToolObserved(logger *logging.Logger, input map[string]interface{})
emitHookEvent(logger, "tool.failed", "tool", "high", "Tool execution failed", input, fields)
return
}
+ if platformFlag == "qwen" {
+ if interrupted, _ := input["is_interrupt"].(bool); interrupted {
+ emitHookEvent(logger, "tool.failed", "tool", "high", "Tool execution failed", input, fields)
+ return
+ }
+ }
action := actionForTool(hookEvent, toolName)
category := "tool"
if strings.HasPrefix(action, "file.") {
diff --git a/cli/beacon-hooks/cmd/qwen_event_test.go b/cli/beacon-hooks/cmd/qwen_event_test.go
index 5711e03f..efe13001 100644
--- a/cli/beacon-hooks/cmd/qwen_event_test.go
+++ b/cli/beacon-hooks/cmd/qwen_event_test.go
@@ -146,6 +146,23 @@ func TestQwenFailedToolIsNotRecordedAsASuccessfulEdit(t *testing.T) {
}
}
+// An interrupt with an empty error and a PostToolUse hook event must still be recorded as a
+// failure. Without this, the Qwen taxonomy maps write_file to file.modified even though the tool
+// was interrupted and the write never landed.
+func TestQwenInterruptedToolIsNotRecordedAsASuccessfulEdit(t *testing.T) {
+ logPath := setupQwenHook(t)
+
+ runHookWithInput(t, runPostTool, readQwenFixture(t, "post_tool_interrupt.json"))
+
+ event := lastEndpointEvent(t, logPath)
+ if got := qwenAction(t, event); got != "tool.failed" {
+ t.Fatalf("event.action = %q, want tool.failed for an interrupted tool", got)
+ }
+ if got := event["severity"]; got != "high" {
+ t.Fatalf("severity = %q, want high", got)
+ }
+}
+
// A shell command has to reach the `command` field, not just `tool.name`: every command rule,
// dashboard column and threat-rule match reads it from there.
func TestQwenShellCommandIsRecordedAsACommand(t *testing.T) {
diff --git a/cli/beacon-hooks/testdata/qwen/post_tool_interrupt.json b/cli/beacon-hooks/testdata/qwen/post_tool_interrupt.json
new file mode 100644
index 00000000..63619247
--- /dev/null
+++ b/cli/beacon-hooks/testdata/qwen/post_tool_interrupt.json
@@ -0,0 +1,16 @@
+{
+ "session_id": "qwen-8f21c4a0",
+ "transcript_path": "/Users/example/.qwen/tmp/qwen-8f21c4a0/chat.json",
+ "cwd": "/Users/example/projects/beacon-demo",
+ "hook_event_name": "PostToolUse",
+ "timestamp": "2026-08-21T10:15:40.000Z",
+ "permission_mode": "default",
+ "tool_name": "write_file",
+ "tool_use_id": "toolu_01QwenIntr",
+ "tool_input": {
+ "file_path": "/Users/example/projects/beacon-demo/src/health.ts",
+ "content": "export const health = true\n"
+ },
+ "error": "",
+ "is_interrupt": true
+}