From 80f33729b39dd5f3eb7fd9553265afc10c93c334 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=89=E9=97=B2=E9=9D=99=E9=9B=85?= Date: Sun, 22 Mar 2026 22:31:38 +0800 Subject: [PATCH] fix: align agentId resolution across all tools to use definition-time context memory_update/forget/stats/list were re-resolving agentId from execute-time runtimeCtx, causing scope mismatch when the execute-time context provides a different agentId than definition-time. This aligns all tools with memory_store's pattern of using the stable definition-time runtimeContext.agentId. Fixes #231 Co-Authored-By: Claude Opus 4.6 (1M context) --- src/tools.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/tools.ts b/src/tools.ts index 1790f87b..a5aa1463 100644 --- a/src/tools.ts +++ b/src/tools.ts @@ -787,7 +787,7 @@ export function registerMemoryForgetTool( }; try { - const agentId = resolveRuntimeAgentId(runtimeContext.agentId, runtimeCtx); + const agentId = runtimeContext.agentId; // Determine accessible scopes let scopeFilter = resolveScopeFilter(runtimeContext.scopeManager, agentId); if (scope) { @@ -963,7 +963,7 @@ export function registerMemoryUpdateTool( } // Determine accessible scopes - const agentId = resolveRuntimeAgentId(runtimeContext.agentId, runtimeCtx); + const agentId = runtimeContext.agentId; const scopeFilter = resolveScopeFilter(context.scopeManager, agentId); // Resolve memoryId: if it doesn't look like a UUID, try search @@ -1200,7 +1200,7 @@ export function registerMemoryStatsTool( const { scope } = params as { scope?: string }; try { - const agentId = resolveRuntimeAgentId(runtimeContext.agentId, runtimeCtx); + const agentId = runtimeContext.agentId; // Determine accessible scopes let scopeFilter = resolveScopeFilter(context.scopeManager, agentId); if (scope) { @@ -1315,7 +1315,7 @@ export function registerMemoryListTool( try { const safeLimit = clampInt(limit, 1, 50); const safeOffset = clampInt(offset, 0, 1000); - const agentId = resolveRuntimeAgentId(runtimeContext.agentId, runtimeCtx); + const agentId = runtimeContext.agentId; // Determine accessible scopes let scopeFilter = resolveScopeFilter(context.scopeManager, agentId);