@@ -62,25 +62,7 @@ export class Memory {
6262
6363 const key = inputs . conversationId !
6464
65- if ( inputs . memoryType === 'sliding_window' ) {
66- const limit = this . parsePositiveInt (
67- inputs . slidingWindowSize ,
68- MEMORY . DEFAULT_SLIDING_WINDOW_SIZE
69- )
70- const existing = await this . fetchMemory ( workspaceId , key )
71- const updated = this . applyWindow ( [ ...existing , message ] , limit )
72- await this . persistMemory ( workspaceId , key , updated )
73- } else if ( inputs . memoryType === 'sliding_window_tokens' ) {
74- const maxTokens = this . parsePositiveInt (
75- inputs . slidingWindowTokens ,
76- MEMORY . DEFAULT_SLIDING_WINDOW_TOKENS
77- )
78- const existing = await this . fetchMemory ( workspaceId , key )
79- const updated = this . applyTokenWindow ( [ ...existing , message ] , maxTokens , inputs . model )
80- await this . persistMemory ( workspaceId , key , updated )
81- } else {
82- await this . appendMessage ( workspaceId , key , message )
83- }
65+ await this . appendMessage ( workspaceId , key , message )
8466
8567 logger . debug ( 'Appended message to memory' , {
8668 workspaceId,
@@ -120,7 +102,7 @@ export class Memory {
120102 messagesToStore = this . applyTokenWindow ( conversationMessages , maxTokens , inputs . model )
121103 }
122104
123- await this . persistMemory ( workspaceId , key , messagesToStore )
105+ await this . seedMemoryRecord ( workspaceId , key , messagesToStore )
124106
125107 logger . debug ( 'Seeded memory' , {
126108 workspaceId,
@@ -228,7 +210,7 @@ export class Memory {
228210 )
229211 }
230212
231- private async persistMemory (
213+ private async seedMemoryRecord (
232214 workspaceId : string ,
233215 key : string ,
234216 messages : Message [ ]
@@ -245,13 +227,7 @@ export class Memory {
245227 createdAt : now ,
246228 updatedAt : now ,
247229 } )
248- . onConflictDoUpdate ( {
249- target : [ memory . workspaceId , memory . key ] ,
250- set : {
251- data : messages ,
252- updatedAt : now ,
253- } ,
254- } )
230+ . onConflictDoNothing ( )
255231 }
256232
257233 private async appendMessage ( workspaceId : string , key : string , message : Message ) : Promise < void > {
0 commit comments