Skip to content

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

Fix multi-step usage event dedup and safe async dispose in opencode plugin

Cursor Agentfadd702750f2
diff --git a/cli/beacon/internal/endpoint/hooks/assets/opencode/beacon.ts b/cli/beacon/internal/endpoint/hooks/assets/opencode/beacon.ts
index 4725609a..f8bc8432 100644
--- a/cli/beacon/internal/endpoint/hooks/assets/opencode/beacon.ts
+++ b/cli/beacon/internal/endpoint/hooks/assets/opencode/beacon.ts
@@ -323,7 +323,7 @@ export const BeaconEndpointPlugin = async ({ project, directory, worktree, clien
flushMessageParts(info.id, sid, model, info?.time?.completed)
if (info?.id) {
if (completedMessages.has(info.id)) return
- completedMessages.add(info.id)
+ if (!info.finish || info.finish === "stop") completedMessages.add(info.id)
}
}
if (type === "message.part.delta") {
@@ -603,7 +603,7 @@ export default {
return async () => {
controller.abort()
await consuming
- await Promise.all(registrations.map((item) => item.dispose?.().catch(() => undefined)))
+ await Promise.all(registrations.map((item) => Promise.resolve(item.dispose?.()).catch(() => undefined)))
}
},
}
diff --git a/plugins/opencode-beacon/src/beacon.ts b/plugins/opencode-beacon/src/beacon.ts
index 4725609a..f8bc8432 100644
--- a/plugins/opencode-beacon/src/beacon.ts
+++ b/plugins/opencode-beacon/src/beacon.ts
@@ -323,7 +323,7 @@ export const BeaconEndpointPlugin = async ({ project, directory, worktree, clien
flushMessageParts(info.id, sid, model, info?.time?.completed)
if (info?.id) {
if (completedMessages.has(info.id)) return
- completedMessages.add(info.id)
+ if (!info.finish || info.finish === "stop") completedMessages.add(info.id)
}
}
if (type === "message.part.delta") {
@@ -603,7 +603,7 @@ export default {
return async () => {
controller.abort()
await consuming
- await Promise.all(registrations.map((item) => item.dispose?.().catch(() => undefined)))
+ await Promise.all(registrations.map((item) => Promise.resolve(item.dispose?.()).catch(() => undefined)))
}
},
}