Skip to content

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

Queue only explicit invocations to wait for a result

Claudeb86b04a0de03
diff --git a/pkg/asymptoteobserve/share.go b/pkg/asymptoteobserve/share.go
index d1750771..f9d2ce16 100644
--- a/pkg/asymptoteobserve/share.go
+++ b/pkg/asymptoteobserve/share.go
@@ -672,6 +672,7 @@ func (b *shareBuilder) addTool(item shareEvent) {
callID := ToolCallID(&event)
toolName := shareToolName(event)
invocation := isShareInvocation(event)
+ explicit := invocation
completion := !invocation && isShareCompletion(event)
if !invocation && !completion {
@@ -703,7 +704,9 @@ func (b *shareBuilder) addTool(item shareEvent) {
message := b.append(item, ShareRoleAssistant, shareToolCallText(call), SharePartV1{Type: SharePartToolCall, Content: call})
b.calls[callID] = call
b.callMessage[callID] = message
- if !named {
+ // Only an explicit invocation waits for a result. A phase-less event promoted to a call
+ // is already whole; queuing it would turn the next read of the same file into its result.
+ if !named && explicit {
b.pending = append(b.pending, callID)
}
return
diff --git a/pkg/asymptoteobserve/share_test.go b/pkg/asymptoteobserve/share_test.go
index f765efe7..a9738cd0 100644
--- a/pkg/asymptoteobserve/share_test.go
+++ b/pkg/asymptoteobserve/share_test.go
@@ -497,3 +497,20 @@ func TestPathScrubberReplacesWholePathsOnly(t *testing.T) {
t.Errorf("windows text = %q", got)
}
}
+
+func TestBuildShareMessagesKeepsRepeatedPhaselessCallsApart(t *testing.T) {
+ // Cursor's beforeReadFile records file.read with a path and nothing else. Reading the same file
+ // twice is two calls, not a call and its result.
+ var events []Event
+ for i, ts := range []string{"2026-10-01T10:00:00Z", "2026-10-01T10:00:01Z", "2026-10-01T10:00:02Z"} {
+ read := shareEventAt(ts, "cursor", CollectionMethodHook, "file.read", "file")
+ read.Event.ID = "r-" + string(rune('a'+i))
+ read.File = &FileInfo{Path: "/home/dev/src/app/main.go", Operation: "read"}
+ events = append(events, read)
+ }
+ messages := BuildShareMessagesWithOptions(events, shareTestOpts)
+ want := "assistant/tool_call,assistant/tool_call,assistant/tool_call"
+ if got := partsOf(t, messages); strings.Join(got, ",") != want {
+ t.Fatalf("parts = %v", got)
+ }
+}