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
feat(lenses): built-in Failures lens (#1224)
John Carlb41143763d31
diff --git a/cli/beacon/internal/endpoint/dashboard/lenses/failures.lens.html b/cli/beacon/internal/endpoint/dashboard/lenses/failures.lens.htmlnew file mode 100644index 00000000..a6479d0a--- /dev/null+++ b/cli/beacon/internal/endpoint/dashboard/lenses/failures.lens.html@@ -0,0 +1,376 @@+<!doctype html>+<html lang="en">+<head>+<meta charset="utf-8">+<title>Failures</title>+<script type="application/beacon-lens+json">+{+ "id": "failures",+ "title": "Failures",+ "description": "Everything that went wrong, in order: commands that exited non-zero, calls the runtime reported as failed, and error events, with their output and what the next identical call did.",+ "icon": "alert",+ "version": 1,+ "api": "beacon.lens.v1",+ "author": "Beacon"+}+</script>+<style>+ [hidden] { display: none !important; }+ body {+ margin: 0;+ color: var(--beacon-text, #111827);+ font: 400 13px/1.5 var(--beacon-font-sans, ui-sans-serif, system-ui, sans-serif);+ }+ .muted { color: var(--beacon-muted, #6b7280); }+ .mono { font: 13px var(--beacon-font-mono, ui-monospace, SFMono-Regular, Menlo, monospace); overflow-wrap: anywhere; }+ .fail { color: var(--beacon-danger, #b91c1c); }+ .ok { color: var(--beacon-ok, #047857); }+ p { margin: 0 0 8px; }+ table { width: 100%; border-collapse: collapse; }+ th, td { padding: 4px 8px; border-bottom: 1px solid var(--beacon-line, rgba(0,0,0,0.1)); font-weight: 400; text-align: left; vertical-align: top; }+ th { color: var(--beacon-muted, #6b7280); white-space: nowrap; }+ .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }+ tr.detail td { padding-top: 0; }+ pre {+ margin: 0;+ padding: 6px 8px;+ max-height: 240px;+ overflow: auto;+ background: var(--beacon-panel-soft, #f9fafb);+ font: 13px/1.4 var(--beacon-font-mono, ui-monospace, SFMono-Regular, Menlo, monospace);+ white-space: pre-wrap;+ overflow-wrap: anywhere;+ }+ .more { margin: 8px 0 0; padding: 0; border: 0; background: none; color: var(--beacon-accent, #036aa2); font: inherit; cursor: pointer; }+ .more:focus-visible { outline: 2px solid var(--beacon-accent, #036aa2); outline-offset: 2px; }+</style>+</head>+<body>+<p id="status" class="muted">Loading trace…</p>+<main id="root" hidden>+ <p id="summary"></p>+ <div id="notes"></div>+ <table id="table" hidden>+ <thead><tr><th class="num">#</th><th class="num">Time</th><th>Kind</th><th>What</th><th>Failure</th><th>Later attempt</th></tr></thead>+ <tbody id="rows"></tbody>+ </table>+</main>+<script>+(function () {+ "use strict";+ var PAGE = 100;+ var MAX_OUTPUT = 4000;+ var fmt = new Intl.NumberFormat();+ // The event types that belong to a tool call. A tool_call only says a call began; the others report+ // how it went (Claude Code's hooks report a successful Edit or Read as a file event).+ var CALL_TYPES = { tool_call: true, tool_result: true, command: true, mcp: true, file: true };+ var RESULT_TYPES = { tool_result: true, command: true, mcp: true, file: true };+ var KINDS = ["command", "tool call", "MCP call", "error"];++ // Every node is built with textContent: commands, output and results are untrusted.+ function el(tag, text, className) {+ var node = document.createElement(tag);+ if (text !== undefined && text !== null) node.textContent = String(text);+ if (className) node.className = className;+ return node;+ }++ function str(value) {+ return typeof value === "string" ? value.trim() : "";+ }++ function exitCode(event) {+ var code = event.command && event.command.exit_code;+ return typeof code === "number" ? code : null;+ }++ // A failure is what the runtime reported as one: an error.type on the event (set on any event the+ // runtime reported as failed, whatever its type), or a command's exit code other than 0.+ function failed(event) {+ var code = exitCode(event);+ if (code !== null && code !== 0) return true;+ return !!(event.error && str(event.error.type));+ }++ // The server and tool a Claude-style name carries: mcp__<server>__<tool>, or MCP:<tool>.+ function fromName(name) {+ var text = str(name);+ var lower = text.toLowerCase();+ if (lower.indexOf("mcp__") === 0) {+ var parts = text.split("__");+ return parts.length >= 3 ? { server: parts[1], tool: parts.slice(2).join("__") } : { server: "", tool: "" };+ }+ if (lower.indexOf("mcp:") === 0) return { server: "", tool: text.slice(4).trim() };+ return null;+ }++ // Arguments as text with sorted keys, so the same arguments compare equal whatever their order.+ function canonical(value) {+ if (value === undefined || value === null) return "";+ if (Array.isArray(value)) return "[" + value.map(canonical).join(",") + "]";+ if (typeof value === "object") {+ return "{" + Object.keys(value).sort().map(function (k) { return JSON.stringify(k) + ":" + canonical(value[k]); }).join(",") + "}";+ }+ return JSON.stringify(value);+ }++ // What a call was, from every event reported for it: the pre-call event often names what the+ // result does not.+ function absorb(f, event) {+ var command = event.command || {};+ var tool = event.tool || {};+ var mcp = event.mcp || {};+ var named = fromName(tool.name);+ if (!f.command) f.command = str(command.command) || str(tool.command);+ if (str(mcp.server) || str(mcp.tool) || named || event.type === "mcp") f.mcp = true;+ if (!f.server) f.server = str(mcp.server) || (named ? named.server : "");+ if (!f.mcpTool) f.mcpTool = str(mcp.tool) || (named ? named.tool : "");+ if (!f.name) f.name = str(tool.name);+ if (!f.path) f.path = str(tool.path);+ if (f.args === undefined && tool.arguments !== undefined && tool.arguments !== null) f.args = tool.arguments;+ }++ // kind and subject are shown; key is what a later call must match to be another attempt at the+ // same thing: the command line, the MCP tool and its arguments, or the tool and the path it acted+ // on (its arguments, for a tool that names no path).+ function identify(f) {+ if (f.command) return { kind: "command", subject: f.command, key: "command\u0000" + f.command };+ if (f.mcp) {+ var mcpName = [f.server, f.mcpTool].filter(Boolean).join(" / ") || f.name;+ return { kind: "MCP call", subject: mcpName, key: mcpName ? "mcp\u0000" + f.server + "\u0000" + (f.mcpTool || f.name) + "\u0000" + canonical(f.args) : "" };+ }+ if (f.name) {+ return {+ kind: "tool call",+ subject: f.path ? f.name + " " + f.path : f.name,+ key: "tool\u0000" + f.name + "\u0000" + f.path + "\u0000" + (f.path ? "" : canonical(f.args))+ };+ }+ return { kind: "tool call", subject: "", key: "" };+ }++ function fieldsOf(event) {+ var f = {};+ absorb(f, event);+ return f;+ }++ // Calls are joined on tool_call_id, so the pre-call event, the result and a second copy of the+ // result (a hook and an OTLP export of one call) are one call. A copy with no call id joins the+ // call whose result has its subject and timestamp.+ function collect(events) {+ var calls = [];+ var loose = [];+ var byID = {};+ var byTwin = {};+ events.forEach(function (event) {+ if (!CALL_TYPES[event.type]) {+ if (event.type !== "approval" && (event.type === "error" || failed(event))) loose.push(event);+ return;+ }+ var id = str(event.tool_call_id);+ var result = !!RESULT_TYPES[event.type];+ var twin = "";+ if (result && event.timestamp) {+ var own = identify(fieldsOf(event)).key;+ if (own) twin = own + "\u0000" + event.timestamp;+ }+ var call = id ? byID[id] : (twin ? byTwin[twin] : null);+ if (!call) {+ call = { fields: {}, events: [], results: [], failure: null };+ calls.push(call);+ if (id) byID[id] = call;+ }+ if (twin && !byTwin[twin]) byTwin[twin] = call;+ absorb(call.fields, event);+ call.events.push(event);+ if (!result) return;+ call.results.push(event);+ if (!call.failure && failed(event)) call.failure = event;+ });+ calls.forEach(function (call) {+ var who = identify(call.fields);+ call.kind = who.kind;+ call.subject = who.subject;+ call.key = who.key;+ // Only a reported result judges a call: a call that failed in any copy failed, and one with a+ // result that did not fail succeeded. A call with no result has no outcome.+ call.outcome = call.failure || call.results[0] || null;+ });+ return { calls: calls, loose: loose };+ }++ // For each failed call, the next later call with the same key and an outcome. One pass from the+ // end, so it costs the same however many failures there are.+ function linkAttempts(calls) {+ var judged = calls.filter(function (c) { return c.outcome && c.key; });+ judged.sort(function (a, b) { return a.outcome.number - b.outcome.number; });+ var next = {};+ for (var i = judged.length - 1; i >= 0; i--) {+ var call = judged[i];+ if (call.failure) call.next = next[call.key] || null;+ next[call.key] = call;+ }+ }++ function reason(event) {+ var code = exitCode(event);+ if (code !== null && code !== 0) return "exit " + code;+ if (event.error && str(event.error.type)) return str(event.error.type);+ return event.action || "error";+ }++ function text(value) {+ if (value === undefined || value === null) return "";+ if (typeof value === "string") return value;+ try { return JSON.stringify(value, null, 2); } catch (e) { return String(value); }+ }++ function retainedText(content) {+ return content && content.included && typeof content.text === "string" ? content.text : "";+ }++ // The output that explains a failure, or why there is none to show. The failing event's copy comes+ // first; another copy of the same call can carry the output that one lacks.+ function output(row) {+ var events = [row.event];+ if (row.call) row.call.results.forEach(function (e) { if (e !== row.event) events.push(e); });+ for (var i = 0; i < events.length; i++) {+ var e = events[i];+ var out = retainedText(e.command && e.command.output) || text(e.tool && e.tool.result) || retainedText(e.content);+ if (out) return { text: out };+ }+ // Output that was not kept leaves no command.output at all; what it was is on the event's content.+ var content = row.event.content;+ if (content && content.included === false) {+ var parts = [content.redacted ? "Output redacted" : "Output not retained"];+ if (str(content.retention)) parts.push("retention " + content.retention);+ if (typeof content.bytes === "number" && content.bytes > 0) parts.push(fmt.format(content.bytes) + " bytes");+ if (str(content.hash)) parts.push(content.hash);+ return { note: parts.join(" · ") + "." };+ }+ // An error event's message describes it; on a call it is only a label.+ var summary = str(row.event.summary);+ if (!row.call && summary && summary !== row.event.action && summary !== row.event.title) return { text: summary };+ return null;+ }++ function when(timestamp) {+ var date = new Date(timestamp);+ return timestamp && !isNaN(date.getTime()) ? date.toLocaleTimeString() : "—";+ }++ function renderRow(body, row) {+ var e = row.event;+ var tr = body.appendChild(el("tr"));+ tr.appendChild(el("td", "#" + e.number, "num"));+ tr.appendChild(el("td", when(e.timestamp), "num"));+ tr.appendChild(el("td", row.kind));+ tr.appendChild(el("td", row.subject || e.title || e.action, "mono"));+ tr.appendChild(el("td", reason(e), "fail"));+ if (!row.call) tr.appendChild(el("td", "—", "muted"));+ else if (!row.call.next) tr.appendChild(el("td", "no later attempt", "muted"));+ else if (row.call.next.failure) tr.appendChild(el("td", "failed again at #" + row.call.next.failure.number, "fail"));+ else tr.appendChild(el("td", "succeeded at #" + row.call.next.outcome.number, "ok"));++ var out = output(row);+ if (!out) return;+ var cell = body.appendChild(el("tr", null, "detail")).appendChild(el("td"));+ cell.colSpan = 6;+ if (out.note) cell.appendChild(el("p", out.note, "muted"));+ else cell.appendChild(el("pre", out.text.length > MAX_OUTPUT ? out.text.slice(0, MAX_OUTPUT) + "\n…" : out.text));+ }++ function plural(n, one, many) {+ return fmt.format(n) + " " + (n === 1 ? one : many);+ }++ function list(parts) {+ return parts.length < 2 ? parts.join("") : parts.slice(0, -1).join(", ") + " and " + parts[parts.length - 1];+ }++ function render(data) {+ var trace = (data && data.trace) || {};+ var events = (Array.isArray(trace.events) ? trace.events : []).filter(Boolean).slice();+ events.sort(function (a, b) { return (a.number || 0) - (b.number || 0); });+ var total = trace.summary && trace.summary.event_count;+ var partial = (data && data.truncated) || (typeof total === "number" && events.length < total);+ var over = partial ? ", over the first " + fmt.format(events.length) + (typeof total === "number" ? " of " + fmt.format(total) : "") + " events" : "";++ var collected = collect(events);+ linkAttempts(collected.calls);+ var rows = [];+ collected.calls.forEach(function (call) {+ if (call.failure) rows.push({ event: call.failure, call: call, kind: call.kind, subject: call.subject });+ });+ collected.loose.forEach(function (event) {+ rows.push({ event: event, call: null, kind: "error", subject: "" });+ });+ rows.sort(function (a, b) { return a.event.number - b.event.number; });++ var summary = document.getElementById("summary");+ var notes = document.getElementById("notes");+ if (!rows.length) {+ summary.textContent = "Nothing failed in this trace" + over + ": no command exited non-zero, and the runtime reported no failed call and no error.";+ summary.className = "muted";+ return finish();+ }++ var counts = {};+ var outcomes = { ok: 0, again: 0, none: 0 };+ rows.forEach(function (row) {+ counts[row.kind] = (counts[row.kind] || 0) + 1;+ if (!row.call) return;+ if (!row.call.next) outcomes.none += 1;+ else if (row.call.next.failure) outcomes.again += 1;+ else outcomes.ok += 1;+ });+ summary.textContent = plural(rows.length, "failure", "failures") + ": " + KINDS.filter(function (k) { return counts[k]; }).map(function (k) {+ return plural(counts[k], k, k + "s");+ }).join(", ") + over + ".";++ var failedCalls = outcomes.ok + outcomes.again + outcomes.none;+ if (failedCalls) {+ var parts = [];+ if (outcomes.ok) parts.push(fmt.format(outcomes.ok) + " succeeded on the next identical call");+ if (outcomes.again) parts.push(fmt.format(outcomes.again) + " failed again");+ if (outcomes.none) parts.push(fmt.format(outcomes.none) + " had no later identical call");+ notes.appendChild(el("p", "Of " + plural(failedCalls, "failed call", "failed calls") + ", " + list(parts) + "."));+ notes.appendChild(el("p", "A later call is identical when it ran the same command line, the same MCP tool with the same arguments, or the same tool on the same path (with the same arguments, for a tool that names no path). It succeeded when its result reported no failure." ++ (partial ? " Calls after the events shown are not included." : ""), "muted"));+ }++ var body = document.getElementById("rows");+ var shown = 0;+ var button = null;+ function more() {+ rows.slice(shown, shown + PAGE).forEach(function (row) { renderRow(body, row); });+ shown = Math.min(rows.length, shown + PAGE);+ if (!button) return;+ if (shown >= rows.length) button.remove();+ else button.textContent = "Show more (" + fmt.format(rows.length - shown) + " left)";+ }+ if (rows.length > PAGE) {+ button = el("button", "", "more");+ button.type = "button";+ button.addEventListener("click", more);+ }+ more();+ var table = document.getElementById("table");+ table.hidden = false;+ if (button && shown < rows.length) table.after(button);+ finish();+ }++ function finish() {+ document.getElementById("status").hidden = true;+ document.getElementById("root").hidden = false;+ }++ window.beacon.getTrace().then(render, function (err) {+ document.getElementById("status").textContent = "Could not load this trace: " + ((err && err.message) || err);+ });+})();+</script>+</body>+</html>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 55af5b8d..e4264d37 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@@ -45,3 +45,23 @@{"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)."}]}}}}}+{"vendor": "beacon", "product": "endpoint-agent", "schema_version": "1.0", "severity": "info", "endpoint": {"os": "linux"}, "harness": {"name": "claude_code", "collection_method": "hook"}, "session": {"id": "failing", "working_directory": "/work/api"}, "timestamp": "2026-06-16T08:00:00Z", "event": {"id": "fl-prompt", "kind": "agent_runtime", "action": "prompt.submitted", "category": "prompt"}, "message": "Prompt submitted to agent", "prompt": {"text": "Fix the flaky retry test"}, "content": {"retention": "full", "included": true}}+{"vendor": "beacon", "product": "endpoint-agent", "schema_version": "1.0", "severity": "info", "endpoint": {"os": "linux"}, "harness": {"name": "claude_code", "collection_method": "hook"}, "session": {"id": "failing", "working_directory": "/work/api"}, "timestamp": "2026-06-16T08:00:10Z", "event": {"id": "fl-test-1-pre", "kind": "agent_runtime", "action": "tool.invoked", "category": "tool"}, "message": "Tool invocation observed", "command": {"command": "go test ./..."}, "tool": {"name": "Bash", "command": "go test ./..."}, "gen_ai": {"tool": {"name": "Bash", "call": {"id": "toolu_test_1"}}}}+{"vendor": "beacon", "product": "endpoint-agent", "schema_version": "1.0", "severity": "high", "endpoint": {"os": "linux"}, "harness": {"name": "claude_code", "collection_method": "hook"}, "session": {"id": "failing", "working_directory": "/work/api"}, "timestamp": "2026-06-16T08:00:14Z", "event": {"id": "fl-test-1", "kind": "agent_runtime", "action": "command.executed", "category": "command"}, "message": "Tool execution observed", "command": {"command": "go test ./...", "exit_code": 1, "duration_ms": 3400, "output": "--- FAIL: TestRetry (0.01s)\n retry_test.go:22: want 3 attempts, got 2\nFAIL"}, "tool": {"name": "Bash", "command": "go test ./..."}, "gen_ai": {"tool": {"name": "Bash", "call": {"id": "toolu_test_1"}}}, "content": {"retention": "full", "included": true}}+{"vendor": "beacon", "product": "endpoint-agent", "schema_version": "1.0", "severity": "info", "endpoint": {"os": "linux"}, "harness": {"name": "claude_code", "collection_method": "otlp"}, "session": {"id": "failing"}, "timestamp": "2026-06-16T08:00:15Z", "event": {"id": "fl-test-1-otlp", "kind": "agent_runtime", "action": "command.executed", "category": "command"}, "message": "claude_code.tool_result", "command": {"command": "go test ./...", "duration_ms": 3400}, "tool": {"name": "Bash", "command": "go test ./..."}, "gen_ai": {"tool": {"name": "Bash", "call": {"id": "toolu_test_1"}}}}+{"vendor": "beacon", "product": "endpoint-agent", "schema_version": "1.0", "severity": "info", "endpoint": {"os": "linux"}, "harness": {"name": "claude_code", "collection_method": "hook"}, "session": {"id": "failing", "working_directory": "/work/api"}, "timestamp": "2026-06-16T08:00:20Z", "event": {"id": "fl-edit-a-pre", "kind": "agent_runtime", "action": "tool.invoked", "category": "tool"}, "message": "Tool invocation observed", "file": {"path": "/work/api/a.go", "operation": "modify", "language": "go"}, "tool": {"name": "Edit", "path": "/work/api/a.go"}, "gen_ai": {"tool": {"name": "Edit", "call": {"id": "toolu_edit_a"}}}}+{"vendor": "beacon", "product": "endpoint-agent", "schema_version": "1.0", "severity": "high", "endpoint": {"os": "linux"}, "harness": {"name": "claude_code", "collection_method": "hook"}, "session": {"id": "failing", "working_directory": "/work/api"}, "timestamp": "2026-06-16T08:00:21Z", "event": {"id": "fl-edit-a", "kind": "agent_runtime", "action": "tool.failed", "category": "tool"}, "message": "Tool execution failed", "file": {"path": "/work/api/a.go", "operation": "modify", "language": "go"}, "tool": {"name": "Edit", "path": "/work/api/a.go"}, "gen_ai": {"tool": {"name": "Edit", "call": {"id": "toolu_edit_a"}}}}+{"vendor": "beacon", "product": "endpoint-agent", "schema_version": "1.0", "severity": "info", "endpoint": {"os": "linux"}, "harness": {"name": "claude_code", "collection_method": "hook"}, "session": {"id": "failing", "working_directory": "/work/api"}, "timestamp": "2026-06-16T08:00:30Z", "event": {"id": "fl-edit-b-pre", "kind": "agent_runtime", "action": "tool.invoked", "category": "tool"}, "message": "Tool invocation observed", "file": {"path": "/work/api/b.go", "operation": "modify", "language": "go"}, "tool": {"name": "Edit", "path": "/work/api/b.go"}, "gen_ai": {"tool": {"name": "Edit", "call": {"id": "toolu_edit_b"}}}}+{"vendor": "beacon", "product": "endpoint-agent", "schema_version": "1.0", "severity": "info", "endpoint": {"os": "linux"}, "harness": {"name": "claude_code", "collection_method": "hook"}, "session": {"id": "failing", "working_directory": "/work/api"}, "timestamp": "2026-06-16T08:00:31Z", "event": {"id": "fl-edit-b", "kind": "agent_runtime", "action": "file.modified", "category": "file"}, "message": "File modification observed", "file": {"path": "/work/api/b.go", "operation": "modify", "language": "go", "diff": "@@ -1 +1 @@\n-const attempts = 2\n+const attempts = 3\n"}, "tool": {"name": "Edit", "path": "/work/api/b.go"}, "gen_ai": {"tool": {"name": "Edit", "call": {"id": "toolu_edit_b"}}}, "content": {"retention": "full", "included": true}}+{"vendor": "beacon", "product": "endpoint-agent", "schema_version": "1.0", "severity": "info", "endpoint": {"os": "linux"}, "harness": {"name": "claude_code", "collection_method": "hook"}, "session": {"id": "failing", "working_directory": "/work/api"}, "timestamp": "2026-06-16T08:00:40Z", "event": {"id": "fl-test-2-pre", "kind": "agent_runtime", "action": "tool.invoked", "category": "tool"}, "message": "Tool invocation observed", "command": {"command": "go test ./..."}, "tool": {"name": "Bash", "command": "go test ./..."}, "gen_ai": {"tool": {"name": "Bash", "call": {"id": "toolu_test_2"}}}}+{"vendor": "beacon", "product": "endpoint-agent", "schema_version": "1.0", "severity": "high", "endpoint": {"os": "linux"}, "harness": {"name": "claude_code", "collection_method": "hook"}, "session": {"id": "failing", "working_directory": "/work/api"}, "timestamp": "2026-06-16T08:00:44Z", "event": {"id": "fl-test-2", "kind": "agent_runtime", "action": "command.executed", "category": "command"}, "message": "Tool execution observed", "command": {"command": "go test ./...", "exit_code": 1, "duration_ms": 3300, "output": "--- FAIL: TestRetry (0.01s)\n retry_test.go:30: backoff not reset after success\nFAIL"}, "tool": {"name": "Bash", "command": "go test ./..."}, "gen_ai": {"tool": {"name": "Bash", "call": {"id": "toolu_test_2"}}}, "content": {"retention": "full", "included": true}}+{"vendor": "beacon", "product": "endpoint-agent", "schema_version": "1.0", "severity": "info", "endpoint": {"os": "linux"}, "harness": {"name": "claude_code", "collection_method": "hook"}, "session": {"id": "failing", "working_directory": "/work/api"}, "timestamp": "2026-06-16T08:00:50Z", "event": {"id": "fl-test-3-pre", "kind": "agent_runtime", "action": "tool.invoked", "category": "tool"}, "message": "Tool invocation observed", "command": {"command": "go test ./..."}, "tool": {"name": "Bash", "command": "go test ./..."}, "gen_ai": {"tool": {"name": "Bash", "call": {"id": "toolu_test_3"}}}}+{"vendor": "beacon", "product": "endpoint-agent", "schema_version": "1.0", "severity": "info", "endpoint": {"os": "linux"}, "harness": {"name": "claude_code", "collection_method": "hook"}, "session": {"id": "failing", "working_directory": "/work/api"}, "timestamp": "2026-06-16T08:00:54Z", "event": {"id": "fl-test-3", "kind": "agent_runtime", "action": "command.executed", "category": "command"}, "message": "Tool execution observed", "command": {"command": "go test ./...", "duration_ms": 3100, "output": "ok \texample.com/api/retry\t0.012s"}, "tool": {"name": "Bash", "command": "go test ./..."}, "gen_ai": {"tool": {"name": "Bash", "call": {"id": "toolu_test_3"}}}, "content": {"retention": "full", "included": true}}+{"vendor": "beacon", "product": "endpoint-agent", "schema_version": "1.0", "severity": "info", "endpoint": {"os": "linux"}, "harness": {"name": "claude_code", "collection_method": "hook"}, "session": {"id": "failing", "working_directory": "/work/api"}, "timestamp": "2026-06-16T08:01:00Z", "event": {"id": "fl-lint-pre", "kind": "agent_runtime", "action": "tool.invoked", "category": "tool"}, "message": "Tool invocation observed", "command": {"command": "npm run lint"}, "tool": {"name": "Bash", "command": "npm run lint"}, "gen_ai": {"tool": {"name": "Bash", "call": {"id": "toolu_lint"}}}}+{"vendor": "beacon", "product": "endpoint-agent", "schema_version": "1.0", "severity": "high", "endpoint": {"os": "linux"}, "harness": {"name": "claude_code", "collection_method": "hook"}, "session": {"id": "failing", "working_directory": "/work/api"}, "timestamp": "2026-06-16T08:01:03Z", "event": {"id": "fl-lint", "kind": "agent_runtime", "action": "command.executed", "category": "command"}, "message": "Tool execution observed", "command": {"command": "npm run lint", "exit_code": 2}, "tool": {"name": "Bash", "command": "npm run lint"}, "gen_ai": {"tool": {"name": "Bash", "call": {"id": "toolu_lint"}}}, "content": {"retention": "metadata", "included": false, "hash": "sha256:eee", "bytes": 512}}+{"vendor": "beacon", "product": "endpoint-agent", "schema_version": "1.0", "severity": "info", "endpoint": {"os": "linux"}, "harness": {"name": "claude_code", "collection_method": "hook"}, "session": {"id": "failing", "working_directory": "/work/api"}, "timestamp": "2026-06-16T08:01:10Z", "event": {"id": "fl-gh-1-pre", "kind": "agent_runtime", "action": "tool.invoked", "category": "tool"}, "message": "Tool invocation observed", "mcp": {"server": "github", "tool": "create_issue"}, "tool": {"name": "mcp__github__create_issue"}, "gen_ai": {"tool": {"name": "mcp__github__create_issue", "call": {"id": "toolu_gh_1", "arguments": {"repo": "acme/api", "title": "Flaky TestRetry"}}}}}+{"vendor": "beacon", "product": "endpoint-agent", "schema_version": "1.0", "severity": "high", "endpoint": {"os": "linux"}, "harness": {"name": "claude_code", "collection_method": "hook"}, "session": {"id": "failing", "working_directory": "/work/api"}, "timestamp": "2026-06-16T08:01:11Z", "event": {"id": "fl-gh-1", "kind": "agent_runtime", "action": "tool.failed", "category": "tool"}, "message": "Tool execution failed", "mcp": {"server": "github", "tool": "create_issue"}, "tool": {"name": "mcp__github__create_issue"}, "gen_ai": {"tool": {"name": "mcp__github__create_issue", "call": {"id": "toolu_gh_1", "arguments": {"repo": "acme/api", "title": "Flaky TestRetry"}}}}}+{"vendor": "beacon", "product": "endpoint-agent", "schema_version": "1.0", "severity": "info", "endpoint": {"os": "linux"}, "harness": {"name": "claude_code", "collection_method": "hook"}, "session": {"id": "failing", "working_directory": "/work/api"}, "timestamp": "2026-06-16T08:01:20Z", "event": {"id": "fl-gh-2-pre", "kind": "agent_runtime", "action": "tool.invoked", "category": "tool"}, "message": "Tool invocation observed", "mcp": {"server": "github", "tool": "create_issue"}, "tool": {"name": "mcp__github__create_issue"}, "gen_ai": {"tool": {"name": "mcp__github__create_issue", "call": {"id": "toolu_gh_2", "arguments": {"title": "Flaky TestRetry", "repo": "acme/api"}}}}}+{"vendor": "beacon", "product": "endpoint-agent", "schema_version": "1.0", "severity": "info", "endpoint": {"os": "linux"}, "harness": {"name": "claude_code", "collection_method": "hook"}, "session": {"id": "failing", "working_directory": "/work/api"}, "timestamp": "2026-06-16T08:01:22Z", "event": {"id": "fl-gh-2", "kind": "agent_runtime", "action": "mcp.tool_invoked", "category": "mcp"}, "message": "Tool execution observed", "mcp": {"server": "github", "tool": "create_issue"}, "tool": {"name": "mcp__github__create_issue"}, "gen_ai": {"tool": {"name": "mcp__github__create_issue", "call": {"id": "toolu_gh_2", "arguments": {"title": "Flaky TestRetry", "repo": "acme/api"}, "result": {"content": [{"type": "text", "text": "Created issue #7"}]}}}}}+{"vendor": "beacon", "product": "endpoint-agent", "schema_version": "1.0", "severity": "info", "endpoint": {"os": "linux"}, "harness": {"name": "opencode", "collection_method": "plugin"}, "session": {"id": "erred", "working_directory": "/work/api"}, "timestamp": "2026-06-16T10:00:00Z", "event": {"id": "er-prompt", "kind": "agent_runtime", "action": "prompt.submitted", "category": "prompt"}, "message": "opencode prompt submitted", "prompt": {"text": "Summarize the changelog"}, "content": {"retention": "full", "included": true}}+{"vendor": "beacon", "product": "endpoint-agent", "schema_version": "1.0", "severity": "high", "endpoint": {"os": "linux"}, "harness": {"name": "opencode", "collection_method": "plugin"}, "session": {"id": "erred", "working_directory": "/work/api"}, "timestamp": "2026-06-16T10:00:05Z", "event": {"id": "er-session-error", "kind": "agent_runtime", "action": "session.error", "category": "session"}, "message": "opencode session error", "error": {"type": "ProviderAuthError"}}diff --git a/cli/beacon/internal/endpoint/dashboard/testdata/lens-e2e/tests/builtin-failures.spec.ts b/cli/beacon/internal/endpoint/dashboard/testdata/lens-e2e/tests/builtin-failures.spec.tsnew file mode 100644index 00000000..097d65b0--- /dev/null+++ b/cli/beacon/internal/endpoint/dashboard/testdata/lens-e2e/tests/builtin-failures.spec.ts@@ -0,0 +1,109 @@+import { expect, test } from '@playwright/test';++test('failures: every failed call once, its output, and what the next identical call did', async ({ page }) => {+ await page.goto('/session.html?id=failing&lens=failures');+ const frame = page.frameLocator('iframe.lens-frame');+ await expect(frame.locator('#root')).toBeVisible();++ await expect(frame.locator('#summary')).toHaveText('5 failures: 3 commands, 1 tool call, 1 MCP call.');+ await expect(frame.locator('#notes p').first()).toHaveText(+ 'Of 5 failed calls, 2 succeeded on the next identical call, 1 failed again and 2 had no later identical call.',+ );++ // The OTLP copy of the first test run (#4) shares its call id: it is the same call, not a row of+ // its own and not a later attempt that succeeded.+ const rows = frame.locator('tbody tr:not(.detail)');+ await expect(rows).toHaveCount(5);+ await expect(rows.locator('td:first-child')).toHaveText(['#3', '#6', '#10', '#14', '#16']);++ const firstRun = rows.nth(0).locator('td');+ await expect(firstRun.nth(2)).toHaveText('command');+ await expect(firstRun.nth(3)).toHaveText('go test ./...');+ await expect(firstRun.nth(4)).toHaveText('exit 1');+ await expect(firstRun.nth(5)).toHaveText('failed again at #10');+ await expect(frame.locator('tbody tr.detail pre').first()).toContainText('want 3 attempts, got 2');++ // A successful edit of another file is not a retry of the failed one.+ const edit = rows.nth(1).locator('td');+ await expect(edit.nth(2)).toHaveText('tool call');+ await expect(edit.nth(3)).toHaveText('Edit /work/api/a.go');+ await expect(edit.nth(4)).toHaveText('tool_execution_failed');+ await expect(edit.nth(5)).toHaveText('no later attempt');++ // Claude Code reports a successful command with no exit code; a result that did not fail is the success.+ const secondRun = rows.nth(2).locator('td');+ await expect(secondRun.nth(3)).toHaveText('go test ./...');+ await expect(secondRun.nth(5)).toHaveText('succeeded at #12');++ // Output that was not retained shows its size and hash, never the event's label.+ const lint = rows.nth(3).locator('td');+ await expect(lint.nth(3)).toHaveText('npm run lint');+ await expect(lint.nth(4)).toHaveText('exit 2');+ await expect(lint.nth(5)).toHaveText('no later attempt');+ await expect(rows.nth(3).locator('xpath=following-sibling::tr[1]')).toHaveText(+ 'Output not retained · retention metadata · 512 bytes · sha256:eee.',+ );++ // The retry sent the same arguments in another order.+ const mcp = rows.nth(4).locator('td');+ await expect(mcp.nth(2)).toHaveText('MCP call');+ await expect(mcp.nth(3)).toHaveText('github / create_issue');+ await expect(mcp.nth(4)).toHaveText('tool_execution_failed');+ await expect(mcp.nth(5)).toHaveText('succeeded at #18');+ await expect(frame.locator('#root')).not.toContainText('Tool execution failed');+});++test('failures: an error.type on an event that is not a call counts, as an error', async ({ page }) => {+ await page.goto('/session.html?id=erred&lens=failures');+ const frame = page.frameLocator('iframe.lens-frame');+ await expect(frame.locator('#summary')).toHaveText('1 failure: 1 error.');+ const cells = frame.locator('tbody tr:not(.detail)').locator('td');+ await expect(cells.nth(3)).toHaveText('session.error');+ await expect(cells.nth(4)).toHaveText('ProviderAuthError');+ await expect(cells.nth(5)).toHaveText('—');+ await expect(frame.locator('#notes')).toBeEmpty();+});++test('failures: an MCP call that kept its own action but carries error.type counts', async ({ page }) => {+ await page.goto('/session.html?id=mcpish&lens=failures');+ const frame = page.frameLocator('iframe.lens-frame');+ await expect(frame.locator('tbody tr:not(.detail)').filter({ hasText: 'linear / list_teams' })).toHaveCount(1);+});++test('failures: a trace where nothing failed says so', async ({ page }) => {+ await page.goto('/session.html?id=gated&lens=failures');+ const frame = page.frameLocator('iframe.lens-frame');+ await expect(frame.locator('#root')).toContainText('Nothing failed in this trace');+ await expect(frame.locator('table')).toBeHidden();+});++test('failures: a long list pages, and later attempts past the first page still count', async ({ page }) => {+ // Serve the real lens data with its events replaced: 250 failed commands, then a success of the first.+ await page.route('**/api/lens-data?*', async (route) => {+ const response = await route.fetch();+ const data = await response.json();+ const events = Array.from({ length: 250 }, (_, i) => ({+ id: `cmd-${i}`, number: i + 1, timestamp: '2026-06-16T08:00:00Z', type: 'command', action: 'command.executed',+ command: { command: `step ${i}`, exit_code: 1 },+ }));+ events.push({ id: 'cmd-ok', number: 251, timestamp: '2026-06-16T08:10:00Z', type: 'command', action: 'command.executed', command: { command: 'step 0', exit_code: 0 } });+ data.trace.events = events;+ data.trace.summary.event_count = events.length;+ await route.fulfill({ response, json: data });+ });+ await page.goto('/session.html?id=failing&lens=failures');+ const frame = page.frameLocator('iframe.lens-frame');+ await expect(frame.locator('#summary')).toHaveText('250 failures: 250 commands.');+ const rows = frame.locator('tbody tr:not(.detail)');+ const more = frame.locator('button.more');+ await expect(rows).toHaveCount(100);+ await expect(rows.nth(0).locator('td').nth(5)).toHaveText('succeeded at #251');+ await expect(rows.nth(1).locator('td').nth(5)).toHaveText('no later attempt');+ await expect(more).toHaveText('Show more (150 left)');+ await more.click();+ await expect(rows).toHaveCount(200);+ await expect(more).toHaveText('Show more (50 left)');+ await more.click();+ await expect(rows).toHaveCount(250);+ await expect(more).toHaveCount(0);+});diff --git a/docs/changelog/cli.mdx b/docs/changelog/cli.mdxindex d49d6938..a2ab1c6e 100644--- a/docs/changelog/cli.mdx+++ b/docs/changelog/cli.mdx@@ -13,6 +13,8 @@ Stay up to date with the latest changes to the Agent Beacon CLI.Changes on `main` since v1.3.58. They ship in the next release.+- **Failures lens** · A new built-in lens lists everything that went wrong in a session, in order: commands that exited non-zero, tool and MCP calls the runtime reported as failed, and error events, each with the output that explains it, or the output's hash and size when the log did not keep it. A call reported by both a hook and OpenTelemetry is listed once. For each failed call it says what the next identical call did -- the same command line, the same tool on the same path, or the same MCP tool with the same arguments: succeeded, failed again, or never came. Long lists page with **Show more**. See [Lenses](/concepts/lenses#built-in-lenses).+- **Failed tool calls carry an error type in traces** · Runtimes that report a failed tool call through hooks (Claude Code, Cursor, Qwen Code, OpenHands, Kiro, Kimi Code and others) logged it as `tool.failed` with no `error`, so in the dashboard's trace view, lenses and shared traces the failure had no `error.type`, though the lenses spec promises one for every action the runtime reported as failed. A `tool.failed` without an error type of its own now gets `error.type` `tool_execution_failed`, the type the session-sync mappers already give a failed tool result. Stored dashboard history is re-derived on the next read, and the runtime log is unchanged.- **Antigravity CLI hooks now run** · Beacon wrote its Antigravity hooks to `~/.gemini/config/hooks.json` and `./.agents/hooks.json` in a grouped lifecycle schema that Antigravity does not run, so none of them ever fired and Antigravity sessions recorded nothing. `beacon endpoint hooks install --harness antigravity` now writes the schema Antigravity runs: `SessionStart` and `Stop` handlers, and `PreToolUse` and `PostToolUse` for every tool. The first prompt of a session is recovered from its transcript on the first tool call, and is recorded once even when the conversation is resumed up to 14 days later. Hooks in the old schema are reported as needing a reinstall: `beacon endpoint hooks status` shows `needs_reinstall=true`, discovery and `beacon endpoint doctor` warn that Beacon's Antigravity hooks use the legacy schema, and the dashboard marks them. Package repair rewrites user-level hooks; for project-level hooks, rerun `beacon endpoint hooks install --harness antigravity --level project`.diff --git a/docs/cloud/lenses/adding-lenses.mdx b/docs/cloud/lenses/adding-lenses.mdxindex 096e093b..ff5e3c63 100644--- a/docs/cloud/lenses/adding-lenses.mdx+++ b/docs/cloud/lenses/adding-lenses.mdx@@ -20,6 +20,7 @@ Every session already has these. Select **+** on a session's tab bar to open one| **Approvals & Policy** | Operator and policy decisions || **Skills** | Skills loaded during the session || **MCP Calls** | Calls grouped by server and tool |+| **Failures** | Failed commands and calls, and whether a retry worked |## Browse the marketplacediff --git a/docs/concepts/lenses.mdx b/docs/concepts/lenses.mdxindex faa74fbf..e56af98c 100644--- a/docs/concepts/lenses.mdx+++ b/docs/concepts/lenses.mdx@@ -15,7 +15,7 @@ Lenses are tabs on a session's page in the local dashboardadd one; the dashboard remembers which lenses you opened and keeps the selected one in thepage URL, so a link opens straight to it.-Beacon ships seven lenses, and you can add your own. A lens is one HTML file, so any coding+Beacon ships eight lenses, and you can add your own. A lens is one HTML file, so any codingagent can write one.## Built-in lenses@@ -29,6 +29,7 @@ agent can write one.| **Approvals & Policy** | Every approval decision in order: allowed or denied, whether the operator or a policy provider (the optional `BEACON_POLICY_PROVIDER` seam) decided, what it was about, and whether the runtime reported it or Beacon inferred it. || **Skills** | Every skill the agent loaded, where each entered the run (the event, and the prompt it came under) and how (a skill tool call, a read of a `SKILL.md`, or a shell command that printed one), and the exact instructions the agent received, when the runtime reported them and the log retained them. A load whose text was not retained shows its hash and size instead. || **MCP Calls** | Every MCP tool call, grouped by server and then by tool, with how many calls each tool took and how many failed. Each call shows when it ran, its method and resource URI where the runtime reported them, and the arguments the agent sent and the result that came back. A call whose result reports `isError` or an error is marked failed. |+| **Failures** | Everything that went wrong, in order: commands that exited non-zero, tool and MCP calls the runtime reported as failed, and error events, each with the output or result that explains it, or the output's hash and size when it was not retained. A call reported twice (by a hook and by OpenTelemetry) is listed once. For each failed call it says what the next identical call did (the same command line, the same tool on the same path, or the same MCP tool with the same arguments): succeeded, failed again, or never came. |## How a lens runs