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

Method fetchMemoryMessages

apps/sim/executor/handlers/agent/memory.ts:16–49  ·  view source on GitHub ↗
(ctx: ExecutionContext, inputs: AgentInputs)

Source from the content-addressed store, hash-verified

14
15export class Memory {
16 async fetchMemoryMessages(ctx: ExecutionContext, inputs: AgentInputs): Promise<Message[]> {
17 if (!inputs.memoryType || inputs.memoryType === 'none') {
18 return []
19 }
20
21 const workspaceId = this.requireWorkspaceId(ctx)
22 this.validateConversationId(inputs.conversationId)
23
24 const messages = await this.fetchMemory(workspaceId, inputs.conversationId!)
25
26 switch (inputs.memoryType) {
27 case 'conversation':
28 return this.applyContextWindowLimit(messages, inputs.model)
29
30 case 'sliding_window': {
31 const limit = this.parsePositiveInt(
32 inputs.slidingWindowSize,
33 MEMORY.DEFAULT_SLIDING_WINDOW_SIZE
34 )
35 return this.applyWindow(messages, limit)
36 }
37
38 case 'sliding_window_tokens': {
39 const maxTokens = this.parsePositiveInt(
40 inputs.slidingWindowTokens,
41 MEMORY.DEFAULT_SLIDING_WINDOW_TOKENS
42 )
43 return this.applyTokenWindow(messages, maxTokens, inputs.model)
44 }
45
46 default:
47 return messages
48 }
49 }
50
51 async appendToMemory(
52 ctx: ExecutionContext,

Callers 2

loadPiMemoryFunction · 0.80
buildMessagesMethod · 0.80

Calls 7

requireWorkspaceIdMethod · 0.95
fetchMemoryMethod · 0.95
parsePositiveIntMethod · 0.95
applyWindowMethod · 0.95
applyTokenWindowMethod · 0.95

Tested by

no test coverage detected