Skip to content

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

fix: classify OpenCode search tools as reads

Cursor Agent08f109eeb893
diff --git a/cli/beacon-hooks/cmd/opencode_event.go b/cli/beacon-hooks/cmd/opencode_event.go
index 12970c1c..8f8a33ee 100644
--- a/cli/beacon-hooks/cmd/opencode_event.go
+++ b/cli/beacon-hooks/cmd/opencode_event.go
@@ -317,9 +317,16 @@ func opencodeToolFields(input map[string]interface{}, completed bool) map[string
}
if path := opencodeToolPath(toolInput); path != "" {
+ operation := fileOperation(toolName)
+ if operation == "" {
+ lower := strings.ToLower(toolName)
+ if strings.Contains(lower, "glob") || strings.Contains(lower, "grep") || strings.Contains(lower, "search") {
+ operation = "read"
+ }
+ }
fields["file"] = map[string]interface{}{
"path": path,
- "operation": fileOperation(toolName),
+ "operation": operation,
"language": strings.TrimPrefix(filepath.Ext(path), "."),
}
fields["tool"] = mergeNested(fields["tool"], map[string]interface{}{"name": toolName, "path": path})
@@ -398,12 +405,14 @@ func opencodeDecision(input map[string]interface{}) string {
func opencodeToolAction(input map[string]interface{}) (string, string) {
name := strings.ToLower(opencodeToolName(input))
+ toolInput := opencodeMap(input, "tool_input", "toolInput")
switch {
case strings.Contains(name, "mcp") || strings.HasPrefix(name, "list_mcp_") || strings.HasPrefix(name, "read_mcp_"):
return "mcp.tool_invoked", "mcp"
case name == "bash" || strings.Contains(name, "shell") || strings.Contains(name, "terminal"):
return "command.executed", "command"
- case strings.Contains(name, "read"):
+ case strings.Contains(name, "read") ||
+ ((strings.Contains(name, "glob") || strings.Contains(name, "grep") || strings.Contains(name, "search")) && opencodeToolPath(toolInput) != ""):
return "file.read", "file"
case strings.Contains(name, "edit") || strings.Contains(name, "write") || strings.Contains(name, "patch"):
return "file.modified", "file"
diff --git a/cli/beacon-hooks/cmd/opencode_event_test.go b/cli/beacon-hooks/cmd/opencode_event_test.go
index e3ed1bbd..f962f86e 100644
--- a/cli/beacon-hooks/cmd/opencode_event_test.go
+++ b/cli/beacon-hooks/cmd/opencode_event_test.go
@@ -377,7 +377,7 @@ func TestOpenCodeTidyPlanetTraceReplay(t *testing.T) {
want := []string{
"prompt.submitted", "prompt.submitted",
"tool.invoked", "file.read",
- "tool.invoked", "tool.completed",
+ "tool.invoked", "file.read",
"prompt.submitted", "tool.invoked", "tool.completed",
"prompt.submitted", "tool.invoked", "file.modified",
"prompt.submitted", "tool.invoked", "command.executed",