Skip to content

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

fix: prevent known dsh tools from falling through to generic classifier and fix uninstall with mixed hooks file

Cursor Agent89b6d15e4067
diff --git a/cli/beacon-hooks/cmd/dsh.go b/cli/beacon-hooks/cmd/dsh.go
index 754b8133..689cd623 100644
--- a/cli/beacon-hooks/cmd/dsh.go
+++ b/cli/beacon-hooks/cmd/dsh.go
@@ -367,10 +367,11 @@ func dshToolAction(toolName string, toolInput map[string]interface{}) string {
case dshToolShell:
return "command.executed"
default:
- // A known tool with no filesystem or shell meaning. "" hands it to the shared classifier,
- // whose tool.invoked fallback is the right answer -- and which is also where an
- // MCP-flavored name would still be caught if one reached here.
- return ""
+ // A known tool with no filesystem or shell meaning. Returned directly rather than as ""
+ // so the generic substring classifier never sees the name: tools like terminal_read and
+ // read_mcp_resource contain substrings the classifier matches on, and "" is the signal
+ // for unknown tools that should fall through.
+ return "tool.invoked"
}
}
diff --git a/cli/beacon-hooks/cmd/dsh_hooks_test.go b/cli/beacon-hooks/cmd/dsh_hooks_test.go
index 366de50d..fed498f0 100644
--- a/cli/beacon-hooks/cmd/dsh_hooks_test.go
+++ b/cli/beacon-hooks/cmd/dsh_hooks_test.go
@@ -227,7 +227,11 @@ func TestDshToolActions(t *testing.T) {
// executes a TypeScript program, and it is `other` because command.command is a shell command line
// and a TypeScript program in that field would match shell rules on its comments while matching
// none of them on what it does.
-func TestDshNonFilesystemToolsFallThroughToToolInvoked(t *testing.T) {
+//
+// These must return "tool.invoked" directly rather than "" so the generic substring classifier
+// never sees them: "" is the signal for unknown tools, and names like terminal_read match the
+// generic classifier's substring rules for shell execution.
+func TestDshNonFilesystemToolsReturnToolInvoked(t *testing.T) {
for _, toolName := range []string{
"terminal_read", "terminal_list", "terminal_open", "terminal_close", "terminal_signal",
"read_mcp_resource", "list_mcp_resources", "session_event_read", "session_search",
@@ -235,9 +239,9 @@ func TestDshNonFilesystemToolsFallThroughToToolInvoked(t *testing.T) {
"send_message", "spawn_teammate", "subagent", "todo_write", "skill", "lsp", "workflow",
} {
t.Run(toolName, func(t *testing.T) {
- if got := dshToolAction(toolName, nil); got != "" {
- t.Fatalf("dshToolAction(%q) = %q; a tool with no filesystem or shell meaning must "+
- "fall through to the shared classifier", toolName, got)
+ if got := dshToolAction(toolName, nil); got != "tool.invoked" {
+ t.Fatalf("dshToolAction(%q) = %q, want tool.invoked so the generic substring "+
+ "classifier never sees the name", toolName, got)
}
if got := dshFileOperation(toolName, nil); got != "" {
t.Fatalf("dshFileOperation(%q) = %q, want no file operation", toolName, got)
diff --git a/cli/beacon-hooks/cmd/endpoint_events.go b/cli/beacon-hooks/cmd/endpoint_events.go
index 0788df65..29a41db4 100644
--- a/cli/beacon-hooks/cmd/endpoint_events.go
+++ b/cli/beacon-hooks/cmd/endpoint_events.go
@@ -788,6 +788,9 @@ func fileOperation(toolName string, toolInput map[string]interface{}) string {
if operation := dshFileOperation(toolName, toolInput); operation != "" {
return operation
}
+ if _, known := dshToolKindFor(toolName); known {
+ return ""
+ }
}
lower := strings.ToLower(toolName)
switch {
diff --git a/cli/beacon/internal/endpoint/hooks/dsh.go b/cli/beacon/internal/endpoint/hooks/dsh.go
index 1368c3e4..cf1ff5be 100644
--- a/cli/beacon/internal/endpoint/hooks/dsh.go
+++ b/cli/beacon/internal/endpoint/hooks/dsh.go
@@ -284,7 +284,10 @@ func removeDshHooks(path string) (bool, error) {
return patchRemoved, nil
}
if err := dshHookFileIsBeacons(path); err != nil {
- return patchRemoved, err
+ // The file contains a hook Beacon did not write. Leave it: the mount is already
+ // removed, so the bridge will no longer load this file. Returning an error here
+ // would report failure after the patch entry was already gone.
+ return patchRemoved, nil
}
if err := os.Remove(path); err != nil {
return patchRemoved, err