The cross-harness, self-improving memory layer for AI agents. Join our community: https://discord.com/invite/zdNChS2fBu
Go agent-ai-cliagent-harnessesagent-securitybrowser-extensionciclaude-codecloudcodexcursordetection-engineeringjevknowledge-basememorymobile-device-managementobservabilitysecuritysecurity-information-and-event-managementsecurity-toolstelemetrytraces
fix(qwen): keep raw.qwen on the file-edit path
Justin1f4bf5d5e1c6
diff --git a/cli/beacon-hooks/cmd/post_tool.go b/cli/beacon-hooks/cmd/post_tool.goindex 200e25e6..a7e912aa 100644--- a/cli/beacon-hooks/cmd/post_tool.go+++ b/cli/beacon-hooks/cmd/post_tool.go@@ -226,6 +226,20 @@ func recordLocalEdit(params *evaluationParams, input map[string]interface{}, logfields["session"] = mergeNested(fields["session"], map[string]interface{}{"id": params.sessionID})}applyWorkspaceFields(fields, input, filepath.Dir(params.filePath))+ // This path writes its event directly rather than through emitHookEvent, so the raw payload+ // that function attaches never reaches it. For Qwen that gap lands on exactly the events this+ // runtime's taxonomy exists to produce: a successful `write_file` or `edit` is classified+ // `file.modified` and routed here, so `permission_mode` and `tool_use_id` -- which have no+ // schema field, and whose only home is raw.qwen -- would survive on failed and non-edit tools+ // and vanish on the successful edits.+ //+ // Scoped to qwen rather than applied to every runtime with a raw convention. grok, hermes and+ // vscode have the same gap on this path, and closing it would change their recorded event shape+ // with no fixture here to say what it should become; that is a stated limit rather than a+ // silent one. TestQwenRawPayloadSurvivesTheFileEditPath is what holds the Qwen half.+ if platformFlag == "qwen" {+ fields["raw"] = mergeNested(fields["raw"], map[string]interface{}{"qwen": input})+ }logger.EndpointEvent("file.modified", "file", "info", "File edit observed", fields)}diff --git a/cli/beacon-hooks/cmd/qwen_event_test.go b/cli/beacon-hooks/cmd/qwen_event_test.goindex 331e3917..5711e03f 100644--- a/cli/beacon-hooks/cmd/qwen_event_test.go+++ b/cli/beacon-hooks/cmd/qwen_event_test.go@@ -421,3 +421,39 @@ func TestQwenSessionLifecycleIsRecorded(t *testing.T) {t.Fatalf("last event after session-end = %q, want the log left intact", got)}}++// The diff path writes its event directly rather than through emitHookEvent, so the raw payload+// that function attaches does not reach it.+//+// That gap lands on exactly the events this runtime's taxonomy exists to produce. A successful+// `write_file` or `edit` is classified `file.modified` and routed through recordLocalEdit, so+// without an explicit attachment there, `permission_mode` and `tool_use_id` -- which have no schema+// field and whose only home is raw.qwen -- survive on failed and non-edit tools and vanish on the+// successful edits. TestQwenRawPayloadPreservesFieldsWithNoSchemaHome does not catch it because it+// exercises the pre-tool path, which does go through emitHookEvent.+func TestQwenRawPayloadSurvivesTheFileEditPath(t *testing.T) {+ logPath := setupQwenHook(t)++ for _, fixture := range []string{"post_tool_write_file.json", "post_tool_edit.json"} {+ t.Run(fixture, func(t *testing.T) {+ runHookWithInput(t, runPostTool, readQwenFixture(t, fixture))+ event := lastEndpointEvent(t, logPath)+ if got := qwenAction(t, event); got != "file.modified" {+ t.Fatalf("event.action = %q, want file.modified", got)+ }+ raw, ok := event["raw"].(map[string]interface{})+ if !ok {+ t.Fatalf("file.modified event has no raw object: %#v", event)+ }+ payload, ok := raw["qwen"].(map[string]interface{})+ if !ok {+ t.Fatalf("file.modified event has no raw.qwen payload: %#v", raw)+ }+ for _, key := range []string{"permission_mode", "tool_use_id", "hook_event_name"} {+ if payload[key] == nil || payload[key] == "" {+ t.Errorf("raw.qwen on a file edit is missing %s: %#v", key, payload)+ }+ }+ })+ }+}