From b3eb076539b93c583fa1be50463a4d1eb04b4550 Mon Sep 17 00:00:00 2001 From: "paseo-bot[bot]" Date: Wed, 18 Nov 2026 10:45:27 +0000 Subject: [PATCH] fix(server): keep no replay failure record for a closed agent The replay takes the agent's record when it starts and writes a failure into that record. Closing the agent drops it, so a replay that fails afterwards no longer leaves an entry behind. Co-Authored-By: Claude Opus 5.5 --- packages/server/src/server/plugins/runtime.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/server/src/server/plugins/runtime.ts b/packages/server/src/server/plugins/runtime.ts index cc047a9f2b..4cf19af379 100644 --- a/packages/server/src/server/plugins/runtime.ts +++ b/packages/server/src/server/plugins/runtime.ts @@ -732,11 +732,13 @@ export class PluginRuntime { tools: [], mcpServers: {}, }; - const failed = this.failedToolReplays.get(request.agentId); + // Detaching the agent drops this record, so a replay that fails after its agent closed records nothing. + const failed = this.failedToolReplays.get(request.agentId) ?? new Map(); + this.failedToolReplays.set(request.agentId, failed); const replayed: ReattachedAgentTools[] = []; for (const pluginId of pluginIds) { const loaded = this.plugins.get(pluginId); - if (!loaded || failed?.get(pluginId) === loaded.instanceId) continue; + if (!loaded || failed.get(pluginId) === loaded.instanceId) continue; if (!loaded.child || !loaded.hooks.includes("agent.open.before")) { replayed.push({ pluginId, tools: [] }); continue; @@ -754,9 +756,7 @@ export class PluginRuntime { replayed.push({ pluginId, tools }); } catch (error) { // Left out like a stopped plugin. The next instance of this plugin is replayed again. - const record = this.failedToolReplays.get(request.agentId) ?? new Map(); - record.set(pluginId, loaded.instanceId); - this.failedToolReplays.set(request.agentId, record); + failed.set(pluginId, loaded.instanceId); this.logger.warn( { err: error, pluginId, agentId: request.agentId }, "Plugin tool reattach failed",