Skip to content

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

Fix the Files Changed lens layout and Cursor tool results in the chat view

Claude5bb260b902c0
diff --git a/cli/beacon-hooks/cmd/post_tool.go b/cli/beacon-hooks/cmd/post_tool.go
index 5655b2f5..32474842 100644
--- a/cli/beacon-hooks/cmd/post_tool.go
+++ b/cli/beacon-hooks/cmd/post_tool.go
@@ -397,6 +397,17 @@ func resolveToolResponse(input map[string]interface{}) map[string]interface{} {
}
}
}
+ // Cursor's postToolUse puts the result under `tool_output`, as a JSON-encoded string. Scoped to
+ // Cursor because Kimi Code uses the same key with its own reader (applyKimiToolResult).
+ if platformFlag == "cursor" {
+ if output := strings.TrimSpace(getFirstStr(input, "tool_output")); output != "" {
+ var parsed map[string]interface{}
+ if strings.HasPrefix(output, "{") && json.Unmarshal([]byte(output), &parsed) == nil && len(parsed) > 0 {
+ return parsed
+ }
+ return map[string]interface{}{"result": output}
+ }
+ }
// Claude Code sends an MCP tool's result as a bare list of content blocks. A list from any
// other runtime is read the same way: until this, every list response was dropped.
if content, ok := input["tool_response"].([]interface{}); ok {
diff --git a/cli/beacon-hooks/cmd/post_tool_test.go b/cli/beacon-hooks/cmd/post_tool_test.go
index a9d1d3f6..fa37aecd 100644
--- a/cli/beacon-hooks/cmd/post_tool_test.go
+++ b/cli/beacon-hooks/cmd/post_tool_test.go
@@ -199,6 +199,54 @@ func TestRunPostToolEmitsCursorMCPGenAIFields(t *testing.T) {
}
}
+// Cursor's postToolUse carries the result as a JSON-encoded string under tool_output; without
+// reading it a WebSearch was recorded as a call with nothing it returned.
+func TestRunPostToolRecordsCursorToolOutput(t *testing.T) {
+ setupHookConfigDirs(t)
+ platformFlag = "cursor"
+ logPath := filepath.Join(t.TempDir(), "runtime.jsonl")
+ t.Setenv("BEACON_ENDPOINT_LOG", logPath)
+
+ runHookWithInput(t, runPostTool, map[string]interface{}{
+ "conversation_id": "conv-web",
+ "hook_event_name": "postToolUse",
+ "tool_name": "WebSearch",
+ "tool_input": map[string]interface{}{"search_term": "weather NYC today"},
+ "tool_output": `{"results":"Sunny, 68F in New York City"}`,
+ "tool_use_id": "call_web",
+ "cwd": "/repo",
+ })
+
+ event := lastEndpointEvent(t, logPath)
+ genAI, _ := event["gen_ai"].(map[string]interface{})
+ tool, _ := genAI["tool"].(map[string]interface{})
+ call, _ := tool["call"].(map[string]interface{})
+ result, _ := call["result"].(map[string]interface{})
+ if result["results"] != "Sunny, 68F in New York City" {
+ t.Fatalf("gen_ai.tool.call.result = %#v, want the parsed tool_output", call["result"])
+ }
+ if call["id"] != "call_web" {
+ t.Fatalf("gen_ai.tool.call.id = %#v, want call_web", call["id"])
+ }
+
+ runHookWithInput(t, runPostTool, map[string]interface{}{
+ "conversation_id": "conv-web",
+ "hook_event_name": "postToolUse",
+ "tool_name": "WebFetch",
+ "tool_input": map[string]interface{}{"url": "https://example.com"},
+ "tool_output": "plain page text",
+ "cwd": "/repo",
+ })
+ event = lastEndpointEvent(t, logPath)
+ genAI, _ = event["gen_ai"].(map[string]interface{})
+ tool, _ = genAI["tool"].(map[string]interface{})
+ call, _ = tool["call"].(map[string]interface{})
+ result, _ = call["result"].(map[string]interface{})
+ if result["result"] != "plain page text" {
+ t.Fatalf("gen_ai.tool.call.result = %#v, want the plain tool_output", call["result"])
+ }
+}
+
func TestRunPostToolSuppressesCursorCloudReadPostToolDuplicate(t *testing.T) {
setupHookConfigDirs(t)
platformFlag = "cursor"
diff --git a/cli/beacon/internal/endpoint/dashboard/lenses/files-changed.lens.html b/cli/beacon/internal/endpoint/dashboard/lenses/files-changed.lens.html
index b11c0997..5f78403c 100644
--- a/cli/beacon/internal/endpoint/dashboard/lenses/files-changed.lens.html
+++ b/cli/beacon/internal/endpoint/dashboard/lenses/files-changed.lens.html
@@ -27,8 +27,8 @@
#summary { margin: 0 0 10px; }
.layout { display: grid; grid-template-columns: minmax(12rem, 18rem) minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 640px) { .layout { grid-template-columns: minmax(0, 1fr); } }
- .tree { border-right: 1px solid var(--beacon-line, rgba(0,0,0,0.1)); padding-right: 8px; }
- .row { display: flex; align-items: baseline; gap: 6px; width: 100%; padding: 2px 6px; border: 0; border-radius: 4px; background: none; color: inherit; font: inherit; text-align: left; }
+ .tree { min-width: 0; border-right: 1px solid var(--beacon-line, rgba(0,0,0,0.1)); padding-right: 8px; }
+ .row { box-sizing: border-box; display: flex; align-items: baseline; gap: 6px; width: 100%; padding: 2px 6px; border: 0; border-radius: 4px; background: none; color: inherit; font: inherit; text-align: left; }
.row .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .counts { white-space: nowrap; font-variant-numeric: tabular-nums; }
button.row { cursor: pointer; }
@@ -37,7 +37,7 @@
button.row:focus-visible { outline: 2px solid var(--beacon-accent, #036aa2); outline-offset: -2px; }
.dir { color: var(--beacon-muted, #6b7280); }
.tag { font-size: 12px; color: var(--beacon-muted, #6b7280); }
- h2 { margin: 0 0 8px; font-size: 13px; font-weight: 400; word-break: break-all; }
+ h2 { margin: 0 0 8px; font-size: 13px; font-weight: 400; overflow-wrap: anywhere; }
.edit { margin: 0 0 14px; }
.edit-head { margin: 0 0 4px; }
pre { margin: 0; padding: 6px 8px; overflow-x: auto; border: 1px solid var(--beacon-line, rgba(0,0,0,0.1)); border-radius: 4px; white-space: pre; }
@@ -72,6 +72,8 @@
}
function isWrite(event) {
+ // An approval names the file a write is about to touch; the write itself is its own event.
+ if (event.category === "approval" || String(event.action || "").indexOf("approval.") === 0) return false;
var op = String((event.file && event.file.operation) || "").toLowerCase();
return !!(WRITE_OPS[op] || WRITE_ACTIONS[event.action]);
}
@@ -169,6 +171,7 @@
shownDirs[dir] = 1;
var dirRow = el("div", null, "row dir");
dirRow.style.paddingLeft = (6 + i * 12) + "px";
+ dirRow.title = dir;
dirRow.appendChild(el("span", parts[i] + "/", "name mono"));
tree.appendChild(dirRow);
}
@@ -203,7 +206,13 @@
function renderDetail(f) {
var detail = document.getElementById("detail");
detail.textContent = "";
- detail.appendChild(el("h2", f.path, "mono"));
+ // Break the path after each slash rather than mid-name.
+ var heading = el("h2", null, "mono");
+ f.path.split("/").forEach(function (part, i, parts) {
+ heading.appendChild(document.createTextNode(part + (i < parts.length - 1 ? "/" : "")));
+ if (i < parts.length - 1) heading.appendChild(document.createElement("wbr"));
+ });
+ detail.appendChild(heading);
f.edits.forEach(function (edit) {
var e = edit.event;
var block = el("div", null, "edit");
diff --git a/pkg/asymptoteobserve/share_test.go b/pkg/asymptoteobserve/share_test.go
index 35ab3c67..0c7aea3d 100644
--- a/pkg/asymptoteobserve/share_test.go
+++ b/pkg/asymptoteobserve/share_test.go
@@ -616,6 +616,41 @@ func TestShareMessagesTreatsAPostToolInvokedEventAsTheResult(t *testing.T) {
}
}
+func TestShareMessagesKeepsCursorsToolOutputWriteApartFromItsWebSearch(t *testing.T) {
+ // Cursor records the file it saves a WebSearch's output to as a Write carrying the WebSearch's
+ // tool_use_id, ahead of the WebSearch's own postToolUse. The two are different tools: the Write
+ // must not swallow the WebSearch and its result. The Stop hook's payloadless tool.completed is
+ // the end of the turn, not a tool.
+ const id = "call_Ox7\nfc_0f44"
+ write := shareEventAt("2026-10-11T19:21:20Z", "cursor", CollectionMethodHook, "file.modified", "file")
+ write.Event.ID = "cursor-write"
+ write = withCall(write, id, "Write", nil, nil)
+ write.File = &FileInfo{Path: "/home/dev/.cursor/projects/app/agent-tools/82a0.txt", Operation: "create"}
+ search := shareEventAt("2026-10-11T19:21:21Z", "cursor", CollectionMethodHook, "tool.invoked", "tool")
+ search.Event.ID = "cursor-search"
+ search = withCall(search, id, "WebSearch", map[string]interface{}{"search_term": "weather NYC"}, map[string]interface{}{"results": "Sunny, 68F"})
+ stop := shareEventAt("2026-10-11T19:21:25Z", "cursor", CollectionMethodHook, "tool.completed", "tool")
+ stop.Event.ID = "cursor-stop"
+
+ messages := shareMessages([]Event{write, search, stop}, shareTestOpts)
+ want := "assistant/tool_call,assistant/tool_call,assistant/tool_result"
+ if got := partsOf(t, messages); strings.Join(got, ",") != want {
+ t.Fatalf("parts = %v, want %s", got, want)
+ }
+ writeCall := messages[0].Parts[0].Content.(*TraceToolCallContentV1)
+ searchCall := messages[1].Parts[0].Content.(*TraceToolCallContentV1)
+ result := messages[2].Parts[0].Content.(*TraceToolResultContentV1)
+ if writeCall.ToolName != "Write" || searchCall.ToolName != "WebSearch" {
+ t.Fatalf("calls = %q, %q; want Write, WebSearch", writeCall.ToolName, searchCall.ToolName)
+ }
+ if searchCall.CallID == writeCall.CallID || result.CallID != searchCall.CallID {
+ t.Fatalf("call ids: write %q, search %q, result %q", writeCall.CallID, searchCall.CallID, result.CallID)
+ }
+ if !strings.Contains(result.Output, "Sunny, 68F") {
+ t.Fatalf("result output = %q", result.Output)
+ }
+}
+
func TestShareMessagesWritesAPromptCapturedTwiceOnce(t *testing.T) {
// Claude Code logs each prompt from the UserPromptSubmit hook and from the OTLP export, with
// different event ids and the same prompt.id. The export copy may carry no text.
diff --git a/pkg/asymptoteobserve/tracemessages.go b/pkg/asymptoteobserve/tracemessages.go
index 575efcc4..39b0c6b0 100644
--- a/pkg/asymptoteobserve/tracemessages.go
+++ b/pkg/asymptoteobserve/tracemessages.go
@@ -288,6 +288,8 @@ func classifyTraceMessage(event TraceEventV1) traceMessageClass {
return traceMessageAgentText
case category == "approval" || strings.HasPrefix(action, "approval.") || strings.HasPrefix(action, "policy."):
return traceMessageApproval
+ case action == "tool.completed" && tracePayloadlessTurnEnd(event):
+ return traceMessageSkip
case strings.HasPrefix(action, "tool.") || strings.HasPrefix(action, "command.") ||
strings.HasPrefix(action, "file.") || action == "mcp.tool_invoked" || action == "mcp.tool_call" ||
category == "tool" || category == "command" || category == "file":
@@ -299,6 +301,44 @@ func classifyTraceMessage(event TraceEventV1) traceMessageClass {
return traceMessageSystem
}
+// tracePayloadlessTurnEnd reports the Stop hook's "Agent response completed": a tool.completed that
+// names no call and carries no tool, command, file or MCP payload. It marks the end of the agent's
+// turn, not a tool, and as a tool it showed as an empty "Used tool" with no output.
+func tracePayloadlessTurnEnd(event TraceEventV1) bool {
+ return strings.TrimSpace(event.ToolCallID) == "" && event.Tool == nil && event.Command == nil &&
+ event.File == nil && event.MCP == nil
+}
+
+// traceToolFamily groups tool kinds that one call can be reported as: an edit tool's call and the
+// file write it produced are one call. "" is a kind that says nothing (other).
+func traceToolFamily(kind string) string {
+ switch kind {
+ case TraceToolKindEdit, TraceToolKindWrite, TraceToolKindDelete:
+ return "file"
+ case TraceToolKindOther:
+ return ""
+ }
+ return kind
+}
+
+// callKey is the key an event's call is held under. Usually the runtime's call id, but a runtime can
+// report a second, different tool under the id of the call it serves: Cursor records the file it
+// writes a WebSearch's output to as a Write carrying the WebSearch's tool_use_id. When the call
+// already held under the id is plainly another kind of tool, this event's call is keyed apart, so
+// the WebSearch keeps its own call and result instead of being folded into the Write.
+func (b *traceMessageBuilder) callKey(callID string, event TraceEventV1, toolName string) string {
+ call := b.calls[callID]
+ if callID == "" || call == nil {
+ return callID
+ }
+ held := traceToolFamily(call.ToolKind)
+ this := traceToolFamily(TraceToolKind(toolName, event.Action, event.Category, event.MCP != nil))
+ if held == "" || this == "" || held == this {
+ return callID
+ }
+ return callID + "#" + normalizeToolName(toolName)
+}
+
// traceToolInvocation reports an event that names a tool call before it runs.
func traceToolInvocation(event TraceEventV1) bool {
switch strings.ToLower(strings.TrimSpace(event.Action)) {
@@ -452,8 +492,8 @@ func (b *traceMessageBuilder) appendText(event TraceEventV1, role, kind, partTyp
}
func (b *traceMessageBuilder) addTool(event TraceEventV1) {
- callID := strings.TrimSpace(event.ToolCallID)
toolName := traceMessageToolName(event)
+ callID := b.callKey(strings.TrimSpace(event.ToolCallID), event, toolName)
invocation := traceToolInvocation(event)
explicit := invocation
completion := !invocation && traceToolCompletion(event)