MCPcopy Index your code
hub / github.com/simstudioai/sim / fetchMemory

Method fetchMemory

apps/sim/executor/handlers/agent/memory.ts:201–224  ·  view source on GitHub ↗
(workspaceId: string, key: string)

Source from the content-addressed store, hash-verified

199 }
200
201 private async fetchMemory(workspaceId: string, key: string): Promise<Message[]> {
202 const result = await db
203 .select({ data: memory.data })
204 .from(memory)
205 .where(and(eq(memory.workspaceId, workspaceId), eq(memory.key, key)))
206 .limit(1)
207
208 if (result.length === 0) return []
209
210 const data = result[0].data
211 if (!Array.isArray(data)) return []
212
213 return data
214 .filter(
215 (msg): msg is Message =>
216 msg &&
217 typeof msg === 'object' &&
218 'role' in msg &&
219 'content' in msg &&
220 ['system', 'user', 'assistant'].includes(msg.role) &&
221 typeof msg.content === 'string'
222 )
223 .map((msg) => this.sanitizeMessageForStorage(msg))
224 }
225
226 private async seedMemoryRecord(
227 workspaceId: string,

Callers 1

fetchMemoryMessagesMethod · 0.95

Calls 2

eqFunction · 0.50

Tested by

no test coverage detected