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(omp): record files under the paths omp resolved; join MCP calls by call id
Kyle Elliott331bea6a922e
diff --git a/cli/beacon-hooks/cmd/omp_paths_test.go b/cli/beacon-hooks/cmd/omp_paths_test.gonew file mode 100644index 00000000..dd5f4897--- /dev/null+++ b/cli/beacon-hooks/cmd/omp_paths_test.go@@ -0,0 +1,145 @@+package cmd++import (+ "os"+ "path/filepath"+ "reflect"+ "testing"+)++func ompFileOf(t *testing.T, events []normalizedEvent) map[string]interface{} {+ t.Helper()+ if len(events) != 1 {+ t.Fatalf("produced %d events, want 1", len(events))+ }+ file, ok := events[0].fields["file"].(map[string]interface{})+ if !ok {+ t.Fatalf("%s has no file block: %v", events[0].action, events[0].fields)+ }+ return file+}++// A result names the file the runtime actually touched, and that is the path recorded: absolute,+// with the selector and `~` the model wrote already resolved by the runtime. tool.path keeps what+// was written.+func TestOmpResultRecordsTheFileTheRuntimeResolved(t *testing.T) {+ for _, tc := range []struct {+ tool, target string+ details map[string]interface{}+ want string+ }{+ {"read", ".env:1-20", map[string]interface{}{"meta": map[string]interface{}{+ "source": map[string]interface{}{"type": "path", "value": "/repo/.env"},+ }}, "/repo/.env"},+ {"write", "notes.md", map[string]interface{}{"resolvedPath": "/repo/notes.md"}, "/repo/notes.md"},+ {"edit", "main.go", map[string]interface{}{"path": "/repo/main.go", "diff": "-a\n+b"}, "/repo/main.go"},+ } {+ t.Run(tc.tool, func(t *testing.T) {+ events := ompRuntime.endpointEvents(map[string]interface{}{+ "type": "tool_result", "toolName": tc.tool, "cwd": "/elsewhere",+ "input": map[string]interface{}{"path": tc.target}, "details": tc.details,+ }, "sess-1")+ if file := ompFileOf(t, events); file["path"] != tc.want {+ t.Fatalf("file.path = %v, want %s", file["path"], tc.want)+ }+ if tool, _ := events[0].fields["tool"].(map[string]interface{}); tool["path"] != tc.target {+ t.Fatalf("tool.path = %v, want %s as written", tool["path"], tc.target)+ }+ })+ }+}++// Before the call runs, and on the approval for it, only the path as written exists. It is resolved+// the way the runtime will resolve it, so the approval rules -- which anchor their patterns at the+// end of the name -- see `/repo/.env` rather than `.env:1-20`.+func TestOmpPathAsWrittenIsResolvedTheWayTheRuntimeWill(t *testing.T) {+ home := t.TempDir()+ t.Setenv("HOME", home)+ cwd := t.TempDir()+ // A file whose real name looks like a selector is kept whole, as the runtime keeps it.+ if err := os.WriteFile(filepath.Join(cwd, "report:2024"), nil, 0o600); err != nil {+ t.Fatal(err)+ }++ for _, tc := range []struct{ target, want string }{+ {".env:1-20", filepath.Join(cwd, ".env")},+ {"src/a.go:5-16,960-973", filepath.Join(cwd, "src/a.go")},+ {"notes.md:1-50:raw", filepath.Join(cwd, "notes.md")},+ {"log.txt:-60", filepath.Join(cwd, "log.txt")},+ {"~/.ssh/id_rsa:raw", filepath.Join(home, ".ssh/id_rsa")},+ {"/etc/hosts", "/etc/hosts"},+ {"report:2024", filepath.Join(cwd, "report:2024")},+ // Not selector grammar: a range may not end in `+`.+ {"a.go:12+", filepath.Join(cwd, "a.go:12+")},+ } {+ t.Run(tc.target, func(t *testing.T) {+ for _, typ := range []string{"tool_call", "tool_approval_requested"} {+ events := ompRuntime.endpointEvents(map[string]interface{}{+ "type": typ, "toolName": "read", "toolCallId": "call-1", "cwd": cwd,+ "input": map[string]interface{}{"path": tc.target},+ }, "sess-1")+ if file := ompFileOf(t, events); file["path"] != tc.want {+ t.Fatalf("%s file.path = %v, want %s", typ, file["path"], tc.want)+ }+ }+ })+ }+}++// Oh My Pi's default edit format can change several files in one call. Its result names no single+// path, so each changed file is recorded as its own file.modified, keeping the edit's operation.+func TestOmpMultiFileEditRecordsEachFile(t *testing.T) {+ events := ompRuntime.endpointEvents(map[string]interface{}{+ "type": "tool_result", "toolName": "edit", "toolCallId": "call-1",+ "input": map[string]interface{}{"input": "[a.go#1A2B]\n…", "paths": []interface{}{"a.go", "b.go"}},+ "details": map[string]interface{}{+ "diff": "a-diff\nb-diff",+ "perFileResults": []interface{}{+ map[string]interface{}{"path": "/repo/a.go", "diff": "a-diff", "op": "update"},+ map[string]interface{}{"path": "/repo/b.go", "diff": "b-diff", "op": "create"},+ },+ },+ }, "sess-1")++ var got [][3]string+ for _, event := range events {+ file, _ := event.fields["file"].(map[string]interface{})+ path, _ := file["path"].(string)+ operation, _ := file["operation"].(string)+ got = append(got, [3]string{event.action, path, operation})+ }+ want := [][3]string{+ {"file.modified", "/repo/a.go", "modify"},+ {"file.modified", "/repo/b.go", "create"},+ }+ if !reflect.DeepEqual(got, want) {+ t.Fatalf("events = %v, want %v", got, want)+ }+}++// `read mcp://<uri>` is an MCP resources/read, recorded as the same mcp.tool_invoked other runtimes+// record for one. The runtime does not report which server served it, so no server is named.+func TestOmpMCPResourceReadIsAnMCPCall(t *testing.T) {+ for typ, action := range map[string]string{"tool_call": "tool.invoked", "tool_result": "mcp.tool_invoked"} {+ events := ompRuntime.endpointEvents(map[string]interface{}{+ "type": typ, "toolName": "read", "toolCallId": "call-1",+ "input": map[string]interface{}{"path": "mcp://ibkr://portfolio/positions"},+ "details": map[string]interface{}{"meta": map[string]interface{}{+ "source": map[string]interface{}{"type": "internal", "value": "mcp://ibkr://portfolio/positions"},+ }},+ }, "sess-1")+ if len(events) != 1 || events[0].action != action {+ t.Fatalf("%s: events = %+v, want one %s", typ, events, action)+ }+ if file, ok := events[0].fields["file"]; ok {+ t.Fatalf("%s grew a file block: %v", typ, file)+ }+ want := map[string]interface{}{+ "method": map[string]interface{}{"name": "resources/read"},+ "resource": map[string]interface{}{"uri": "ibkr://portfolio/positions"},+ }+ if mcp := events[0].fields["mcp"]; !reflect.DeepEqual(mcp, want) {+ t.Fatalf("%s mcp = %v, want %v", typ, mcp, want)+ }+ }+}diff --git a/cli/beacon-hooks/cmd/pi_family.go b/cli/beacon-hooks/cmd/pi_family.goindex 620e82d3..84a6f89e 100644--- a/cli/beacon-hooks/cmd/pi_family.go+++ b/cli/beacon-hooks/cmd/pi_family.go@@ -3,6 +3,7 @@ package cmdimport ("encoding/json""net/url"+ "os""path/filepath""regexp""strings"@@ -40,11 +41,21 @@ type piFamily struct {platform string// displayName is how the runtime is named in an event's human-readable message.displayName string+ // resolvesToolPaths marks a runtime whose read, edit and write tools take a path the way Oh+ // My Pi's do -- relative to the session's working directory or to `~`, with an inline selector+ // such as `main.go:10-40` or `notes.md:raw` -- and whose results report the absolute file they+ // resolved it to. Such a runtime's file events carry that file; see filePath.+ //+ // It is declared rather than inferred because Pi and Prime Agent are also read back from their+ // session files (pisession, primesession), which record the path as written. A hook event and+ // a session-file event for the same read are merged only when their file.path matches, so+ // resolving the path on one side alone would record each read twice.+ resolvesToolPaths bool}var (piRuntime = piFamily{platform: "pi", displayName: "Pi"}- ompRuntime = piFamily{platform: "omp", displayName: "Oh My Pi"}+ ompRuntime = piFamily{platform: "omp", displayName: "Oh My Pi", resolvesToolPaths: true}// Prime Agent's `--platform` is `prime` rather than `prime-agent` because the platform value is// also the prefix on this runtime's keys inside `raw`, and `prime_agent_session_reason` reads// as a field of a harness named `prime_agent` -- which is exactly what it is. The harness name@@ -414,6 +425,110 @@ func isURIScheme(s string) bool {return true}+// filePath returns the file a read, edit or write call touched, or "" when its target is not a+// file.+//+// On a runtime that resolves its tool paths, the runtime's own statement of the file is preferred,+// because it is the one path that is certainly right: it is absolute, and any selector or `~` in+// what the model wrote has already been resolved. A tool_call or an approval, which happen before+// the runtime has resolved anything, resolve the target the same way the runtime will.+func (f piFamily) filePath(call piToolCall, input map[string]interface{}, target string) string {+ path := piFilePath(target)+ if path == "" || !f.resolvesToolPaths {+ return path+ }+ if resolved := piResolvedPath(call.details); resolved != "" {+ return resolved+ }+ return ompToolPath(path, resolveCwd(input, f.platform))+}++// piResolvedPath returns the absolute path a tool result reports having read or written.+//+// Oh My Pi reports it in three places, one per tool: a read names its source in `meta.source`+// when the source was a file, a write names the file in `resolvedPath`, and an edit of one file+// names it in `path`. A read of anything else -- a URL, or a runtime resource backed by a file in+// the runtime's own storage -- reports a different source type and is never taken for a file.+func piResolvedPath(details map[string]interface{}) string {+ path := getFirstStr(details, "resolvedPath", "path")+ if source := firstMap(firstMap(details, "meta"), "source"); getFirstStr(source, "type") == "path" {+ path = getFirstStr(source, "value")+ }+ if !filepath.IsAbs(path) {+ return ""+ }+ return path+}++// ompLineSelector is Oh My Pi's read selector grammar, FILE_LINE_RANGE_RE in its+// packages/tui/src/tools/read.ts: comma-joined line ranges (`10`, `10-40`, `10..40`, `10+30`,+// `10-`), a tail (`-60`), or `raw`, `conflicts` or `img`. A range may not end in `+`, which is+// what the runtime's trailing lookbehind enforces.+var ompLineSelector = regexp.MustCompile(`(?i)^(?:` + ompLineRange + `(?:,` + ompLineRange + `)*|-\d+|raw|conflicts|img)$`)++const ompLineRange = `L?\d+(?:(?:\.\.|-)(?:L?\d+)?|\+L?\d+)?`++// ompToolPath turns a path as an Oh My Pi tool was given it into the file it names.+//+// Oh My Pi resolves a relative path against the session's working directory, expands `~`, and+// reads a trailing selector as a line range rather than part of the name: `read .env:1-20` reads+// the first twenty lines of `<cwd>/.env`. Recording the string as written put `.env:1-20` in+// file.path, which defeats every file rule that anchors its pattern at the end of the name -- the+// credential-read rules match `(^|/)\.env($|\.)`, not `.env:1-20` -- and filed one file under as+// many names as it was read with. Cline resolves relative paths for the same reason.+//+// The selector is peeled the way the runtime peels it: from the last colon, only when what follows+// is selector grammar, at most twice (a range and `raw` may be combined), and not at all when a+// file of that literal name exists, which is the runtime's own tiebreak.+func ompToolPath(path, cwd string) string {+ if path == "~" || strings.HasPrefix(path, "~/") || strings.HasPrefix(path, "~"+string(filepath.Separator)) {+ if home, err := os.UserHomeDir(); err == nil {+ path = filepath.Join(home, path[1:])+ }+ }+ if !filepath.IsAbs(path) && cwd != "" {+ path = filepath.Join(cwd, path)+ }+ stripped := path+ for range 2 {+ i := strings.LastIndexByte(stripped, ':')+ if i <= 0 || !ompLineSelector.MatchString(stripped[i+1:]) {+ break+ }+ stripped = stripped[:i]+ }+ if stripped == path {+ return path+ }+ if _, err := os.Lstat(path); err == nil {+ return path+ }+ return stripped+}++// ompMCPResourceScheme is the URI scheme through which Oh My Pi's read tool reads an MCP resource:+// `read mcp://<resource-uri>` asks whichever connected server lists that resource.+const ompMCPResourceScheme = "mcp://"++// ompMCPResourceURI returns the resource URI a `read mcp://<uri>` call asks for, or "".+//+// Such a read is an MCP resources/read, and is recorded as one: the same mcp.tool_invoked other+// runtimes record for a resource read, with the URI in mcp.resource.uri. The server cannot be+// named. The runtime picks it by matching the URI against every connected server and reports the+// choice only in a note its read tool discards. The runtime also sends a resource URI whose scheme+// it does not handle itself to MCP, but telling those apart from its own schemes would mean+// copying its scheme registry, so only the explicit `mcp://` form is recognized.+func ompMCPResourceURI(call piToolCall) string {+ if !strings.EqualFold(call.name, "read") {+ return ""+ }+ target := getFirstStr(call.args, "path")+ if len(target) <= len(ompMCPResourceScheme) || !strings.EqualFold(target[:len(ompMCPResourceScheme)], ompMCPResourceScheme) {+ return ""+ }+ return target[len(ompMCPResourceScheme):]+}+// toolFields builds the tool, command, and file blocks for one Pi-family tool event.//// The built-in tools have fixed, documented argument shapes -- bash takes `command`, and read,@@ -451,11 +566,11 @@ func (f piFamily) toolFields(call piToolCall, input map[string]interface{}, withfields["content"] = retainedContentFields(code)}case "read", "edit", "write":- // tool.path keeps the target as the tool was given it, URI or not, so the row still says- // what was read; only a filesystem target becomes a file block.+ // tool.path keeps the target as the tool was given it, URI and selector included, so the+ // row still says what was asked for; only a file becomes a file block, under its real path.if target := getFirstStr(args, "path"); target != "" {tool["path"] = target- if path := piFilePath(target); path != "" {+ if path := f.filePath(call, input, target); path != "" {fields["file"] = map[string]interface{}{"path": path,"operation": piFileOperation(name),@@ -463,6 +578,12 @@ func (f piFamily) toolFields(call piToolCall, input map[string]interface{}, with}}}+ if uri := ompMCPResourceURI(call); uri != "" {+ fields["mcp"] = map[string]interface{}{+ "method": map[string]interface{}{"name": "resources/read"},+ "resource": map[string]interface{}{"uri": uri},+ }+ }}if len(tool) > 0 {@@ -568,6 +689,10 @@ func (f piFamily) toolResultEvents(input map[string]interface{}, fields map[strireturn append(f.one("tool.failed", "tool", "high", "tool failed", fields), kernelWrites...)}+ if edits := f.perFileEditEvents(call, fields); len(edits) > 0 {+ return append(edits, kernelWrites...)+ }+if diff := piEditDiff(call.details); diff != "" {fields["content"] = retainedContentFields(diff)}@@ -754,12 +879,69 @@ func piEditDiff(details map[string]interface{}) string {return getFirstStr(details, "patch", "diff")}+// perFileEditEvents records an edit that changed several files as one file.modified per file.+//+// Oh My Pi's default edit format applies one patch to any number of files. An edit of one file+// reports that file's path; an edit of several reports no path at all, only a perFileResults list.+// Without this, such an edit fell through to tool.completed and none of the files it changed was+// recorded. One event per changed file is the shape pythonDiffEvents produces for a Prime Agent+// cell and the OpenHands mapper produces for one apply_patch call: a store that files one row per+// path is the one a "who touched this file" query can answer.+//+// Each file keeps the edit's own operation word, so a file the edit created or deleted reads as+// one, while the action stays in the file.modified family as a single-file edit's does.+func (f piFamily) perFileEditEvents(call piToolCall, fields map[string]interface{}) []normalizedEvent {+ if !strings.EqualFold(call.name, "edit") {+ return nil+ }+ results, _ := call.details["perFileResults"].([]interface{})+ var events []normalizedEvent+ for _, item := range results {+ entry, ok := item.(map[string]interface{})+ if !ok {+ continue+ }+ path := getFirstStr(entry, "path")+ if !filepath.IsAbs(path) {+ continue+ }+ values := cloneFields(fields)+ values["file"] = map[string]interface{}{+ "path": path,+ "operation": ompEditOperation(getFirstStr(entry, "op")),+ "language": strings.TrimPrefix(filepath.Ext(path), "."),+ }+ delete(values, "content")+ if diff := piEditDiff(entry); diff != "" {+ values["content"] = retainedContentFields(diff)+ }+ events = append(events, f.one("file.modified", "file", "info", "file modified", values)...)+ }+ return events+}++// ompEditOperation maps the operation Oh My Pi reports for one file of an edit onto the event+// schema's vocabulary.+func ompEditOperation(op string) string {+ switch strings.ToLower(op) {+ case "create":+ return "create"+ case "delete":+ return "delete"+ default:+ return "modify"+ }+}+// piToolAction maps a Pi-family tool call onto the endpoint action its completion represents.func piToolAction(call piToolCall) (string, string) {switch strings.ToLower(call.name) {case "bash", "ipython":return "command.executed", "command"case "read":+ if ompMCPResourceURI(call) != "" {+ return "mcp.tool_invoked", "mcp"+ }return "file.read", "file"case "edit":return "file.modified", "file"diff --git a/cli/beacon/internal/endpoint/dashboard/lenses/mcp.lens.html b/cli/beacon/internal/endpoint/dashboard/lenses/mcp.lens.htmlindex cf07a83e..207bbdcb 100644--- a/cli/beacon/internal/endpoint/dashboard/lenses/mcp.lens.html+++ b/cli/beacon/internal/endpoint/dashboard/lenses/mcp.lens.html@@ -77,27 +77,35 @@return typeof value === "string" ? value.trim() : "";}- // The server and tool a Claude-style name carries: mcp__<server>__<tool>, or MCP:<tool>.+ // The server and tool a Claude-style name carries: mcp__<server>__<tool>, or MCP:<tool>. Any other+ // name in the mcp__ namespace is an MCP call whose halves the name cannot tell apart -- Oh My Pi's+ // mcp__<server>_<tool> -- so it names neither, and the event that reports them, joined by+ // tool_call_id, supplies both.function fromName(name) {var text = str(name);var lower = text.toLowerCase();if (lower.indexOf("mcp__") === 0) {var parts = text.split("__");if (parts.length >= 3) return { server: parts[1], tool: parts.slice(2).join("__") };+ if (text.length > 5) return { server: "", tool: "" };}if (lower.indexOf("mcp:") === 0) return { server: "", tool: text.slice(4).trim() };return null;}- // classify returns the MCP call an event is part of, or null.+ // classify returns the MCP call an event is part of, or null. toolKnown says whether the tool is+ // the MCP tool's own name rather than the runtime's name for it, so a later event of the same call+ // that does know it can replace it.function classify(event) {var mcp = event.mcp;var named = fromName(event.tool && event.tool.name);if (!mcp && !named && event.type !== "mcp") return null;mcp = mcp || {};+ var tool = str(mcp.tool) || (named && named.tool) || "";return {server: str(mcp.server) || (named && named.server) || "",- tool: str(mcp.tool) || (named && named.tool) || str(event.tool && event.tool.name) || str(mcp.method) || "(tool not reported)",+ tool: tool || str(event.tool && event.tool.name) || str(mcp.method) || "(tool not reported)",+ toolKnown: !!tool,method: str(mcp.method),resource: str(mcp.resource_uri)};@@ -129,13 +137,17 @@var call = event.tool_call_id ? byID[event.tool_call_id] : null;if (!call) {call = {- server: found.server, tool: found.tool, method: found.method, resource: found.resource,+ server: found.server, tool: found.tool, toolKnown: found.toolKnown, method: found.method, resource: found.resource,first: event, events: [], args: undefined, result: undefined, failed: false};calls.push(call);if (event.tool_call_id) byID[event.tool_call_id] = call;}if (!call.server && found.server) call.server = found.server;+ if (!call.toolKnown && found.toolKnown) {+ call.tool = found.tool;+ call.toolKnown = true;+ }if (!call.method && found.method) call.method = found.method;if (!call.resource && found.resource) call.resource = found.resource;if (call.args === undefined && tool.arguments !== undefined && tool.arguments !== null) call.args = tool.arguments;diff --git a/cli/beacon/internal/endpoint/dashboard/testdata/lens-e2e/fixtures/runtime.jsonl b/cli/beacon/internal/endpoint/dashboard/testdata/lens-e2e/fixtures/runtime.jsonlindex d94651d7..55af5b8d 100644--- a/cli/beacon/internal/endpoint/dashboard/testdata/lens-e2e/fixtures/runtime.jsonl+++ b/cli/beacon/internal/endpoint/dashboard/testdata/lens-e2e/fixtures/runtime.jsonl@@ -42,3 +42,6 @@{"vendor": "beacon", "product": "endpoint-agent", "schema_version": "1.0", "severity": "info", "endpoint": {"os": "linux"}, "harness": {"name": "claude_code"}, "session": {"id": "mcpish", "working_directory": "/work/app"}, "timestamp": "2026-06-15T11:00:20Z", "event": {"id": "mc-bare", "kind": "agent_runtime", "action": "tool.invoked", "category": "tool"}, "message": "tool.invoked", "tool": {"name": "mcp__linear__save_issue"}, "gen_ai": {"tool": {"name": "mcp__linear__save_issue", "call": {"arguments": {"title": "Flaky TestRetry"}}}}}{"vendor": "beacon", "product": "endpoint-agent", "schema_version": "1.0", "severity": "info", "endpoint": {"os": "linux"}, "harness": {"name": "claude_code"}, "session": {"id": "mcpish", "working_directory": "/work/app"}, "timestamp": "2026-06-15T11:00:25Z", "event": {"id": "mc-read", "kind": "agent_runtime", "action": "file.read", "category": "file"}, "message": "file.read", "file": {"path": "/work/app/main.go", "operation": "read"}}{"vendor": "beacon", "product": "endpoint-agent", "schema_version": "1.0", "severity": "high", "endpoint": {"os": "linux"}, "harness": {"name": "claude_code"}, "session": {"id": "mcpish", "working_directory": "/work/app"}, "timestamp": "2026-06-15T11:00:30Z", "event": {"id": "mc-store-fail", "kind": "agent_runtime", "action": "mcp.tool_invoked", "category": "mcp"}, "message": "mcp.tool_invoked", "mcp": {"server": "linear", "tool": "list_teams"}, "tool": {"name": "mcp__linear__list_teams"}, "gen_ai": {"tool": {"name": "mcp__linear__list_teams", "call": {"id": "call-mcp-5", "result": "connection refused"}}}, "error": {"type": "tool_execution_failed"}}+{"vendor": "beacon", "product": "endpoint-agent", "schema_version": "1.0", "severity": "info", "endpoint": {"os": "darwin"}, "harness": {"name": "omp"}, "session": {"id": "ompmcp", "working_directory": "/work/app"}, "timestamp": "2026-06-16T09:00:00Z", "event": {"id": "omp-mcp-pre", "kind": "agent_runtime", "action": "tool.invoked", "category": "tool"}, "message": "Oh My Pi tool invoked", "tool": {"name": "mcp__beacon_managed_beacon_lookup"}, "gen_ai": {"tool": {"name": "mcp__beacon_managed_beacon_lookup", "call": {"id": "omp-call-1", "arguments": {"kind": "harness"}}}}}+{"vendor": "beacon", "product": "endpoint-agent", "schema_version": "1.0", "severity": "info", "endpoint": {"os": "darwin"}, "harness": {"name": "omp"}, "session": {"id": "ompmcp", "working_directory": "/work/app"}, "timestamp": "2026-06-16T09:00:01Z", "event": {"id": "omp-mcp-approval", "kind": "agent_runtime", "action": "approval.allowed", "category": "approval", "fidelity": "observed"}, "message": "Oh My Pi approval allowed", "tool": {"name": "mcp__beacon_managed_beacon_lookup"}, "approval": {"required": true, "decision": "approve"}, "gen_ai": {"tool": {"name": "mcp__beacon_managed_beacon_lookup", "call": {"id": "omp-call-1"}}}}+{"vendor": "beacon", "product": "endpoint-agent", "schema_version": "1.0", "severity": "info", "endpoint": {"os": "darwin"}, "harness": {"name": "omp"}, "session": {"id": "ompmcp", "working_directory": "/work/app"}, "timestamp": "2026-06-16T09:00:02Z", "event": {"id": "omp-mcp-post", "kind": "agent_runtime", "action": "mcp.tool_invoked", "category": "mcp"}, "message": "Oh My Pi MCP tool invoked", "mcp": {"server": "beacon-managed", "tool": "beacon_lookup"}, "tool": {"name": "mcp__beacon_managed_beacon_lookup"}, "gen_ai": {"tool": {"name": "mcp__beacon_managed_beacon_lookup", "call": {"id": "omp-call-1", "result": {"content": [{"type": "text", "text": "Found 1 harness value(s)."}]}}}}}diff --git a/cli/beacon/internal/endpoint/dashboard/testdata/lens-e2e/tests/builtin-mcp.spec.ts b/cli/beacon/internal/endpoint/dashboard/testdata/lens-e2e/tests/builtin-mcp.spec.tsindex 5d998cab..d54b0ae2 100644--- a/cli/beacon/internal/endpoint/dashboard/testdata/lens-e2e/tests/builtin-mcp.spec.ts+++ b/cli/beacon/internal/endpoint/dashboard/testdata/lens-e2e/tests/builtin-mcp.spec.ts@@ -52,6 +52,23 @@ test('mcp: calls by server and tool, with arguments, results and failures', asynawait expect(detail.locator('.call', { hasText: 'save_issue' })).not.toContainText('failed');});+test('mcp: a call whose name does not split is joined to the result that names its server', async ({ page }) => {+ // Oh My Pi's mcp__<server>_<tool> names cannot be split, so its pre-tool event and its approval+ // carry no server; the result does. All three are one call, under the server the result names,+ // with the approval decided on it.+ await page.goto('/session.html?id=ompmcp&lens=mcp');+ const frame = page.frameLocator('iframe.lens-frame');+ await expect(frame.locator('#summary')).toHaveText('1 call to 1 tool on 1 server · none failed.');+ await expect(frame.locator('#list button.row')).toHaveCount(1);+ await expect(frame.locator('#list button.row').first()).toContainText('beacon-managed');++ const call = frame.locator('#detail .call');+ await expect(call).toHaveCount(1);+ await expect(call).toContainText('beacon_lookup');+ await expect(call).not.toContainText('mcp__beacon_managed_beacon_lookup');+ await expect(call).toContainText('approval: approve');+});+test('mcp: a trace without MCP calls says so', async ({ page }) => {await page.goto('/session.html?id=rich&lens=mcp');const frame = page.frameLocator('iframe.lens-frame');diff --git a/cli/beacon/internal/pisession/mapper.go b/cli/beacon/internal/pisession/mapper.goindex 2be974ca..5d13606f 100644--- a/cli/beacon/internal/pisession/mapper.go+++ b/cli/beacon/internal/pisession/mapper.go@@ -313,6 +313,9 @@ func (m *mapper) emitToolResult(line int, timestamp time.Time, callID string, meev.Error = &schema.ErrorInfo{Type: "tool_error"}}m.applyToolCall(&ev, state)+ if server, tool := piMCPServerTool(state.Name, childMap(message["details"])); server != "" || tool != "" {+ ev.MCP = &schema.MCPInfo{Server: server, Tool: tool}+ }if category == "command" {ev.Command = &schema.CommandInfo{Command: commandFor(state.Name, state.Args), Output: output}}@@ -394,7 +397,7 @@ func (m *mapper) applyToolCall(ev *schema.Event, call toolCallState) {ev.Tool.Path = pathev.File = &schema.FileInfo{Path: path, Operation: fileOperation(call.Name), Language: strings.TrimPrefix(filepath.Ext(path), ".")}}- if server, tool := piMCPServerTool(call.Name); server != "" || tool != "" {+ if server, tool := piMCPServerTool(call.Name, nil); server != "" || tool != "" {ev.MCP = &schema.MCPInfo{Server: server, Tool: tool}}ev.GenAI = ensureGenAI(ev.GenAI)@@ -498,7 +501,19 @@ func fileOperation(name string) string {}}-func piMCPServerTool(toolName string) (string, string) {+// piMCPServerTool returns the MCP server and tool a Pi tool call reached, when that is known: from+// the serverName and mcpToolName a result's details carry, or else from the reversible+// mcp__<server>__<tool> spelling. It reads exactly what the live hook mapper reads (piMCPServerTool+// in cli/beacon-hooks/cmd/pi_family.go), because a hook event and a session-file event for one call+// are merged only when they name the same server and tool.+//+// A name of the form mcp__<server>_<tool> is not split. That spelling hides where the server ends --+// Oh My Pi mints it from `beacon-managed` and `beacon_lookup` as mcp__beacon_managed_beacon_lookup --+// and a guessed server files the call under one it never reached.+func piMCPServerTool(toolName string, details map[string]interface{}) (string, string) {+ if server, tool := stringValue(details["serverName"]), stringValue(details["mcpToolName"]); server != "" && tool != "" {+ return server, tool+ }rest, ok := strings.CutPrefix(strings.TrimSpace(toolName), "mcp__")if !ok {return "", ""@@ -506,16 +521,14 @@ func piMCPServerTool(toolName string) (string, string) {if server, tool, ok := strings.Cut(rest, "__"); ok && server != "" && tool != "" {return server, tool}- server, tool, ok := strings.Cut(rest, "_")- if !ok || server == "" || tool == "" {- return "", ""- }- return server, tool+ return "", ""}+// isMCPTool reports whether a tool is MCP-routed, whether or not its server can be named: mcp__ is+// the namespace MCP tools are given.func isMCPTool(name string) bool {- server, tool := piMCPServerTool(name)- return server != "" || tool != ""+ rest, ok := strings.CutPrefix(strings.TrimSpace(name), "mcp__")+ return ok && rest != ""}func piUsage(usage map[string]interface{}) *schema.GenAIUsageInfo {diff --git a/cli/beacon/internal/pisession/mapper_test.go b/cli/beacon/internal/pisession/mapper_test.goindex e3905e69..6ecb4f4b 100644--- a/cli/beacon/internal/pisession/mapper_test.go+++ b/cli/beacon/internal/pisession/mapper_test.go@@ -98,6 +98,33 @@ func TestMapSessionSupportsTopLevelToolRecords(t *testing.T) {}}+// The server and tool come from what the result states, never from splitting a name whose halves+// cannot be told apart. The live hook mapper reads the same way, and a hook event and a session-file+// event for one call are merged only when they agree.+func TestMapSessionAttributesMCPToTheServerTheResultNames(t *testing.T) {+ ref := SessionRef{ID: "session-1", Path: "/tmp/pi-session-1.jsonl", Header: map[string]interface{}{"type": "session", "id": "session-1"}}+ entries := []Entry{+ {Line: 1, Data: ref.Header},+ {Line: 2, Data: map[string]interface{}{"type": "tool_call", "id": "call-1", "toolName": "mcp__beacon_managed_beacon_lookup", "input": map[string]interface{}{"kind": "harness"}}},+ {Line: 3, Data: map[string]interface{}{"type": "tool_result", "toolCallId": "call-1",+ "details": map[string]interface{}{"serverName": "beacon-managed", "mcpToolName": "beacon_lookup"}}},+ {Line: 4, Data: map[string]interface{}{"type": "tool_call", "id": "call-2", "toolName": "mcp__github_create_issue", "input": map[string]interface{}{}}},+ {Line: 5, Data: map[string]interface{}{"type": "tool_result", "toolCallId": "call-2"}},+ }+ mapped := MapSession(ref, entries, MapOptions{})+ if got := actionsOf(mapped); len(got) != 5 || got[2] != "mcp.tool_invoked" || got[4] != "mcp.tool_invoked" {+ t.Fatalf("actions = %#v", got)+ }+ if mcp := mapped[2].Event.MCP; mcp == nil || mcp.Server != "beacon-managed" || mcp.Tool != "beacon_lookup" {+ t.Fatalf("stated result mcp = %#v, want beacon-managed/beacon_lookup", mcp)+ }+ for _, i := range []int{1, 3, 4} {+ if mcp := mapped[i].Event.MCP; mcp != nil {+ t.Fatalf("%s for %s guessed mcp = %#v from the name", mapped[i].Event.Event.Action, mapped[i].Event.Tool.Name, mcp)+ }+ }+}+func actionsOf(items []MappedEvent) []string {out := make([]string, 0, len(items))for _, item := range items {diff --git a/docs/runtimes/integration-model.mdx b/docs/runtimes/integration-model.mdxindex 17f32b4d..b93cef39 100644--- a/docs/runtimes/integration-model.mdx+++ b/docs/runtimes/integration-model.mdx@@ -110,7 +110,7 @@ that is better represented as runtime events than generic OTLP spans.| [OpenCode](/runtimes/opencode) | Chat messages, session events, command execution, permission activity, diffs, and errors where payloads are available. || [Cline](/runtimes/cline) | Prompt submission, task start and end, task errors, tool invocation and completion, command execution with exit code, file reads and edits with diffs, MCP tool activity, and task token usage. Approval decisions are not exposed by Cline's hook payloads. || [Pi](/runtimes/pi) | Session lifecycle, prompt submission, tool invocation and results, command execution including operator `!` commands, file reads, creates, and edits with the unified patch, agent reasoning from assistant thinking parts, and token usage and cost. Approval decisions are not exposed by Pi's extension API and are not synthesized. |-| [Oh My Pi](/runtimes/oh-my-pi) | Everything Pi reports, plus real operator approval decisions carrying the command or file being decided on, the session's approval mode, and the tool call id. Commands include operator `!` shell and `$` Python prefixes, and MCP tool activity is resolved from Oh My Pi's `mcp__<server>_<tool>` naming. |+| [Oh My Pi](/runtimes/oh-my-pi) | Everything Pi reports, plus real operator approval decisions carrying the command or file being decided on, the session's approval mode, and the tool call id. Commands include operator `!` shell and `$` Python prefixes. MCP tool activity carries the server and tool Oh My Pi reports on the call's result, including calls made through its `xd://` tool devices. File paths are recorded as the absolute files Oh My Pi resolved them to. || [Muse Code](/runtimes/muse-code) | Session start, prompt submission, pre-tool and post-tool activity, permission requests, subagent start and stop, context compaction, stop events, command execution, and file activity. Hook timeouts are second values. User scope only: Muse's project `.muse/hooks.json` is ignored by the shipping build. || [goose](/runtimes/goose) | Session start and end, prompt submission, pre-tool and post-tool activity, post-tool failures, stop events, command lines, and file activity with diffs. Hook timeouts are second values. The two scopes replace each other rather than merging: goose deduplicates plugins by name with project scope first, so one install is one registration. || [Kiro](/runtimes/kiro) | Session start, prompt submission, pre-tool and post-tool activity, stop events with the agent's final response, command execution with output, and file activity. Hook timeouts are second values, and `0` means no timeout rather than the default. One install covers the Kiro IDE and the Kiro CLI, because they are one harness reading one hooks directory; both scopes are live at once, because Kiro merges them. |diff --git a/docs/runtimes/oh-my-pi.mdx b/docs/runtimes/oh-my-pi.mdxindex 307f6029..a7a62823 100644--- a/docs/runtimes/oh-my-pi.mdx+++ b/docs/runtimes/oh-my-pi.mdx@@ -103,20 +103,26 @@ Unlike Pi, a project-level install needs no trust prompt: Oh My Pi loads `.omp`| Tool use | Supported. `tool.invoked` before execution, then `tool.completed` or `tool.failed`, joined by `gen_ai.tool.call.id` || **Approval decisions** | **Supported.** `approval.requested`, `approval.allowed`, and `approval.denied` from real operator prompts, carrying the command or file being decided on, the approval mode the session was running under, and the tool call id of the execution they decided. This is the capability Oh My Pi has that upstream Pi does not || Commands | Supported. `command.executed` for the agent's `bash` tool, for commands you run with the `!` prefix, and for code you run with the `$` Python prefix — the last two marked as operator-initiated |-| File activity | Supported. `file.read`, `file.created`, and `file.modified`, with the unified patch on an edit. Only filesystem targets count: see [tool devices and URIs](#tool-devices-and-uris) |-| MCP activity | Supported. `tool.invoked` then `mcp.tool_invoked`, whether the model called the tool directly or through its `xd://` device. `mcp.server` and `mcp.tool` are the server's configured name and the tool's own name, read from the result Oh My Pi reports |+| File activity | Supported. `file.read`, `file.created`, and `file.modified` under the absolute path Oh My Pi resolved, with the edit's diff. An edit that changes several files records one `file.modified` per file. Only filesystem targets count: see [file paths](#file-paths) and [tool devices and URIs](#tool-devices-and-uris) |+| MCP activity | Supported. `tool.invoked` then `mcp.tool_invoked`, whether the model called the tool directly or through its `xd://` device. `mcp.server` and `mcp.tool` are the server's configured name and the tool's own name, read from the result Oh My Pi reports. A `read mcp://<uri>` is recorded as an MCP `resources/read` with `mcp.resource.uri` || Agent reasoning | Supported. `agent.reasoning` from an assistant message's thinking parts, in the OTel GenAI reasoning-part shape || Token usage and cost | Supported. `token.usage` normalized into `gen_ai.usage`, including cache and reasoning tokens and runtime-reported cost || Local JSONL and dashboard | Supported || MDM deployment | Supported for the endpoint agent. The extension installs separately in the logged-in user's context |+### File paths++Oh My Pi's tools take a path the way the model wrote it: relative to the session's working directory or to `~`, often with a line selector such as `.env:1-20`, `main.go:5-16,960-973`, or `notes.md:raw`. Beacon records the file that path names, as an absolute path, so file rules and queries see `/repo/.env` rather than `.env:1-20`. Results use the path Oh My Pi reports having resolved. The `tool.invoked` before a call, and any approval for it, resolve the path the same way Oh My Pi will: against the working directory, with `~` expanded and the selector removed, unless a file of that literal name exists. `tool.path` keeps the path as written, selector included.++Oh My Pi's default edit format can change several files in one call. Such an edit is recorded as one `file.modified` per file, each with that file's diff and its own operation (`create`, `modify`, or `delete`).+### Tool devices and URIs-Oh My Pi's `read` and `write` tools take URIs as well as paths. `https://` fetches a web page, and the runtime's own schemes (`artifact://`, `agent://`, `skill://`, `local://`, `proc://`, `omp://`, `xd://`, and others) address its resources: a spilled tool output, a subagent's report, a skill, a background job, its own docs, a tool device. None of these is file activity. Beacon records them as `tool.invoked` and `tool.completed` with the URI in `tool.path` and no `file` block, the same way every other runtime records a web fetch or a resource read. A `file://` URI is recorded as the path it names.+Oh My Pi's `read` and `write` tools take URIs as well as paths. `https://` fetches a web page, and the runtime's own schemes (`artifact://`, `agent://`, `skill://`, `local://`, `proc://`, `omp://`, `xd://`, and others) address its resources: a spilled tool output, a subagent's report, a skill, a background job, its own docs, a tool device. None of these is file activity. Beacon records them as `tool.invoked` and `tool.completed` with the URI in `tool.path` and no `file` block, the same way every other runtime records a web fetch or a resource read. A `file://` URI is recorded as the path it names. `read mcp://<uri>` reads an MCP resource and is recorded as an MCP call, with no server named: Oh My Pi does not report which server served it. A resource URI whose scheme Oh My Pi does not handle itself is also sent to MCP, but Beacon cannot tell those from the runtime's own schemes, and records them as plain tool events.Writing JSON to `xd://<tool>` is how the model calls a tool that Oh My Pi exposes as a device. That includes every MCP tool. Beacon records the device as the tool that ran, under the device's name, so an MCP call through a device produces the same `tool.invoked` and `mcp.tool_invoked` pair as one called directly. Oh My Pi reports most device calls twice: once as the `write`, and once from inside the dispatch as the device's own call, under the same tool call id. Beacon keeps one of them. Reading `xd://<tool>`, or writing `?` to it, fetches the device's documentation and is recorded as the `read` or `write` it is.-An MCP call's server is known only once it has run. Oh My Pi names its MCP tools `mcp__<server>_<tool>`. It lowercases both halves, turns other characters into `_`, and shortens long names, so the server cannot be recovered from the name: `beacon-managed`'s `beacon_lookup` becomes `mcp__beacon_managed_beacon_lookup`. The result carries the real names. The `tool.invoked` before the call, and any approval for it, record the tool name without an `mcp` block. Their `gen_ai.tool.call.id` joins them to the attributed result.+An MCP call's server is known only once it has run. Oh My Pi names its MCP tools `mcp__<server>_<tool>`. It lowercases both halves, turns other characters into `_`, and shortens long names, so the server cannot be recovered from the name: `beacon-managed`'s `beacon_lookup` becomes `mcp__beacon_managed_beacon_lookup`. The result carries the real names. The `tool.invoked` before the call, and any approval for it, record the tool name without an `mcp` block. Their `gen_ai.tool.call.id` joins them to the attributed result, which is how the dashboard's MCP lens shows the call, and the approval decided on it, under the right server.### Approval telemetry