You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Move the unreleased working memory extraction controls to the final agentManaged/manageWorkingMemory API. This keeps the working memory extractor branch from introducing the discarded injectTools name and documents the managed working memory defaults.
Co-Authored-By: Mastra Code (openai/gpt-5.5) <noreply@mastra.ai>
add working memory extractor and injectTools config
6
+
add OM-managed working memory
7
7
8
-
Adds a built-in WorkingMemoryExtractor for the observtional
9
-
memory extractor pipeline. When included in observation or
10
-
reflection config, the observer/reflector can update working
11
-
memory through the normal extractor pipeline instead of
12
-
requiring the main agent to call the working memory tool.
8
+
Adds `observationalMemory.observation.manageWorkingMemory` so the Observer can update working memory automatically instead of requiring the main agent to call the working memory tool.
13
9
14
-
Adds injectTools: boolean (default true) to BaseWorkingMemory.
15
-
Set to false to prevent the working memory update tool from
16
-
being injected into the main agent.
10
+
```ts
11
+
newMemory({
12
+
options: {
13
+
workingMemory: { enabled: true },
14
+
observationalMemory: {
15
+
enabled: true,
16
+
observation: { manageWorkingMemory: true },
17
+
},
18
+
},
19
+
})
20
+
```
21
+
22
+
This option adds `WorkingMemoryExtractor`, defaults `workingMemory.agentManaged` to `false`, and defaults `workingMemory.useStateSignals` to `true` when working memory is enabled. Set `workingMemory.agentManaged: true` to keep the main agent's working memory tool and instructions enabled.
Copy file name to clipboardExpand all lines: docs/src/content/en/docs/memory/observational-memory.mdx
+26Lines changed: 26 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -248,6 +248,32 @@ new Extractor({
248
248
})
249
249
```
250
250
251
+
### Working memory updates
252
+
253
+
Use `observationalMemory.observation.manageWorkingMemory` when working memory should be managed automatically by the Observer. The main agent no longer needs to remember to call the working memory tool while it is handling the user request.
254
+
255
+
This also keeps working memory prompt-cache friendly. Working memory normally lives in the system prompt, so updates can invalidate the prompt cache. OM-managed working memory defaults `workingMemory.useStateSignals` to `true`, which moves working memory into state signals instead.
256
+
257
+
```typescript title="src/mastra/agents/agent.ts"
258
+
import { Memory } from'@mastra/memory'
259
+
260
+
const memory =newMemory({
261
+
options: {
262
+
workingMemory: {
263
+
enabled: true,
264
+
},
265
+
observationalMemory: {
266
+
enabled: true,
267
+
observation: {
268
+
manageWorkingMemory: true,
269
+
},
270
+
},
271
+
},
272
+
})
273
+
```
274
+
275
+
This setting adds `WorkingMemoryExtractor`, defaults `workingMemory.agentManaged` to `false`, and defaults `workingMemory.useStateSignals` to `true`. Set `workingMemory.agentManaged: true` if the main agent should still receive working memory tool and instruction injection.
276
+
251
277
Use `onExtracted` to normalize or react to custom extracted values before they are persisted:
Copy file name to clipboardExpand all lines: docs/src/content/en/docs/memory/working-memory.mdx
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,6 +20,8 @@ Think of it as the agent's active thoughts or scratchpad – the key information
20
20
21
21
This is useful for maintaining ongoing state that's always relevant and should always be available to the agent.
22
22
23
+
If you use [Observational Memory](/docs/memory/observational-memory), `observationalMemory.observation.manageWorkingMemory` lets OM update working memory for the agent.
24
+
23
25
Working memory can persist at two different scopes:
24
26
25
27
-**Resource-scoped** (default): Memory persists across all conversation threads for the same user
Copy file name to clipboardExpand all lines: docs/src/content/en/reference/memory/observational-memory.mdx
+26Lines changed: 26 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -448,10 +448,36 @@ const memory = new Memory({
448
448
- Schema-backed extractors add a follow-up structured output request.
449
449
- Schema-less extractors are inline string extractors emitted directly in the Observer or Reflector output.
450
450
- Dynamic extractor functions receive runtime context, including `source`, `threadId`, `resourceId`, `mainAgent`, `memory`, and `requestContext` when available.
451
+
-`WorkingMemoryExtractor` uses the normal extractor pipeline to update working memory through the active `Memory` instance. It uses structured extraction when working memory has a JSON schema and skips OM metadata persistence, so the working memory payload isn't duplicated under OM extracted metadata.
452
+
-`observationalMemory.observation.manageWorkingMemory` adds `WorkingMemoryExtractor`, defaults `workingMemory.agentManaged` to `false`, and defaults `workingMemory.useStateSignals` to `true` when working memory is enabled.
451
453
- Extraction failures are reported in OM marker data and do not discard other successful extracted values.
452
454
453
455
## Examples
454
456
457
+
### Working memory updates
458
+
459
+
Use `observationalMemory.observation.manageWorkingMemory` when OM should update working memory.
460
+
461
+
```typescript title="src/mastra/agents/agent.ts"
462
+
import { Memory } from'@mastra/memory'
463
+
464
+
const memory =newMemory({
465
+
options: {
466
+
workingMemory: {
467
+
enabled: true,
468
+
},
469
+
observationalMemory: {
470
+
enabled: true,
471
+
observation: {
472
+
manageWorkingMemory: true,
473
+
},
474
+
},
475
+
},
476
+
})
477
+
```
478
+
479
+
Set `workingMemory.agentManaged: true` if the main agent should still receive working memory tool and instruction injection.
480
+
455
481
### Resource scope with custom thresholds (experimental)
0 commit comments