@mastra/memory 1.6.1 → 1.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/CHANGELOG.md +52 -0
  2. package/dist/{chunk-GBBQIJQF.js → chunk-3CM4XQJO.js} +1940 -463
  3. package/dist/chunk-3CM4XQJO.js.map +1 -0
  4. package/dist/{chunk-D6II7EP4.cjs → chunk-5W5463NI.cjs} +1939 -461
  5. package/dist/chunk-5W5463NI.cjs.map +1 -0
  6. package/dist/docs/SKILL.md +24 -24
  7. package/dist/docs/assets/SOURCE_MAP.json +25 -25
  8. package/dist/docs/references/docs-agents-agent-approval.md +3 -3
  9. package/dist/docs/references/docs-agents-agent-memory.md +3 -3
  10. package/dist/docs/references/docs-agents-network-approval.md +5 -2
  11. package/dist/docs/references/docs-agents-networks.md +2 -2
  12. package/dist/docs/references/docs-agents-supervisor-agents.md +3 -3
  13. package/dist/docs/references/docs-memory-memory-processors.md +9 -9
  14. package/dist/docs/references/docs-memory-message-history.md +4 -4
  15. package/dist/docs/references/docs-memory-observational-memory.md +11 -7
  16. package/dist/docs/references/docs-memory-semantic-recall.md +9 -9
  17. package/dist/docs/references/docs-memory-storage.md +1 -1
  18. package/dist/docs/references/docs-memory-working-memory.md +20 -20
  19. package/dist/docs/references/reference-core-getMemory.md +1 -1
  20. package/dist/docs/references/reference-core-listMemory.md +1 -1
  21. package/dist/docs/references/reference-memory-clone-utilities.md +7 -7
  22. package/dist/docs/references/reference-memory-cloneThread.md +5 -5
  23. package/dist/docs/references/reference-memory-createThread.md +1 -1
  24. package/dist/docs/references/reference-memory-getThreadById.md +1 -1
  25. package/dist/docs/references/reference-memory-listThreads.md +3 -3
  26. package/dist/docs/references/reference-memory-memory-class.md +1 -1
  27. package/dist/docs/references/reference-memory-observational-memory.md +8 -6
  28. package/dist/docs/references/reference-processors-token-limiter-processor.md +2 -2
  29. package/dist/docs/references/reference-storage-dynamodb.md +7 -7
  30. package/dist/docs/references/reference-storage-libsql.md +1 -1
  31. package/dist/docs/references/reference-storage-mongodb.md +6 -6
  32. package/dist/docs/references/reference-storage-postgresql.md +7 -7
  33. package/dist/docs/references/reference-storage-upstash.md +4 -4
  34. package/dist/docs/references/reference-vectors-libsql.md +15 -15
  35. package/dist/docs/references/reference-vectors-mongodb.md +18 -18
  36. package/dist/docs/references/reference-vectors-pg.md +23 -21
  37. package/dist/docs/references/reference-vectors-upstash.md +15 -15
  38. package/dist/index.cjs +48 -25
  39. package/dist/index.cjs.map +1 -1
  40. package/dist/index.d.ts +14 -14
  41. package/dist/index.d.ts.map +1 -1
  42. package/dist/index.js +44 -21
  43. package/dist/index.js.map +1 -1
  44. package/dist/{observational-memory-AHVELJX4.cjs → observational-memory-C5LO7RBR.cjs} +17 -17
  45. package/dist/{observational-memory-AHVELJX4.cjs.map → observational-memory-C5LO7RBR.cjs.map} +1 -1
  46. package/dist/{observational-memory-QFQUF5EY.js → observational-memory-OYK4MEUD.js} +3 -3
  47. package/dist/{observational-memory-QFQUF5EY.js.map → observational-memory-OYK4MEUD.js.map} +1 -1
  48. package/dist/processors/index.cjs +15 -15
  49. package/dist/processors/index.js +1 -1
  50. package/dist/processors/observational-memory/observational-memory.d.ts +33 -2
  51. package/dist/processors/observational-memory/observational-memory.d.ts.map +1 -1
  52. package/dist/processors/observational-memory/observer-agent.d.ts +7 -4
  53. package/dist/processors/observational-memory/observer-agent.d.ts.map +1 -1
  54. package/dist/processors/observational-memory/repro-capture.d.ts +23 -0
  55. package/dist/processors/observational-memory/repro-capture.d.ts.map +1 -0
  56. package/dist/processors/observational-memory/token-counter.d.ts +28 -3
  57. package/dist/processors/observational-memory/token-counter.d.ts.map +1 -1
  58. package/dist/tools/working-memory.d.ts +6 -10
  59. package/dist/tools/working-memory.d.ts.map +1 -1
  60. package/package.json +16 -11
  61. package/dist/chunk-D6II7EP4.cjs.map +0 -1
  62. package/dist/chunk-GBBQIJQF.js.map +0 -1
@@ -3,7 +3,7 @@ name: mastra-memory
3
3
  description: Documentation for @mastra/memory. Use when working with @mastra/memory APIs, configuration, or implementation.
