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
Treat the turn-end event after a share as the share's own
Claude9117c9edb0da
diff --git a/cli/beacon/internal/endpoint/dashboard/history_store.go b/cli/beacon/internal/endpoint/dashboard/history_store.goindex 6a4f8f05..a34a41a8 100644--- a/cli/beacon/internal/endpoint/dashboard/history_store.go+++ b/cli/beacon/internal/endpoint/dashboard/history_store.go@@ -41,7 +41,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 = 8 // 2: trace events carry the event's policy block; 3: and its error; 4: usage carries the 1h cache-write split; 5: sharing goes stale on newer activity and carries a refresh command; 6: staleness compares against what a share covered (shared_through); 7: a share's own events (its command, the reply about it) do not make it stale; 8: only when the session holds the share call+ historyDerivationVersion = 9 // 2: trace events carry the event's policy block; 3: and its error; 4: usage carries the 1h cache-write split; 5: sharing goes stale on newer activity and carries a refresh command; 6: staleness compares against what a share covered (shared_through); 7: a share's own events (its command, the reply about it) do not make it stale; 8: only when the session holds the share call; 9: and the turn-end event after itdefaultHistoryRetentionDays = 90// maxHistoryRetentionDays is 100 years: a retention this long or longer means nothing expires.diff --git a/cli/beacon/internal/endpoint/dashboard/share_activity.go b/cli/beacon/internal/endpoint/dashboard/share_activity.goindex c2a469d1..607e5c54 100644--- a/cli/beacon/internal/endpoint/dashboard/share_activity.go+++ b/cli/beacon/internal/endpoint/dashboard/share_activity.go@@ -90,12 +90,16 @@ func isShareCallEvent(event schema.Event) bool {return event.Tool != nil && isBeaconShareCommand(event.Tool.Command)}-// isAssistantOutput is an event that only carries the agent's own output or what it cost: no-// prompt, tool call, command or file activity.+// isAssistantOutput is an event that only carries the agent's own output, what it cost, or the end+// of its turn: no prompt, tool call, command or file activity. Turn ends include Claude Code's Stop+// hook ("Agent response completed": tool.completed with no tool call id and no tool, command or+// file payload) and the plugin runtimes' agent.response / agent.response.completed.func isAssistantOutput(event schema.Event) bool {switch event.Event.Action {- case "agent.message", "agent.reasoning", "token.usage":+ case "agent.message", "agent.reasoning", "token.usage", "agent.response", "agent.response.completed":return true+ case "tool.completed":+ return isPayloadlessTurnEnd(event)}if event.Command != nil || event.Tool != nil || event.File != nil || event.MCP != nil {return false@@ -149,3 +153,15 @@ func shareRelevantRecord(record EventRecord) EventRecord {}return EventRecord{ID: record.ID, Line: record.Line, Event: slim, Parsed: record.Parsed}}++// isPayloadlessTurnEnd is a completion event that names no tool call: no call id and no tool,+// command, file or MCP payload, which is how a turn-end hook (Claude Code's Stop) records itself.+func isPayloadlessTurnEnd(event schema.Event) bool {+ if asymptoteobserve.ToolCallID(&event) != "" || event.Command != nil || event.File != nil || event.MCP != nil {+ return false+ }+ if event.Tool != nil && (event.Tool.Name != "" || event.Tool.Command != "" || event.Tool.Path != "") {+ return false+ }+ return true+}diff --git a/cli/beacon/internal/endpoint/dashboard/sharing_view_test.go b/cli/beacon/internal/endpoint/dashboard/sharing_view_test.goindex 74565aae..f0add59a 100644--- a/cli/beacon/internal/endpoint/dashboard/sharing_view_test.go+++ b/cli/beacon/internal/endpoint/dashboard/sharing_view_test.go@@ -178,6 +178,8 @@ func TestShareFromInsideTheSessionIsNotStale(t *testing.T) {`{"timestamp":"2026-06-11T10:00:10Z","event":{"id":"e4","action":"tool.completed","category":"tool"},"harness":{"name":"claude_code"},"session":{"id":"in1"},"prompt":{"id":"p1"},"tool":{"name":"Bash"},"gen_ai":{"tool":{"call":{"id":"call-share"}}}}`,`{"timestamp":"2026-06-11T10:00:11Z","event":{"id":"e5","action":"command.executed","category":"command"},"harness":{"name":"claude_code"},"session":{"id":"in1"},"prompt":{"id":"p1"},"command":{"command":"beacon share --current"}}`,`{"timestamp":"2026-06-11T10:00:15Z","event":{"id":"e6","action":"agent.message","category":"agent"},"harness":{"name":"claude_code"},"session":{"id":"in1"},"prompt":{"id":"p1"},"message":"Shared: https://beacon.sh/s/in1"}`,+ // Claude Code's Stop hook ends the turn.+ `{"timestamp":"2026-06-11T10:00:16Z","event":{"id":"e6s","action":"tool.completed","category":"tool"},"harness":{"name":"claude_code","collection_method":"hook"},"session":{"id":"in1"},"prompt":{"id":"p1"},"message":"Agent response completed"}`,}check := func(t *testing.T, lines []string, want string) {t.Helper()@@ -209,6 +211,12 @@ func TestShareFromInsideTheSessionIsNotStale(t *testing.T) {`{"timestamp":"2026-06-11T10:05:00Z","event":{"id":"e7","action":"tool.invoked","category":"tool"},"harness":{"name":"claude_code"},"session":{"id":"in1"},"prompt":{"id":"p1"},"tool":{"name":"Edit","path":"main.go"},"gen_ai":{"tool":{"call":{"id":"call-edit"}}}}`,), "stale")})+ t.Run("turn end after a later prompt", func(t *testing.T) {+ check(t, append(append([]string{}, inside...),+ `{"timestamp":"2026-06-11T10:05:00Z","event":{"id":"e9","action":"prompt.submitted","category":"prompt"},"harness":{"name":"claude_code"},"session":{"id":"in1"},"prompt":{"id":"p3","text":"one more thing"}}`,+ `{"timestamp":"2026-06-11T10:05:30Z","event":{"id":"e10","action":"tool.completed","category":"tool"},"harness":{"name":"claude_code","collection_method":"hook"},"session":{"id":"in1"},"prompt":{"id":"p3"},"message":"Agent response completed"}`,+ ), "stale")+ })t.Run("reply after later work", func(t *testing.T) {check(t, append(append([]string{}, inside...),`{"timestamp":"2026-06-11T10:05:00Z","event":{"id":"e8","action":"prompt.submitted","category":"prompt"},"harness":{"name":"claude_code"},"session":{"id":"in1"},"prompt":{"id":"p2","text":"now fix the bug"}}`,