From 55443a6334e9c9db5f352d0c2f49ae4b6bf1c794 Mon Sep 17 00:00:00 2001 From: wyh0626 <44987669+wyh0626@users.noreply.github.com> Date: Mon, 8 Jun 2026 15:31:34 +0800 Subject: [PATCH] fix(scope): propagate agentId through memoryToObservation (#817 follow-up) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The #817 fix enforces AGENT_ID isolation in mem::search by post-filtering loaded rows on `obs.agentId !== filterAgentId`. But memoryToObservation() — the path that wraps /remember-saved Memory rows for the index — never copied agentId, so memories load with agentId=undefined and get dropped by the isolated-mode filter. Effect: in AGENTMEMORY_AGENT_SCOPE=isolated an agent cannot recall its own remembered memories (false negative, not a leak). Copy agentId in memoryToObservation so isolation applies to memories too. --- src/state/memory-utils.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/state/memory-utils.ts b/src/state/memory-utils.ts index aa0bcc5b8..5baac175d 100644 --- a/src/state/memory-utils.ts +++ b/src/state/memory-utils.ts @@ -20,5 +20,11 @@ export function memoryToObservation(memory: Memory): CompressedObservation { concepts: memory.concepts, files: memory.files, importance: memory.strength, + // #817: carry agentId through so agent-scope isolation in + // mem::search applies to memories too. Without this, a memory + // saved via /remember loads with agentId=undefined and gets + // dropped by the isolated-mode filter — hiding an agent's own + // remembered memories from itself. + agentId: memory.agentId, }; }