4
4
  metadata:
5
5
  package: "@mastra/memory"
6
- version: "1.6.1"
6
+ version: "1.6.2"
7
7
  ---
8
8
 
9
9
  ## When to use
@@ -16,40 +16,40 @@ Read the individual reference documents for detailed explanations and code examp
16
16
 
17
17
  ### Docs
18
18
 
19
- - [Agent Approval](references/docs-agents-agent-approval.md) - Learn how to require approvals, suspend tool execution, and automatically resume suspended tools while keeping humans in control of agent workflows.
20
- - [Agent Memory](references/docs-agents-agent-memory.md) - Learn how to add memory to agents to store message history and maintain context across interactions.
21
- - [Network Approval](references/docs-agents-network-approval.md) - Learn how to require approvals, suspend execution, and resume suspended networks while keeping humans in control of agent network workflows.
22
- - [Agent Networks](references/docs-agents-networks.md) - Learn how to coordinate multiple agents, workflows, and tools using agent networks for complex, non-deterministic task execution.
23
- - [Supervisor Agents](references/docs-agents-supervisor-agents.md) - Learn how to coordinate multiple agents using the supervisor pattern with delegation hooks, iteration monitoring, message filtering, and task completion scoring.
24
- - [Memory Processors](references/docs-memory-memory-processors.md) - Learn how to use memory processors in Mastra to filter, trim, and transform messages before they're sent to the language model to manage context window limits.
25
- - [Message History](references/docs-memory-message-history.md) - Learn how to configure message history in Mastra to store recent messages from the current conversation.
26
- - [Observational Memory](references/docs-memory-observational-memory.md) - Learn how Observational Memory keeps your agent's context window small while preserving long-term memory across conversations.
19
+ - [Agent approval](references/docs-agents-agent-approval.md) - Learn how to require approvals, suspend tool execution, and automatically resume suspended tools while keeping humans in control of agent workflows.
20
+ - [Agent memory](references/docs-agents-agent-memory.md) - Learn how to add memory to agents to store message history and maintain context across interactions.
21
+ - [Network approval](references/docs-agents-network-approval.md) - Learn how to require approvals, suspend execution, and resume suspended networks while keeping humans in control of agent network workflows.
22
+ - [Agent networks](references/docs-agents-networks.md) - Learn how to coordinate multiple agents, workflows, and tools using agent networks for complex, non-deterministic task execution.
23
+ - [Supervisor agents](references/docs-agents-supervisor-agents.md) - Learn how to coordinate multiple agents using the supervisor pattern with delegation hooks, iteration monitoring, message filtering, and task completion scoring.
24
+ - [Memory processors](references/docs-memory-memory-processors.md) - Learn how to use memory processors in Mastra to filter, trim, and transform messages before they're sent to the language model to manage context window limits.
25
+ - [Message history](references/docs-memory-message-history.md) - Learn how to configure message history in Mastra to store recent messages from the current conversation.
26
+ - [Observational memory](references/docs-memory-observational-memory.md) - Learn how Observational Memory keeps your agent's context window small while preserving long-term memory across conversations.
27
27
  - [Memory overview](references/docs-memory-overview.md) - Learn how Mastra's memory system works with working memory, message history, semantic recall, and observational memory.
28
- - [Semantic Recall](references/docs-memory-semantic-recall.md) - Learn how to use semantic recall in Mastra to retrieve relevant messages from past conversations using vector search and embeddings.
28
+ - [Semantic recall](references/docs-memory-semantic-recall.md) - Learn how to use semantic recall in Mastra to retrieve relevant messages from past conversations using vector search and embeddings.
29
29
  - [Storage](references/docs-memory-storage.md) - Configure storage for Mastra's memory system to persist conversations, workflows, and traces.
30
- - [Working Memory](references/docs-memory-working-memory.md) - Learn how to configure working memory in Mastra to store persistent user data, preferences.
30
+ - [Working memory](references/docs-memory-working-memory.md) - Learn how to configure working memory in Mastra to store persistent user data, preferences.
31
31
 
32
32
  ### Reference
33
33
 
34
34
  - [Reference: Mastra.getMemory()](references/reference-core-getMemory.md) - Documentation for the `Mastra.getMemory()` method in Mastra, which retrieves a registered memory instance by its registry key.
35
35
  - [Reference: Mastra.listMemory()](references/reference-core-listMemory.md) - Documentation for the `Mastra.listMemory()` method in Mastra, which returns all registered memory instances.
36
- - [Reference: Cloned Thread Utilities](references/reference-memory-clone-utilities.md) - Documentation for utility methods to work with cloned threads in Mastra Memory.
36
+ - [Reference: Cloned thread utilities](references/reference-memory-clone-utilities.md) - Documentation for utility methods to work with cloned threads in Mastra Memory.
37
37
  - [Reference: Memory.cloneThread()](references/reference-memory-cloneThread.md) - Documentation for the `Memory.cloneThread()` method in Mastra, which creates a copy of a conversation thread with all its messages.
