diff --git a/apps/sim/app/api/memory/[id]/route.ts b/apps/sim/app/api/memory/[id]/route.ts index 2928fd8b42..9cc7b5ccc0 100644 --- a/apps/sim/app/api/memory/[id]/route.ts +++ b/apps/sim/app/api/memory/[id]/route.ts @@ -86,7 +86,7 @@ export const GET = withRouteHandler(async (request: NextRequest, context: Memory .limit(1) if (memories.length === 0) { - return memoryEnvelopeError('Memory not found', 404) + return NextResponse.json({ success: true, data: null }, { status: 200 }) } const mem = memories[0] diff --git a/apps/sim/tools/memory/get.test.ts b/apps/sim/tools/memory/get.test.ts index 0b7177d19d..862ca367d1 100644 --- a/apps/sim/tools/memory/get.test.ts +++ b/apps/sim/tools/memory/get.test.ts @@ -36,6 +36,20 @@ describe('memoryGetTool', () => { expect(url).toBe('/api/memory/team%2Fuser%20123?workspaceId=workspace-1') }) + it('returns empty memories when key is not found (null data)', async () => { + const result = await transformResponse( + new Response(JSON.stringify({ success: true, data: null })) + ) + + expect(result).toEqual({ + success: true, + output: { + memories: [], + message: 'No memories found', + }, + }) + }) + it('wraps the exact memory response as a single result', async () => { const result = await transformResponse( new Response(