Skip to content

Commit d0d3735

Browse files
ssdeanxCopilot
andcommitted
- observation memory update
Co-authored-by: Copilot <copilot@github.com>
1 parent 9cfd6ed commit d0d3735

3 files changed

Lines changed: 38 additions & 23 deletions

File tree

package-lock.json

Lines changed: 13 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
"@ai-sdk/openai": "^3.0.53",
5757
"@ai-sdk/openai-compatible": "^2.0.41",
5858
"@ai-sdk/provider-utils": "^4.0.23",
59-
"@ai-sdk/react": "^3.0.164",
59+
"@ai-sdk/react": "^3.0.165",
6060
"@auth/agent": "^0.4.6",
6161
"@auth/agent-cli": "^0.4.5",
6262
"@better-auth/agent-auth": "^0.4.5",
@@ -147,7 +147,7 @@
147147
"@zernio/chat-sdk-adapter": "^0.2.3",
148148
"a2a-ai-provider": "^0.4.0-alpha.2",
149149
"adm-zip": "^0.5.17",
150-
"ai": "^6.0.162",
150+
"ai": "^6.0.163",
151151
"ai-sdk-ollama": "^3.8.3",
152152
"ai-sdk-provider-gemini-cli": "^2.0.1",
153153
"ai-sdk-provider-opencode-sdk": "^3.0.2",
@@ -308,7 +308,7 @@
308308
},
309309
"overrides": {
310310
"jsondiffpatch": "0.7.3",
311-
"ai": "^6.0.162",
311+
"ai": "^6.0.163",
312312
"morgan": "^1.10.1",
313313
"js-yaml": "^4.1.1",
314314
"multer": "^2.1.1",
@@ -336,4 +336,4 @@
336336
"@typescript-eslint/parser": "^8.58.2",
337337
"@typescript-eslint/eslint-plugin": "^8.58.2"
338338
}
339-
}
339+
}

src/mastra/config/libsql.ts

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,19 +56,25 @@ export const LibsqlMemory = new Memory({
5656
logOutputs: true,
5757
},
5858
},
59-
maxParallelCalls: 50, // Limit parallel embedding calls to avoid rate limits
59+
maxParallelCalls: 20, // Limit parallel embedding calls to avoid rate limits
6060
},
6161
options: {
6262
// Message management
6363
readOnly: false,
6464
observationalMemory: {
6565
enabled: true,
66-
scope: 'thread', // 'resource' | 'thread'
66+
scope: 'resource', // 'resource' | 'thread'
6767
model: 'google/gemini-2.5-flash',
68-
shareTokenBudget: false, // Don't share token budget between observation and reflection to preserve context
68+
retrieval: { vector: true, scope: 'resource' },
69+
shareTokenBudget: true, // Don't share token budget between observation and reflection to preserve context
6970
observation: {
7071
instruction: 'You are an assistant that observes and remembers important information from the conversation. Pay attention to details, context, and any information that might be useful for future reference.',
71-
messageTokens: 60_000,
72+
messageTokens: 50_000,
73+
bufferTokens: 5_000,
74+
// Activate to retain 30% of threshold
75+
bufferActivation: 0.85,
76+
// Force synchronous observation at 1.5x threshold
77+
blockAfter: 1.5,
7278
modelSettings: {
7379
temperature: 0.3,
7480
maxOutputTokens: 64_000,
@@ -77,14 +83,17 @@ export const LibsqlMemory = new Memory({
7783
},
7884
},
7985
reflection: {
86+
bufferActivation: 0.5,
87+
// Force synchronous reflection at 1.2x threshold
88+
blockAfter: 1.2,
8089
instruction: 'Based on the observations, generate concise and informative reflections that capture important details, context, and insights from the conversation. These reflections should be useful for future reference and help provide context for the assistant.',
8190
modelSettings: {
8291
temperature: 0.3,
8392
maxOutputTokens: 64_000,
8493
topK: 40,
8594
topP: 0.95,
8695
},
87-
observationTokens: 50_000,
96+
observationTokens: 40_000,
8897
},
8998
},
9099
lastMessages: parseInt(process.env.MEMORY_LAST_MESSAGES ?? '500'),
@@ -115,6 +124,7 @@ export const LibsqlMemory = new Memory({
115124
{{#if user.organization}}Organization: {{user.organization}}{{/if}}
116125
{{#if user.preferences}}Preferences: {{user.preferences}}{{/if}}
117126
{{#if user.history}}History: {{user.history}}{{/if}}
127+
{{#if user.other}}Other: {{user.other}}{{/if}}
118128
119129
# Conversation Context
120130
{{#if conversation.topic}}Topic: {{conversation.topic}}{{/if}}
@@ -123,7 +133,12 @@ export const LibsqlMemory = new Memory({
123133
# Additional Context
124134
{{#each additionalContext}}
125135
- {{this}}
126-
- {{/each}}
136+
{{/each}}
137+
138+
## Important Information
139+
{{#each importantInfo}}
140+
- {{this}}
141+
{{/each}}
127142
`,
128143
},
129144
},

0 commit comments

Comments
 (0)