38
38
  - [Reference: Memory.createThread()](references/reference-memory-createThread.md) - Documentation for the `Memory.createThread()` method in Mastra, which creates a new conversation thread in the memory system.
39
39
  - [Reference: Memory.getThreadById()](references/reference-memory-getThreadById.md) - Documentation for the `Memory.getThreadById()` method in Mastra, which retrieves a specific thread by its ID.
40
40
  - [Reference: Memory.listThreads()](references/reference-memory-listThreads.md) - Documentation for the `Memory.listThreads()` method in Mastra, which retrieves threads with optional filtering by resourceId and/or metadata.
41
- - [Reference: Memory Class](references/reference-memory-memory-class.md) - Documentation for the `Memory` class in Mastra, which provides a robust system for managing conversation history and thread-based message storage.
42
- - [Reference: Observational Memory](references/reference-memory-observational-memory.md) - API reference for Observational Memory in Mastra — a three-tier memory system that uses Observer and Reflector agents to maintain long-term memory across conversations.
43
- - [Reference: Token Limiter Processor](references/reference-processors-token-limiter-processor.md) - Documentation for the TokenLimiterProcessor in Mastra, which limits the number of tokens in messages.
44
- - [Reference: DynamoDB Storage](references/reference-storage-dynamodb.md) - Documentation for the DynamoDB storage implementation in Mastra, using a single-table design with ElectroDB.
45
- - [Reference: libSQL Storage](references/reference-storage-libsql.md) - Documentation for the libSQL storage implementation in Mastra.
46
- - [Reference: MongoDB Storage](references/reference-storage-mongodb.md) - Documentation for the MongoDB storage implementation in Mastra.
47
- - [Reference: PostgreSQL Storage](references/reference-storage-postgresql.md) - Documentation for the PostgreSQL storage implementation in Mastra.
48
- - [Reference: Upstash Storage](references/reference-storage-upstash.md) - Documentation for the Upstash storage implementation in Mastra.
49
- - [Reference: libSQL Vector Store](references/reference-vectors-libsql.md) - Documentation for the LibSQLVector class in Mastra, which provides vector search using libSQL with vector extensions.
50
- - [Reference: MongoDB Vector Store](references/reference-vectors-mongodb.md) - Documentation for the MongoDBVector class in Mastra, which provides vector search using MongoDB Atlas and Atlas Vector Search.
51
- - [Reference: PG Vector Store](references/reference-vectors-pg.md) - Documentation for the PgVector class in Mastra, which provides vector search using PostgreSQL with pgvector extension.
52
- - [Reference: Upstash Vector Store](references/reference-vectors-upstash.md) - Documentation for the UpstashVector class in Mastra, which provides vector search using Upstash Vector.
41
+ - [Reference: Memory class](references/reference-memory-memory-class.md) - Documentation for the `Memory` class in Mastra, which provides a robust system for managing conversation history and thread-based message storage.
42
+ - [Reference: Observational memory](references/reference-memory-observational-memory.md) - API reference for Observational Memory in Mastra — a three-tier memory system that uses Observer and Reflector agents to maintain long-term memory across conversations.
43
+ - [Reference: TokenLimiterProcessor](references/reference-processors-token-limiter-processor.md) - Documentation for the TokenLimiterProcessor in Mastra, which limits the number of tokens in messages.
44
+ - [Reference: DynamoDB storage](references/reference-storage-dynamodb.md) - Documentation for the DynamoDB storage implementation in Mastra, using a single-table design with ElectroDB.
45
+ - [Reference: libSQL storage](references/reference-storage-libsql.md) - Documentation for the libSQL storage implementation in Mastra.
46
+ - [Reference: MongoDB storage](references/reference-storage-mongodb.md) - Documentation for the MongoDB storage implementation in Mastra.
47
+ - [Reference: PostgreSQL storage](references/reference-storage-postgresql.md) - Documentation for the PostgreSQL storage implementation in Mastra.
48
+ - [Reference: Upstash storage](references/reference-storage-upstash.md) - Documentation for the Upstash storage implementation in Mastra.
49
+ - [Reference: libSQL vector store](references/reference-vectors-libsql.md) - Documentation for the LibSQLVector class in Mastra, which provides vector search using libSQL with vector extensions.
50
+ - [Reference: MongoDB vector store](references/reference-vectors-mongodb.md) - Documentation for the MongoDBVector class in Mastra, which provides vector search using MongoDB Atlas and Atlas Vector Search.
51
+ - [Reference: PG vector store](references/reference-vectors-pg.md) - Documentation for the PgVector class in Mastra, which provides vector search using PostgreSQL with pgvector extension.
52
+ - [Reference: Upstash vector store](references/reference-vectors-upstash.md) - Documentation for the UpstashVector class in Mastra, which provides vector search using Upstash Vector.
53
53
 
54
54
 
55
55
  Read [assets/SOURCE_MAP.json](assets/SOURCE_MAP.json) for source code references.
