Skip to content

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

fix: preserve cross-harness event dedupe

Cursor Agentbc55d288c2cc
diff --git a/pkg/asymptoteobserve/dedupe.go b/pkg/asymptoteobserve/dedupe.go
index 6a6844fb..7a1e5a72 100644
--- a/pkg/asymptoteobserve/dedupe.go
+++ b/pkg/asymptoteobserve/dedupe.go
@@ -45,8 +45,10 @@ func IsDuplicateEndpointEvent(path string, candidateLine []byte, window time.Dur
// Same-harness events are normally preserved because two adjacent calls
// can legitimately target the same file or command. A stable tool call
// ID makes an exact duplicate safe to collapse.
- if existing.harness == candidate.harness && (existing.callID == "" || candidate.callID == "") {
- continue
+ if existing.harness == candidate.harness {
+ if existing.callID == "" || candidate.callID == "" || existing.callID != candidate.callID {
+ continue
+ }
}
diff := candidate.ts.Sub(existing.ts)
if diff < 0 {
@@ -118,7 +120,6 @@ func endpointDedupeCandidate(line []byte) (endpointDedupeEvent, bool) {
sessionID,
strings.ToLower(workspace),
target,
- callID,
}, "\x00")
return endpointDedupeEvent{action: strings.ToLower(action), harness: harness, key: key, callID: callID, ts: ts.UTC()}, true
}
diff --git a/pkg/asymptoteobserve/dedupe_test.go b/pkg/asymptoteobserve/dedupe_test.go
index 25b09797..0e45c543 100644
--- a/pkg/asymptoteobserve/dedupe_test.go
+++ b/pkg/asymptoteobserve/dedupe_test.go
@@ -58,6 +58,32 @@ func TestIsDuplicateEndpointEventCollapsesSameHarnessCallID(t *testing.T) {
}
}
+func TestIsDuplicateEndpointEventKeepsDifferentSameHarnessCallIDs(t *testing.T) {
+ path := filepath.Join(t.TempDir(), "runtime.jsonl")
+ existing := `{"timestamp":"2026-06-18T21:11:24Z","event":{"action":"tool.completed"},"harness":{"name":"opencode"},"session":{"id":"s1"},"tool":{"name":"webfetch"},"gen_ai":{"tool":{"name":"webfetch","call":{"id":"call_1"}}},"message":"opencode tool completed"}`
+ candidate := []byte(`{"timestamp":"2026-06-18T21:11:25Z","event":{"action":"tool.completed"},"harness":{"name":"opencode"},"session":{"id":"s1"},"tool":{"name":"webfetch"},"gen_ai":{"tool":{"name":"webfetch","call":{"id":"call_2"}}},"message":"opencode tool completed"}`)
+ if err := os.WriteFile(path, []byte(existing+"\n"), 0644); err != nil {
+ t.Fatalf("write existing event: %v", err)
+ }
+
+ if IsDuplicateEndpointEvent(path, candidate, EndpointDuplicateWindow) {
+ t.Fatal("different same-harness call IDs should not dedupe")
+ }
+}
+
+func TestIsDuplicateEndpointEventIgnoresCallIDDifferencesAcrossHarnesses(t *testing.T) {
+ path := filepath.Join(t.TempDir(), "runtime.jsonl")
+ existing := `{"timestamp":"2026-06-18T21:11:24Z","event":{"action":"tool.invoked"},"harness":{"name":"opencode"},"session":{"id":"s1"},"tool":{"name":"read","path":"/repo/a.go"},"gen_ai":{"tool":{"name":"read","call":{"id":"opencode_1"}}},"message":"Tool execution observed"}`
+ candidate := []byte(`{"timestamp":"2026-06-18T21:11:25Z","event":{"action":"tool.invoked"},"harness":{"name":"otel"},"session":{"id":"s1"},"tool":{"name":"read","path":"/repo/a.go"},"gen_ai":{"tool":{"name":"read","call":{"id":"span_9"}}},"message":"Tool execution observed"}`)
+ if err := os.WriteFile(path, []byte(existing+"\n"), 0644); err != nil {
+ t.Fatalf("write existing event: %v", err)
+ }
+
+ if !IsDuplicateEndpointEvent(path, candidate, EndpointDuplicateWindow) {
+ t.Fatal("cross-harness duplicates should ignore call ID differences")
+ }
+}
+
func TestIsDuplicateEndpointEventRequiresSession(t *testing.T) {
path := filepath.Join(t.TempDir(), "runtime.jsonl")
existing := `{"timestamp":"2026-06-18T21:11:24Z","event":{"action":"mcp.tool_invoked"},"harness":{"name":"cursor"},"mcp":{"tool":"list_tables"}}`