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(trace): give tool.failed an error.type in the trace projection (#1229)
kyle-elliott-asymptote2f695729b2af
diff --git a/agent-skills/skills/beacon-lens-create/SKILL.md b/agent-skills/skills/beacon-lens-create/SKILL.mdindex 3400730a..ba4bfbbb 100644--- a/agent-skills/skills/beacon-lens-create/SKILL.md+++ b/agent-skills/skills/beacon-lens-create/SKILL.md@@ -96,7 +96,9 @@ The result is `LensDataV1`; `beacon lenses spec` has the full shape. The parts y- `trace.events[]`, in order, each with `id`, `number`, `timestamp`, `type`, `action` andoptional `title`, `summary`, `fidelity`, `content`, `tool`, `command`, `file`, `mcp`,`approval`, `policy`, `error`, `model`, `usage`, `tool_call_id`. `error.type` is set when the- runtime reported the action as failed, even on an event whose `type` is not `error`. `type` is one of `user_message`,+ runtime reported the action as failed, even on an event whose `type` is not `error`; every+ `tool.failed` is a `tool_result` that carries one (`tool_execution_failed` when the runtime named+ no type). `type` is one of `user_message`,`agent_message`, `agent_reasoning`, `tool_call`, `tool_result`, `command`, `file`, `mcp`,`approval`, `token_usage`, `session`, `error`, `other`, and the list can grow.- `findings`: threat-rule matches, each pointing at its evidence by `event_ids`.diff --git a/cli/beacon/internal/agentskills/skills/beacon-lens-create/SKILL.md b/cli/beacon/internal/agentskills/skills/beacon-lens-create/SKILL.mdindex 3400730a..ba4bfbbb 100644--- a/cli/beacon/internal/agentskills/skills/beacon-lens-create/SKILL.md+++ b/cli/beacon/internal/agentskills/skills/beacon-lens-create/SKILL.md@@ -96,7 +96,9 @@ The result is `LensDataV1`; `beacon lenses spec` has the full shape. The parts y- `trace.events[]`, in order, each with `id`, `number`, `timestamp`, `type`, `action` andoptional `title`, `summary`, `fidelity`, `content`, `tool`, `command`, `file`, `mcp`,`approval`, `policy`, `error`, `model`, `usage`, `tool_call_id`. `error.type` is set when the- runtime reported the action as failed, even on an event whose `type` is not `error`. `type` is one of `user_message`,+ runtime reported the action as failed, even on an event whose `type` is not `error`; every+ `tool.failed` is a `tool_result` that carries one (`tool_execution_failed` when the runtime named+ no type). `type` is one of `user_message`,`agent_message`, `agent_reasoning`, `tool_call`, `tool_result`, `command`, `file`, `mcp`,`approval`, `token_usage`, `session`, `error`, `other`, and the list can grow.- `findings`: threat-rule matches, each pointing at its evidence by `event_ids`.diff --git a/cli/beacon/internal/endpoint/dashboard/history_browser_messages_test.go b/cli/beacon/internal/endpoint/dashboard/history_browser_messages_test.goindex a281eda6..8b23c9f6 100644--- a/cli/beacon/internal/endpoint/dashboard/history_browser_messages_test.go+++ b/cli/beacon/internal/endpoint/dashboard/history_browser_messages_test.go@@ -92,8 +92,8 @@ func TestHistoryRebuildsVersion15LegacyBrowserMessages(t *testing.T) {t.Fatal(err)}defer store.close()- if version := store.metaInt("derivation_version", 0); version != 16 {- t.Fatalf("derivation version=%d, want 16 (actual predecessor 15)", version)+ if version := store.metaInt("derivation_version", 0); version != historyDerivationVersion {+ t.Fatalf("derivation version=%d, want %d (seeded from actual predecessor 15)", version, historyDerivationVersion)}var rowID int64var count intdiff --git a/cli/beacon/internal/endpoint/dashboard/history_store.go b/cli/beacon/internal/endpoint/dashboard/history_store.goindex 152becbd..11ca65bf 100644--- a/cli/beacon/internal/endpoint/dashboard/history_store.go+++ b/cli/beacon/internal/endpoint/dashboard/history_store.go@@ -43,7 +43,7 @@ const (// historyDerivationVersion covers everything computed from a stored line: trace keys, event// numbers, types, summaries and search text. Bump it when that projection changes; the next// catch-up recomputes it from the stored lines, so history survives the change.- historyDerivationVersion = 16 // 16: retained browser role/text messages are readable; 15: completed assistant responses and plans retain their answer; 14: trace labels preserve UTF-8 at byte limits; 2: trace events carry the event's policy block; 3: and its error; 4: usage carries the 1h cache-write split; 5: agent.response is an agent message; 6: the summary names its project; 7-11 were the sharing-staleness steps on a parallel branch; 12: sharing goes stale on activity after what a share covered (shared_through), ignoring a share's own events and events the share projection skips, and carries a refresh command; 13: redaction recognizes more credential shapes, so trace text and search text change+ historyDerivationVersion = 17 // 17: a tool.failed without an error of its own carries error.type tool_execution_failed; 16: retained browser role/text messages are readable; 15: completed assistant responses and plans retain their answer; 14: trace labels preserve UTF-8 at byte limits; 2: trace events carry the event's policy block; 3: and its error; 4: usage carries the 1h cache-write split; 5: agent.response is an agent message; 6: the summary names its project; 7-11 were the sharing-staleness steps on a parallel branch; 12: sharing goes stale on activity after what a share covered (shared_through), ignoring a share's own events and events the share projection skips, and carries a refresh command; 13: redaction recognizes more credential shapes, so trace text and search text changedefaultHistoryRetentionDays = 90// maxHistoryRetentionDays is 100 years: a retention this long or longer means nothing expires.diff --git a/cli/beacon/internal/endpoint/dashboard/lenses/SPEC.md b/cli/beacon/internal/endpoint/dashboard/lenses/SPEC.mdindex c7cf70aa..f3ba9375 100644--- a/cli/beacon/internal/endpoint/dashboard/lenses/SPEC.md+++ b/cli/beacon/internal/endpoint/dashboard/lenses/SPEC.md@@ -113,7 +113,9 @@ trace view uses. Its main parts:`model`, `usage`, `tool_call_id`, `prompt_id` (the turn the event belongs to,where the runtime names one) and `trace` (span IDs). `error.type` is setwhen the runtime reported the action as failed, which can happen on an event- whose `type` is not `error` (a failed MCP call keeps type `mcp`).+ whose `type` is not `error` (a failed MCP call keeps type `mcp`). Every+ `tool.failed` carries one: it is a `tool_result`, with `error.type`+ `tool_execution_failed` when the runtime named no type of its own.- `type` is one of `user_message`, `agent_message`, `agent_reasoning`,`tool_call`, `tool_result`, `command`, `file`, `mcp`, `approval`,`token_usage`, `session`, `error` or `other`. The list may grow (see@@ -308,3 +310,4 @@ warns on the features above.`<link>` elements, speculation rules and `document.write`, and turns off DNSprefetching. A lens that follows this spec uses none of them; the[trust model](#trust-model) says what this does and does not guarantee.+- `lenses/v1` (clarification): every `tool.failed` event carries `error.type`.diff --git a/docs/changelog/cli.mdx b/docs/changelog/cli.mdxindex 08fa67c5..d49d6938 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.+- **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`.- **Beacon leaves your own hooks alone when their command mentions `beacon-hooks`** · Install, repair and uninstall used to claim any hook whose command merely contained `beacon-hooks` -- a script like `~/scripts/my-beacon-hooks-wrapper.sh`, `echo beacon-hooks`, or a log file named `beacon-hooks.log` -- as one Beacon had written, so they overwrote or deleted it, and the DeepSeek Harness and Kiro installers replaced a hooks file they should have refused to touch. A hook now counts as Beacon's only when the program it runs is the hooks binary itself and the command carries the endpoint settings an install writes. This applies to every runtime (Cursor, Hermes, VS Code, Kimi Code, OpenHands, Devin, DeepSeek Harness, Kiro and the rest), and `beacon endpoint hooks status` and discovery agree with what uninstall would remove.diff --git a/pkg/asymptoteobserve/trace.go b/pkg/asymptoteobserve/trace.goindex 364a6c75..76ec7052 100644--- a/pkg/asymptoteobserve/trace.go+++ b/pkg/asymptoteobserve/trace.go@@ -213,6 +213,11 @@ type TraceErrorV1 struct {Type string `json:"type,omitempty"`}+// ToolFailedErrorType is the error.type a trace event gets when its source is a tool.failed that+// carried no error of its own, as hook adapters write them. It is the type the session mappers+// already give a failed tool result.+const ToolFailedErrorType = "tool_execution_failed"+// TraceUsageV1 is gen_ai.usage flattened. CacheCreation1hInputTokens is the subset of// CacheCreationInputTokens written with a one-hour TTL, where the source reported it; like// ReasoningOutputTokens it is a breakdown and never part of a total.diff --git a/pkg/asymptoteobserve/tracebuild.go b/pkg/asymptoteobserve/tracebuild.goindex 1bf6c158..6cdec3ef 100644--- a/pkg/asymptoteobserve/tracebuild.go+++ b/pkg/asymptoteobserve/tracebuild.go@@ -166,6 +166,11 @@ func TraceEventFromEvent(event Event, fallbackID string, number int) TraceEventV}if event.Error != nil && event.Error.Type != "" {te.Error = &TraceErrorV1{Type: event.Error.Type}+ } else if strings.EqualFold(strings.TrimSpace(event.Event.Action), "tool.failed") {+ // Hook adapters report a failed call as tool.failed and say nothing under error, so the+ // action alone carries the failure. error.type is what a reader of the trace checks for+ // one, so the projection names it rather than leaving tool.failed the one failure without it.+ te.Error = &TraceErrorV1{Type: ToolFailedErrorType}}if event.Approval != nil {te.Approval = &TraceApprovalV1{Required: event.Approval.Required, Decision: event.Approval.Decision, Reason: event.Approval.Reason}diff --git a/pkg/asymptoteobserve/tracebuild_test.go b/pkg/asymptoteobserve/tracebuild_test.goindex e75a40f0..df08035e 100644--- a/pkg/asymptoteobserve/tracebuild_test.go+++ b/pkg/asymptoteobserve/tracebuild_test.go@@ -49,6 +49,35 @@ func TestTraceEventFromEvent(t *testing.T) {}}+func TestToolFailedProjectsAnErrorType(t *testing.T) {+ // Shaped as the hook adapter writes them: Claude Code's PostToolUseFailure and Cursor's+ // postToolUseFailure, which puts its message under tool.error. Neither carries error.+ for name, line := range map[string]string{+ "claude": `{"timestamp":"2026-10-01T10:00:03Z","event":{"id":"failed-claude","action":"tool.failed","category":"tool","severity":"high"},"harness":{"name":"claude","collection_method":"hook"},"session":{"id":"s"},"message":"Tool execution failed","tool":{"name":"Read","path":"/tmp/missing"}}`,+ "cursor": `{"timestamp":"2026-10-01T10:00:03Z","event":{"id":"failed-cursor","action":"tool.failed","category":"tool","severity":"high"},"harness":{"name":"cursor","collection_method":"hook"},"session":{"id":"s"},"message":"Tool execution failed","tool":{"name":"Read","failure_type":"error","error":"ENOENT"}}`,+ } {+ var event Event+ if err := json.Unmarshal([]byte(line), &event); err != nil {+ t.Fatal(err)+ }+ te := TraceEventFromEvent(event, "", 1)+ if te.Type != "tool_result" || te.Error == nil || te.Error.Type != ToolFailedErrorType {+ t.Fatalf("%s: type=%q error=%+v, want tool_result with error.type %q", name, te.Type, te.Error, ToolFailedErrorType)+ }+ }++ reported := shareEventAt("2026-10-01T10:00:04Z", "copilot", CollectionMethodPoll, "tool.failed", "tool")+ reported.Error = &ErrorInfo{Type: "mcp_timeout"}+ if te := TraceEventFromEvent(reported, "", 2); te.Error == nil || te.Error.Type != "mcp_timeout" {+ t.Fatalf("reported error = %+v, want mcp_timeout kept", te.Error)+ }++ completed := shareEventAt("2026-10-01T10:00:05Z", "claude", CollectionMethodHook, "tool.completed", "tool")+ if te := TraceEventFromEvent(completed, "", 3); te.Type != "tool_result" || te.Error != nil {+ t.Fatalf("completed: type=%q error=%+v, want tool_result without error", te.Type, te.Error)+ }+}+func TestAssistantActionsRetainTheirAnswerInTraceMessages(t *testing.T) {for _, tc := range []struct{ action, category string }{{"agent.message", "agent"},diff --git a/spec/lenses/SPEC.md b/spec/lenses/SPEC.mdindex c7cf70aa..f3ba9375 100644--- a/spec/lenses/SPEC.md+++ b/spec/lenses/SPEC.md@@ -113,7 +113,9 @@ trace view uses. Its main parts:`model`, `usage`, `tool_call_id`, `prompt_id` (the turn the event belongs to,where the runtime names one) and `trace` (span IDs). `error.type` is setwhen the runtime reported the action as failed, which can happen on an event- whose `type` is not `error` (a failed MCP call keeps type `mcp`).+ whose `type` is not `error` (a failed MCP call keeps type `mcp`). Every+ `tool.failed` carries one: it is a `tool_result`, with `error.type`+ `tool_execution_failed` when the runtime named no type of its own.- `type` is one of `user_message`, `agent_message`, `agent_reasoning`,`tool_call`, `tool_result`, `command`, `file`, `mcp`, `approval`,`token_usage`, `session`, `error` or `other`. The list may grow (see@@ -308,3 +310,4 @@ warns on the features above.`<link>` elements, speculation rules and `document.write`, and turns off DNSprefetching. A lens that follows this spec uses none of them; the[trust model](#trust-model) says what this does and does not guarantee.+- `lenses/v1` (clarification): every `tool.failed` event carries `error.type`.