@@ -1,71 +1,71 @@
1
1
  {
2
- "version": "1.6.1",
2
+ "version": "1.6.2",
3
3
  "package": "@mastra/memory",
4
4
  "exports": {
5
5
  "OBSERVATIONAL_MEMORY_DEFAULTS": {
6
6
  "types": "dist/processors/index.d.ts",
7
- "implementation": "dist/chunk-GBBQIJQF.js"
7
+ "implementation": "dist/chunk-3CM4XQJO.js"
8
8
  },
9
9
  "OBSERVATION_CONTEXT_INSTRUCTIONS": {
10
10
  "types": "dist/processors/index.d.ts",
11
- "implementation": "dist/chunk-GBBQIJQF.js"
11
+ "implementation": "dist/chunk-3CM4XQJO.js"
12
12
  },
13
13
  "OBSERVATION_CONTEXT_PROMPT": {
14
14
  "types": "dist/processors/index.d.ts",
15
- "implementation": "dist/chunk-GBBQIJQF.js"
15
+ "implementation": "dist/chunk-3CM4XQJO.js"
16
16
  },
17
17
  "OBSERVATION_CONTINUATION_HINT": {
18
18
  "types": "dist/processors/index.d.ts",
19
- "implementation": "dist/chunk-GBBQIJQF.js"
19
+ "implementation": "dist/chunk-3CM4XQJO.js"
20
20
  },
21
21
  "OBSERVER_SYSTEM_PROMPT": {
22
22
  "types": "dist/processors/index.d.ts",
23
- "implementation": "dist/chunk-GBBQIJQF.js"
23
+ "implementation": "dist/chunk-3CM4XQJO.js"
24
24
  },
25
25
  "ObservationalMemory": {
26
26
  "types": "dist/processors/index.d.ts",
27
- "implementation": "dist/chunk-GBBQIJQF.js",
28
- "line": 1642
27
+ "implementation": "dist/chunk-3CM4XQJO.js",
28
+ "line": 2907
29
29
  },
30
30
  "TokenCounter": {
31
31
  "types": "dist/processors/index.d.ts",
32
- "implementation": "dist/chunk-GBBQIJQF.js",
33
- "line": 1401
32
+ "implementation": "dist/chunk-3CM4XQJO.js",
33
+ "line": 2385
34
34
  },
35
35
  "buildObserverPrompt": {
36
36
  "types": "dist/processors/index.d.ts",
37
- "implementation": "dist/chunk-GBBQIJQF.js",
38
- "line": 822
37
+ "implementation": "dist/chunk-3CM4XQJO.js",
38
+ "line": 993
39
39
  },
40
40
  "buildObserverSystemPrompt": {
41
41
  "types": "dist/processors/index.d.ts",
42
- "implementation": "dist/chunk-GBBQIJQF.js",
43
- "line": 570
42
+ "implementation": "dist/chunk-3CM4XQJO.js",
43
+ "line": 573
44
44
  },
45
45
  "extractCurrentTask": {
46
46
  "types": "dist/processors/index.d.ts",
47
- "implementation": "dist/chunk-GBBQIJQF.js",
48
- "line": 951
47
+ "implementation": "dist/chunk-3CM4XQJO.js",
48
+ "line": 1101
49
49
  },
50
50
  "formatMessagesForObserver": {
51
51
  "types": "dist/processors/index.d.ts",
52
- "implementation": "dist/chunk-GBBQIJQF.js",
53
- "line": 665
52
+ "implementation": "dist/chunk-3CM4XQJO.js",
53
+ "line": 820
54
54
  },
55
55
  "hasCurrentTaskSection": {
56
56
  "types": "dist/processors/index.d.ts",
57
- "implementation": "dist/chunk-GBBQIJQF.js",
58
- "line": 939
57
+ "implementation": "dist/chunk-3CM4XQJO.js",
58
+ "line": 1089
59
59
  },
60
60
  "optimizeObservationsForContext": {
61
61
  "types": "dist/processors/index.d.ts",
62
- "implementation": "dist/chunk-GBBQIJQF.js",
63
- "line": 962
62
+ "implementation": "dist/chunk-3CM4XQJO.js",
63
+ "line": 1112
64
64
  },
65
65
  "parseObserverOutput": {
66
66
  "types": "dist/processors/index.d.ts",
67
- "implementation": "dist/chunk-GBBQIJQF.js",
68
- "line": 853
67
+ "implementation": "dist/chunk-3CM4XQJO.js",
68
+ "line": 1003
69
69
  },
70
70
  "extractWorkingMemoryContent": {
71
71
  "types": "dist/index.d.ts",
@@ -96,7 +96,7 @@
96
96
  "processors": {
97
97
  "index": "dist/processors/index.js",
98
98
  "chunks": [
99
- "chunk-GBBQIJQF.js"
99
+ "chunk-3CM4XQJO.js"
100
100
  ]
101
101
  }
102
102
  }
@@ -92,7 +92,7 @@ const handleDecline = async () => {
92
92
  }
93
93
  ```
94
94
 
95
- ## Tool approval with generate()
95
+ ## Tool approval with `generate()`
96
96
 
97
97
  Tool approval also works with the `generate()` method for non-streaming use cases. When a tool requires approval during a `generate()` call, the method returns immediately instead of executing the tool.
98
98
 
@@ -504,7 +504,7 @@ for await (const chunk of stream.fullStream) {
504
504
  }
505
505
  ```
506
506
 
507
- ### Using suspend() in supervisor pattern
507
+ ### Using `suspend()` in supervisor pattern
508
508
 
509
509
  Tools can also use [`suspend()`](#approval-using-suspend) to pause execution and return context to the user. This approach works through the supervisor delegation chain the same way `requireApproval` does — the suspension surfaces at the supervisor level:
510
510
 
@@ -553,7 +553,7 @@ for await (const chunk of stream.fullStream) {
553
553
  }
554
554
  ```
555
555
 
556
- ### Tool approval with generate()
556
+ ### Tool approval with `generate()`
557
557
 
558
558
  Tool approval propagation also works with `generate()` in supervisor pattern:
559
559
 
@@ -96,7 +96,7 @@ export const memoryAgent = new Agent({
96
96
  })
97
97
  ```
98
98
 
99
- > **Mastra Cloud Store limitation:** Agent-level storage is not supported when using [Mastra Cloud Store](https://mastra.ai/docs/mastra-cloud/deployment). If you use Mastra Cloud Store, configure storage on the Mastra instance instead. This limitation does not apply if you bring your own database.
99
+ > **Mastra Cloud Store limitation:** Agent-level storage isn't supported when using [Mastra Cloud Store](https://mastra.ai/docs/mastra-cloud/deployment). If you use Mastra Cloud Store, configure storage on the Mastra instance instead. This limitation doesn't apply if you bring your own database.
100
100
 
101
101
  ## Message history
102
102
 
@@ -127,11 +127,11 @@ const response = await memoryAgent.generate("What's my favorite color?", {
127
127
  })
128
128
  ```
129
129
 
130
- > **Warning:** Each thread has an owner (`resourceId`) that cannot be changed after creation. Avoid reusing the same thread ID for threads with different owners, as this will cause errors when querying.
130
+ > **Warning:** Each thread has an owner (`resourceId`) that can't be changed after creation. Avoid reusing the same thread ID for threads with different owners, as this will cause errors when querying.
131
131
 
132
132
  To learn more about memory see the [Memory](https://mastra.ai/docs/memory/overview) documentation.
133
133
 
134
- ## Observational Memory
134
+ ## Observational memory
135
135
 
136
136
  For long-running conversations, raw message history grows until it fills the context window, degrading agent performance. [Observational Memory](https://mastra.ai/docs/memory/observational-memory) solves this by running background agents that compress old messages into dense observations, keeping the context window small while preserving long-term memory.
137
137
 
@@ -1,4 +1,6 @@
1
- # Network Approval
1
+ # Network approval
2
+
3
+ > **Deprecated:** Agent networks are deprecated and will be removed in a future release. Use the [supervisor pattern](https://mastra.ai/docs/agents/supervisor-agents) instead. See the [migration guide](https://mastra.ai/guides/migrations/network-to-supervisor) to upgrade.
2
4
 
3
5
  Agent networks can require the same [human-in-the-loop](https://mastra.ai/docs/workflows/human-in-the-loop) oversight used in individual agents and workflows. When a tool, subagent, or workflow within a network requires approval or suspends execution, the network pauses and emits events that allow your application to collect user input before resuming.
4
6
 
@@ -269,7 +271,8 @@ Both approaches work with the same tool definitions. Automatic resumption trigge
269
271
 
270
272
  ## Related
271
273
 
272
- - [Agent Networks](https://mastra.ai/docs/agents/networks)
274
+ - [Supervisor Agents](https://mastra.ai/docs/agents/supervisor-agents)
275
+ - [Migration: .network() to Supervisor Pattern](https://mastra.ai/guides/migrations/network-to-supervisor)
273
276
  - [Agent Approval](https://mastra.ai/docs/agents/agent-approval)
274
277
  - [Human-in-the-Loop](https://mastra.ai/docs/workflows/human-in-the-loop)
275
278
  - [Agent Memory](https://mastra.ai/docs/agents/agent-memory)
@@ -1,6 +1,6 @@
1
- # Agent Networks
1
+ # Agent networks
2
2
 
3
- > **Supervisor Pattern Recommended:** The [supervisor pattern](https://mastra.ai/docs/agents/supervisor-agents) using `agent.stream()` or `agent.generate()` is now the recommended approach for coordinating multiple agents. It provides the same multi-agent coordination capabilities as `.network()` with significant improvements:
3
+ > **Agent Network Deprecated — Supervisor Pattern Recommended:** Agent networks are deprecated and will be removed in a future release. The [supervisor pattern](https://mastra.ai/docs/agents/supervisor-agents) using `agent.stream()` or `agent.generate()` is now the recommended approach for coordinating multiple agents. It provides the same multi-agent coordination capabilities as `.network()` with significant improvements:
4
4
  >
5
5
  > - **Better control**: Iteration hooks, delegation hooks, and task completion scoring give you fine-grained control over execution
6
6
  > - **Simpler API**: Uses familiar `stream()` and `generate()` methods instead of a separate `.network()` API
@@ -1,4 +1,4 @@
1
- # Supervisor Agents
1
+ # Supervisor agents
2
2
 
3
3
  A supervisor agent coordinates multiple subagents using `agent.stream()` or `agent.generate()`. You configure subagents on the supervisor's `agents` property, and the supervisor uses its instructions and each subagent's `description` to decide when and how to delegate tasks.
4
4
 
@@ -57,7 +57,7 @@ for await (const chunk of stream.textStream) {
57
57
 
58
58
  Delegation hooks let you intercept, modify, or reject delegations as they happen. Configure them under the `delegation` option, either in the agent's `defaultOptions` or per-call.
59
59
 
60
- ### onDelegationStart
60
+ ### `onDelegationStart`
61
61
 
62
62
  Called before the supervisor delegates to a subagent. Return an object to control the delegation:
63
63
 
@@ -104,7 +104,7 @@ The `context` object includes:
104
104
  | `prompt` | The prompt the supervisor is sending |
105
105
  | `iteration` | Current iteration number |
106
106
 
107
- ### onDelegationComplete
107
+ ### `onDelegationComplete`
108
108
 
109
109
  Called after a delegation finishes. Use it to inspect results, provide feedback, or stop execution:
110
110
 
@@ -1,4 +1,4 @@
1
- # Memory Processors
1
+ # Memory processors
2
2
 
3
3
  Memory processors transform and filter messages as they pass through an agent with memory enabled. They manage context window limits, remove unnecessary content, and optimize the information sent to the language model.
4
4
 
@@ -6,11 +6,11 @@ When memory is enabled on an agent, Mastra adds memory processors to the agent's
6
6
 
7
7
  Memory processors are [processors](https://mastra.ai/docs/agents/processors) that operate specifically on memory-related messages and state.
8
8
 
9
- ## Built-in Memory Processors
9
+ ## Built-in memory processors
10
10
 
11
11
  Mastra automatically adds these processors when memory is enabled:
12
12
 
13
- ### MessageHistory
13
+ ### `MessageHistory`
14
14
 
15
15
  Retrieves message history and persists new messages.
16
16
 
@@ -56,7 +56,7 @@ const agent = new Agent({
56
56
  })
57
57
  ```
58
58
 
59
- ### SemanticRecall
59
+ ### `SemanticRecall`
60
60
 
61
61
  Retrieves semantically relevant messages based on the current input and creates embeddings for new messages.
62
62
 
@@ -114,7 +114,7 @@ const agent = new Agent({
114
114
  })
115
115
  ```
116
116
 
117
- ### WorkingMemory
117
+ ### `WorkingMemory`
118
118
 
119
119
  Manages working memory state across conversations.
120
120
 
@@ -159,9 +159,9 @@ const agent = new Agent({
159
159
  })
160
160
  ```
161
161
 
162
- ## Manual Control and Deduplication
162
+ ## Manual control and deduplication
163
163
 
164
- If you manually add a memory processor to `inputProcessors` or `outputProcessors`, Mastra will **not** automatically add it. This gives you full control over processor ordering:
164
+ If you manually add a memory processor to `inputProcessors` or `outputProcessors`, Mastra **won't** automatically add it. This gives you full control over processor ordering:
165
165
 
166
166
  ```typescript
167
167
  import { Agent } from '@mastra/core/agent'
@@ -192,7 +192,7 @@ const agent = new Agent({
192
192
  })
193
193
  ```
194
194
 
195
- ## Processor Execution Order
195
+ ## Processor execution order
196
196
 
197
197
  Understanding the execution order is important when combining guardrails with memory:
198
198
 
@@ -218,7 +218,7 @@ This means memory loads message history before your processors can validate or f
218
218
 
219
219
  This ordering is designed to be **safe by default**: if your output guardrail calls `abort()`, the memory processors never run and **no messages are saved**.
220
220
 
221
- ## Guardrails and Memory
221
+ ## Guardrails and memory
222
222
 
223
223
  The default execution order provides safe guardrail behavior:
224
224
 
@@ -1,4 +1,4 @@
1
- # Message History
1
+ # Message history
2
2
 
3
3
  Message history is the most basic and important form of memory. It gives the LLM a view of recent messages in the context window, enabling your agent to reference earlier exchanges and respond coherently.
4
4
 
@@ -98,12 +98,12 @@ await agent.stream('Hello', {
98
98
 
99
99
  > **Info:** Threads and messages are created automatically when you call `agent.generate()` or `agent.stream()`, but you can also create them manually with [`createThread()`](https://mastra.ai/reference/memory/createThread) and [`saveMessages()`](https://mastra.ai/reference/memory/memory-class).
100
100
 
101
- There are two ways to use this history:
101
+ You can use this history in two ways:
102
102
 
103
103
  - **Automatic inclusion** - Mastra automatically fetches and includes recent messages in the context window. By default, it includes the last 10 messages, keeping agents grounded in the conversation. You can adjust this number with `lastMessages`, but in most cases you don't need to think about it.
104
104
  - [**Manual querying**](#querying) - For more control, use the `recall()` function to query threads and messages directly. This lets you choose exactly which memories are included in the context window, or fetch messages to render conversation history in your UI.
105
105
 
106
- ## Accessing Memory
106
+ ## Accessing memory
107
107
 
108
108
  To access memory functions for querying, cloning, or deleting threads and messages, call `getMemory()` on an agent:
109
109
 
@@ -118,7 +118,7 @@ The `Memory` instance gives you access to functions for listing threads, recalli
118
118
 
119
119
  Use these methods to fetch threads and messages for displaying conversation history in your UI or for custom memory retrieval logic.
120
120
 
121
- > **Warning:** The memory system does not enforce access control. Before running any query, verify in your application logic that the current user is authorized to access the `resourceId` being queried.
121
+ > **Warning:** The memory system doesn't enforce access control. Before running any query, verify in your application logic that the current user is authorized to access the `resourceId` being queried.
122
122
 
123
123
  ### Threads
124
124
 
@@ -1,10 +1,10 @@
1
- # Observational Memory
1
+ # Observational memory
2
2
 
3
3
  **Added in:** `@mastra/memory@1.1.0`
4
4
 
5
5
  Observational Memory (OM) is Mastra's memory system for long-context agentic memory. Two background agents — an **Observer** and a **Reflector** — watch your agent's conversations and maintain a dense observation log that replaces raw message history as it grows.
6
6
 
7
- ## Quick Start
7
+ ## Quick start
8
8
 
9
9
  Enable `observationalMemory` in the memory options when creating your agent:
10
10
 
@@ -46,7 +46,7 @@ See [configuration options](https://mastra.ai/reference/memory/observational-mem
46
46
  - **Compression**: Raw message history and tool results get compressed into a dense observation log. Smaller context means faster responses and longer coherent conversations.
47
47
  - **Zero context rot**: The agent sees relevant information instead of noisy tool calls and irrelevant tokens, so the agent stays on task over long sessions.
48
48
 
49
- ## How It Works
49
+ ## How it works
50
50
 
51
51
  You don't remember every word of every conversation you've ever had. You observe what happened subconsciously, then your brain reflects — reorganizing, combining, and condensing into long-term memory. OM works the same way.
52
52
 
@@ -61,6 +61,10 @@ OM solves both problems by compressing old context into dense observations.
61
61
 
62
62
  When message history tokens exceed a threshold (default: 30,000), the Observer creates observations — concise notes about what happened:
63
63
 
64
+ Image parts contribute to this threshold with model-aware estimates, so multimodal conversations trigger observation at the right time. The same applies to image-like `file` parts when a transport normalizes an uploaded image as a file instead of an image part. For example, OpenAI image detail settings can materially change when OM decides to observe.
65
+
66
+ The Observer can also see attachments in the history it reviews. OM keeps readable placeholders like `[Image #1: reference-board.png]` or `[File #1: floorplan.pdf]` in the transcript for readability, and forwards the actual attachment parts alongside the text. Image-like `file` parts are upgraded to image inputs for the Observer when possible, while non-image attachments are forwarded as file parts with normalized token counting. This applies to both normal thread observation and batched resource-scope observation.
67
+
64
68
  ```text
65
69
  Date: 2026-01-15
66
70
  - 🔴 12:10 User is building a Next.js app with Supabase auth, due in 1 week (meaning January 22nd 2026)
@@ -145,7 +149,7 @@ For your use-case this may not be a problem, so your mileage may vary.
145
149
 
146
150
  > **Warning:** In resource scope, unobserved messages across _all_ threads are processed together. For users with many existing threads, this can be slow. Use thread scope for existing apps.
147
151
 
148
- ## Token Budgets
152
+ ## Token budgets
149
153
 
150
154
  OM uses token thresholds to decide when to observe and reflect. See [token budget configuration](https://mastra.ai/reference/memory/observational-memory) for details.
151
155
 
@@ -177,9 +181,9 @@ OM caches tiktoken part estimates in message metadata to reduce repeat counting
177
181
  - Per-part estimates are stored on `part.providerMetadata.mastra` and reused on subsequent passes when the cache version/tokenizer source matches.
178
182
  - For string-only message content (without parts), OM uses a message-level metadata fallback cache.
179
183
  - Message and conversation overhead are still recalculated on every pass. The cache only stores payload estimates, so counting semantics stay the same.
180
- - `data-*` and `reasoning` parts are still skipped and are not cached.
184
+ - `data-*` and `reasoning` parts are still skipped and aren't cached.
181
185
 
182
- ## Async Buffering
186
+ ## Async buffering
183
187
 
184
188
  Without async buffering, the Observer runs synchronously when the message threshold is reached — the agent pauses mid-conversation while the Observer LLM call completes. With async buffering (enabled by default), observations are pre-computed in the background as the conversation grows. When the threshold is hit, buffered observations activate instantly with no pause.
185
189
 
@@ -224,7 +228,7 @@ const memory = new Memory({
224
228
 
225
229
  Setting `bufferTokens: false` disables both observation and reflection async buffering. See [async buffering configuration](https://mastra.ai/reference/memory/observational-memory) for the full API.
226
230
 
227
- > **Note:** Async buffering is not supported with `scope: 'resource'`. It is automatically disabled in resource scope.
231
+ > **Note:** Async buffering isn't supported with `scope: 'resource'`. It's automatically disabled in resource scope.
228
232
 
229
233
  ## Migrating existing threads
230
234
 
@@ -1,10 +1,10 @@
1
- # Semantic Recall
1
+ # Semantic recall
2
2
 
3
3
  If you ask your friend what they did last weekend, they will search in their memory for events associated with "last weekend" and then tell you what they did. That's sort of like how semantic recall works in Mastra.
4
4
 
5
5
  > **Watch 📹:** What semantic recall is, how it works, and how to configure it in Mastra → [YouTube (5 minutes)](https://youtu.be/UVZtK8cK8xQ)
6
6
 
7
- ## How Semantic Recall Works
7
+ ## How semantic recall works
8
8
 
9
9
  Semantic recall is RAG-based search that helps agents maintain context across longer interactions when messages are no longer within [recent message history](https://mastra.ai/docs/memory/message-history).
10
10
 
@@ -16,7 +16,7 @@ When it's enabled, new messages are used to query a vector DB for semantically s
16
16
 
17
17
  After getting a response from the LLM, all new messages (user, assistant, and tool calls/results) are inserted into the vector DB to be recalled in later interactions.
18
18
 
19
- ## Quick Start
19
+ ## Quick start
20
20
 
21
21
  Semantic recall is enabled by default, so if you give your agent memory it will be included:
22
22
 
@@ -33,9 +33,9 @@ const agent = new Agent({
33
33
  })
34
34
  ```
35
35
 
36
- ## Using the recall() Method
36
+ ## Using the `recall()` method
37
37
 
38
- While `listMessages` retrieves messages by thread ID with basic pagination, [`recall()`](https://mastra.ai/reference/memory/recall) adds support for **semantic search**. When you need to find messages by meaning rather than just recency, use `recall()` with a `vectorSearchString`:
38
+ While `listMessages` retrieves messages by thread ID with basic pagination, [`recall()`](https://mastra.ai/reference/memory/recall) adds support for **semantic search**. When you need to find messages by meaning rather than recency, use `recall()` with a `vectorSearchString`:
39
39
 
40
40
  ```typescript
41
41
  const memory = await agent.getMemory()
@@ -182,7 +182,7 @@ const agent = new Agent({
182
182
  })
183
183
  ```
184
184
 
185
- ### Using FastEmbed (Local)
185
+ ### Using FastEmbed (local)
186
186
 
187
187
  To use FastEmbed (a local embedding model), install `@mastra/fastembed`:
188
188
 
@@ -224,7 +224,7 @@ const agent = new Agent({
224
224
  })
225
225
  ```
226
226
 
227
- ## PostgreSQL Index Optimization
227
+ ## PostgreSQL index optimization
228
228
 
229
229
  When using PostgreSQL as your vector store, you can optimize semantic recall performance by configuring the vector index. This is particularly important for large-scale deployments with thousands of messages.
230
230
 
@@ -264,7 +264,7 @@ For detailed information about index configuration options and performance tunin
264
264
 
265
265
  ## Disabling
266
266
 
267
- There is a performance impact to using semantic recall. New messages are converted into embeddings and used to query a vector database before new messages are sent to the LLM.
267
+ Semantic recall has a performance impact. New messages are converted into embeddings and used to query a vector database before new messages are sent to the LLM.
268
268
 
269
269
  Semantic recall is enabled by default but can be disabled when not needed:
270
270
 
@@ -283,6 +283,6 @@ You might want to disable semantic recall in scenarios like:
283
283
  - When message history provides sufficient context for the current conversation.
284
284
  - In performance-sensitive applications, like realtime two-way audio, where the added latency of creating embeddings and running vector queries is noticeable.
285
285
 
286
- ## Viewing Recalled Messages
286
+ ## Viewing recalled messages
287
287
 
288
288
  When tracing is enabled, any messages retrieved via semantic recall will appear in the agent's trace output, alongside recent message history (if configured).
@@ -170,7 +170,7 @@ export const agent = new Agent({
170
170
  })
171
171
  ```
172
172
 
173
- Title generation runs asynchronously after the agent responds and does not affect response time.
173
+ Title generation runs asynchronously after the agent responds and doesn't affect response time.
174
174
 
175
175
  To optimize cost or behavior, provide a smaller [`model`](https://mastra.ai/models) and custom `instructions`:
176
176