Skip to content

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

fix(opencode): release arguments of failed tools (#843)

Rudy Mizrahi Celeklif70325d5845b
diff --git a/cli/beacon/internal/endpoint/hooks/assets/opencode/beacon.ts b/cli/beacon/internal/endpoint/hooks/assets/opencode/beacon.ts
index f8bc8432..071b2932 100644
--- a/cli/beacon/internal/endpoint/hooks/assets/opencode/beacon.ts
+++ b/cli/beacon/internal/endpoint/hooks/assets/opencode/beacon.ts
@@ -176,6 +176,8 @@ export const BeaconEndpointPlugin = async ({ project, directory, worktree, clien
if (next.type === "tool") {
const status = next.state?.status
if (status !== "completed" && status !== "error") return
+ // A failed tool never reaches tool.execute.after, which is what releases its arguments.
+ if (status === "error") activeCalls.delete(next.callID)
if (status === "completed" && completedCalls.has(next.callID)) return
} else if (next.type === "text" || next.type === "reasoning") {
if (next.type === "text") {
diff --git a/plugins/opencode-beacon/src/beacon.ts b/plugins/opencode-beacon/src/beacon.ts
index f8bc8432..071b2932 100644
--- a/plugins/opencode-beacon/src/beacon.ts
+++ b/plugins/opencode-beacon/src/beacon.ts
@@ -176,6 +176,8 @@ export const BeaconEndpointPlugin = async ({ project, directory, worktree, clien
if (next.type === "tool") {
const status = next.state?.status
if (status !== "completed" && status !== "error") return
+ // A failed tool never reaches tool.execute.after, which is what releases its arguments.
+ if (status === "error") activeCalls.delete(next.callID)
if (status === "completed" && completedCalls.has(next.callID)) return
} else if (next.type === "text" || next.type === "reasoning") {
if (next.type === "text") {