@mastra/mcp-docs-server 1.1.0 → 1.1.1-alpha.0
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.
- package/.docs/docs/memory/observational-memory.md +166 -0
- package/.docs/docs/memory/overview.md +4 -2
- package/.docs/reference/index.md +1 -0
- package/.docs/reference/memory/memory-class.md +3 -0
- package/.docs/reference/memory/observational-memory.md +217 -0
- package/CHANGELOG.md +7 -0
- package/package.json +5 -6
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
# Observational Memory
|
|
2
|
+
|
|
3
|
+
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.
|
|
4
|
+
|
|
5
|
+
## Quick Start
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
import { Memory } from "@mastra/memory";
|
|
9
|
+
import { Agent } from "@mastra/core/agent";
|
|
10
|
+
|
|
11
|
+
export const agent = new Agent({
|
|
12
|
+
name: "my-agent",
|
|
13
|
+
instructions: "You are a helpful assistant.",
|
|
14
|
+
model: "openai/gpt-5-mini",
|
|
15
|
+
memory: new Memory({
|
|
16
|
+
options: {
|
|
17
|
+
observationalMemory: true,
|
|
18
|
+
},
|
|
19
|
+
}),
|
|
20
|
+
});
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
That's it. The agent now has humanlike long-term memory that persists across conversations.
|
|
24
|
+
|
|
25
|
+
See [configuration options](https://mastra.ai/reference/memory/observational-memory) for full API details.
|
|
26
|
+
|
|
27
|
+
> **Note:** OM currently only supports `@mastra/pg`, `@mastra/libsql`, and `@mastra/mongodb` storage adapters. It also uses background agents for managing memory. The default model (configurable) is `google/gemini-2.5-flash` as it's the one we've tested the most.
|
|
28
|
+
|
|
29
|
+
## Benefits
|
|
30
|
+
|
|
31
|
+
- **Prompt caching**: OM's context is stable — observations append over time rather than being dynamically retrieved each turn. This keeps the prompt prefix cacheable, which reduces costs.
|
|
32
|
+
- **Compression**: Raw message history and tool results get compressed into a dense observation log. Smaller context means faster responses and longer coherent conversations.
|
|
33
|
+
- **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.
|
|
34
|
+
|
|
35
|
+
## How It Works
|
|
36
|
+
|
|
37
|
+
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.
|
|
38
|
+
|
|
39
|
+
Every time an agent responds, it sees a context window containing its system prompt, recent message history, and any injected context. The context window is finite — even models with large token limits perform worse when the window is full. This causes two problems:
|
|
40
|
+
|
|
41
|
+
- **Context rot**: the more raw message history an agent carries, the worse it performs.
|
|
42
|
+
- **Context waste**: most of that history contains tokens no longer needed to keep the agent on task.
|
|
43
|
+
|
|
44
|
+
OM solves both problems by compressing old context into dense observations.
|
|
45
|
+
|
|
46
|
+
### Observations
|
|
47
|
+
|
|
48
|
+
When message history tokens exceed a threshold (default: 30,000), the Observer creates observations — concise notes about what happened:
|
|
49
|
+
|
|
50
|
+
```text
|
|
51
|
+
Date: 2026-01-15
|
|
52
|
+
- 🔴 12:10 User is building a Next.js app with Supabase auth, due in 1 week (meaning January 22nd 2026)
|
|
53
|
+
- 🔴 12:10 App uses server components with client-side hydration
|
|
54
|
+
- 🟡 12:12 User asked about middleware configuration for protected routes
|
|
55
|
+
- 🔴 12:15 User stated the app name is "Acme Dashboard"
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
The compression is typically 5–40×. The Observer also tracks a **current task** and **suggested response** so the agent picks up where it left off.
|
|
59
|
+
|
|
60
|
+
Example: an agent using Playwright MCP might see 50,000+ tokens per page snapshot. With OM, the Observer watches the interaction and creates a few hundred tokens of observations about what was on the page and what actions were taken. The agent stays on task without carrying every raw snapshot.
|
|
61
|
+
|
|
62
|
+
### Reflections
|
|
63
|
+
|
|
64
|
+
When observations exceed their threshold (default: 40,000 tokens), the Reflector condenses them — combining related items and reflecting on patterns.
|
|
65
|
+
|
|
66
|
+
The result is a three-tier system:
|
|
67
|
+
|
|
68
|
+
1. **Recent messages** — exact conversation history for the current task
|
|
69
|
+
2. **Observations** — a log of what the Observer has seen
|
|
70
|
+
3. **Reflections** — condensed observations when memory becomes too long
|
|
71
|
+
|
|
72
|
+
## Models
|
|
73
|
+
|
|
74
|
+
The Observer and Reflector run in the background. Any model that works with Mastra's model routing (e.g. `openai/...`, `google/...`, `deepseek/...`) can be used.
|
|
75
|
+
|
|
76
|
+
The default is `google/gemini-2.5-flash` — it works well for both observation and reflection, and its 1M token context window gives the Reflector headroom.
|
|
77
|
+
|
|
78
|
+
We've also tested `deepseek`, `qwen3`, and `glm-4.7` for the Observer. For the Reflector, make sure the model's context window can fit all observations. Note that Claude 4.5 models currently don't work well as observer or reflector.
|
|
79
|
+
|
|
80
|
+
```typescript
|
|
81
|
+
const memory = new Memory({
|
|
82
|
+
options: {
|
|
83
|
+
observationalMemory: {
|
|
84
|
+
model: "deepseek/deepseek-reasoner",
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
});
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
See [model configuration](https://mastra.ai/reference/memory/observational-memory) for using different models per agent.
|
|
91
|
+
|
|
92
|
+
## Scopes
|
|
93
|
+
|
|
94
|
+
### Thread scope (default)
|
|
95
|
+
|
|
96
|
+
Each thread has its own observations.
|
|
97
|
+
|
|
98
|
+
```typescript
|
|
99
|
+
observationalMemory: {
|
|
100
|
+
scope: "thread",
|
|
101
|
+
}
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### Resource scope
|
|
105
|
+
|
|
106
|
+
Observations are shared across all threads for a resource (typically a user). Enables cross-conversation memory.
|
|
107
|
+
|
|
108
|
+
```typescript
|
|
109
|
+
observationalMemory: {
|
|
110
|
+
scope: "resource",
|
|
111
|
+
}
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
> **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.
|
|
115
|
+
|
|
116
|
+
## Token Budgets
|
|
117
|
+
|
|
118
|
+
OM uses token thresholds to decide when to observe and reflect. See [token budget configuration](https://mastra.ai/reference/memory/observational-memory) for details.
|
|
119
|
+
|
|
120
|
+
```typescript
|
|
121
|
+
const memory = new Memory({
|
|
122
|
+
options: {
|
|
123
|
+
observationalMemory: {
|
|
124
|
+
observation: {
|
|
125
|
+
// when to run the Observer (default: 30,000)
|
|
126
|
+
messageTokens: 30_000,
|
|
127
|
+
},
|
|
128
|
+
reflection: {
|
|
129
|
+
// when to run the Reflector (default: 40,000)
|
|
130
|
+
observationTokens: 40_000,
|
|
131
|
+
},
|
|
132
|
+
// let message history borrow from observation budget
|
|
133
|
+
shareTokenBudget: false,
|
|
134
|
+
},
|
|
135
|
+
},
|
|
136
|
+
});
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
## Migrating existing threads
|
|
140
|
+
|
|
141
|
+
No manual migration needed. OM reads existing messages and observes them lazily when thresholds are exceeded.
|
|
142
|
+
|
|
143
|
+
- **Thread scope**: The first time a thread exceeds `observation.messageTokens`, the Observer processes the backlog.
|
|
144
|
+
- **Resource scope**: All unobserved messages across all threads for a resource are processed together. For users with many existing threads, this could take significant time.
|
|
145
|
+
|
|
146
|
+
## Viewing in Mastra Studio
|
|
147
|
+
|
|
148
|
+
Mastra Studio shows OM status in real time in the memory tab: token usage, which model is running, current observations, and reflection history.
|
|
149
|
+
|
|
150
|
+
## Comparing OM with other memory features
|
|
151
|
+
|
|
152
|
+
- **[Message history](https://mastra.ai/docs/memory/message-history)** — high-fidelity record of the current conversation
|
|
153
|
+
- **[Working memory](https://mastra.ai/docs/memory/working-memory)** — small, structured state (JSON or markdown) for user preferences, names, goals
|
|
154
|
+
- **[Semantic Recall](https://mastra.ai/docs/memory/semantic-recall)** — RAG-based retrieval of relevant past messages
|
|
155
|
+
- **Observational Memory** — long-context agentic memory that compresses extended sessions
|
|
156
|
+
|
|
157
|
+
If you're using working memory to store conversation summaries or ongoing state that grows over time, OM is a better fit. Working memory is for small, structured data; OM is for long-running event logs. OM also manages message history automatically—the `messageTokens` setting controls how much raw history remains before observation runs.
|
|
158
|
+
|
|
159
|
+
In practical terms, OM replaces both working memory and message history, and has greater accuracy (and lower cost) than Semantic Recall.
|
|
160
|
+
|
|
161
|
+
## Related
|
|
162
|
+
|
|
163
|
+
- [Observational Memory Reference](https://mastra.ai/reference/memory/observational-memory) — configuration options and API
|
|
164
|
+
- [Memory Overview](https://mastra.ai/docs/memory/overview)
|
|
165
|
+
- [Message History](https://mastra.ai/docs/memory/message-history)
|
|
166
|
+
- [Memory Processors](https://mastra.ai/docs/memory/memory-processors)
|
|
@@ -2,11 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
Memory enables your agent to remember user messages, agent replies, and tool results across interactions, giving it the context it needs to stay consistent, maintain conversation flow, and produce better answers over time.
|
|
4
4
|
|
|
5
|
-
Mastra supports
|
|
5
|
+
Mastra supports four complementary memory types:
|
|
6
6
|
|
|
7
7
|
- [**Message history**](https://mastra.ai/docs/memory/message-history) - keeps recent messages from the current conversation so they can be rendered in the UI and used to maintain short-term continuity within the exchange.
|
|
8
8
|
- [**Working memory**](https://mastra.ai/docs/memory/working-memory) - stores persistent, structured user data such as names, preferences, and goals.
|
|
9
9
|
- [**Semantic recall**](https://mastra.ai/docs/memory/semantic-recall) - retrieves relevant messages from older conversations based on semantic meaning rather than exact keywords, mirroring how humans recall information by association. Requires a [vector database](https://mastra.ai/docs/memory/semantic-recall) and an [embedding model](https://mastra.ai/docs/memory/semantic-recall).
|
|
10
|
+
- [**Observational memory**](https://mastra.ai/docs/memory/observational-memory) - uses background Observer and Reflector agents to maintain a dense observation log that replaces raw message history as it grows, keeping the context window small while preserving long-term memory across conversations.
|
|
10
11
|
|
|
11
12
|
If the combined memory exceeds the model's context limit, [memory processors](https://mastra.ai/docs/memory/memory-processors) can filter, trim, or prioritize content so the most relevant information is preserved.
|
|
12
13
|
|
|
@@ -17,6 +18,7 @@ Choose a memory option to get started:
|
|
|
17
18
|
- [Message history](https://mastra.ai/docs/memory/message-history)
|
|
18
19
|
- [Working memory](https://mastra.ai/docs/memory/working-memory)
|
|
19
20
|
- [Semantic recall](https://mastra.ai/docs/memory/semantic-recall)
|
|
21
|
+
- [Observational memory](https://mastra.ai/docs/memory/observational-memory)
|
|
20
22
|
|
|
21
23
|
## Storage
|
|
22
24
|
|
|
@@ -39,5 +41,5 @@ This visibility helps you understand why an agent made specific decisions and ve
|
|
|
39
41
|
## Next steps
|
|
40
42
|
|
|
41
43
|
- Learn more about [Storage](https://mastra.ai/docs/memory/storage) providers and configuration options
|
|
42
|
-
- Add [Message history](https://mastra.ai/docs/memory/message-history), [Working memory](https://mastra.ai/docs/memory/working-memory),
|
|
44
|
+
- Add [Message history](https://mastra.ai/docs/memory/message-history), [Working memory](https://mastra.ai/docs/memory/working-memory), [Semantic recall](https://mastra.ai/docs/memory/semantic-recall), or [Observational memory](https://mastra.ai/docs/memory/observational-memory)
|
|
43
45
|
- Visit [Memory configuration reference](https://mastra.ai/reference/memory/memory-class) for all available options
|
package/.docs/reference/index.md
CHANGED
|
@@ -104,6 +104,7 @@ The Reference section provides documentation of Mastra's API, including paramete
|
|
|
104
104
|
- [Tool Call Accuracy Scorers](https://mastra.ai/reference/evals/tool-call-accuracy)
|
|
105
105
|
- [Toxicity](https://mastra.ai/reference/evals/toxicity)
|
|
106
106
|
- [Memory Class](https://mastra.ai/reference/memory/memory-class)
|
|
107
|
+
- [Observational Memory](https://mastra.ai/reference/memory/observational-memory)
|
|
107
108
|
- [.createThread()](https://mastra.ai/reference/memory/createThread)
|
|
108
109
|
- [.deleteMessages()](https://mastra.ai/reference/memory/deleteMessages)
|
|
109
110
|
- [.getThreadById()](https://mastra.ai/reference/memory/getThreadById)
|
|
@@ -44,6 +44,8 @@ export const agent = new Agent({
|
|
|
44
44
|
|
|
45
45
|
**workingMemory?:** (`WorkingMemory`): Configuration for working memory feature. Can be \`{ enabled: boolean; template?: string; schema?: ZodObject\<any> | JSONSchema7; scope?: 'thread' | 'resource' }\` or \`{ enabled: boolean }\` to disable. (Default: `{ enabled: false, template: '# User Information\n- **First Name**:\n- **Last Name**:\n...' }`)
|
|
46
46
|
|
|
47
|
+
**observationalMemory?:** (`boolean | ObservationalMemoryOptions`): Enable Observational Memory for long-context agentic memory. Set to \`true\` for defaults, or pass a config object to customize token budgets, models, and scope. See \[Observational Memory reference]\(/reference/memory/observational-memory) for configuration details. (Default: `false`)
|
|
48
|
+
|
|
47
49
|
**generateTitle?:** (`boolean | { model: DynamicArgument<MastraLanguageModel>; instructions?: DynamicArgument<string> }`): Controls automatic thread title generation from the user's first message. Can be a boolean or an object with custom model and instructions. (Default: `false`)
|
|
48
50
|
|
|
49
51
|
## Returns
|
|
@@ -134,6 +136,7 @@ export const agent = new Agent({
|
|
|
134
136
|
- [Getting Started with Memory](https://mastra.ai/docs/memory/overview)
|
|
135
137
|
- [Semantic Recall](https://mastra.ai/docs/memory/semantic-recall)
|
|
136
138
|
- [Working Memory](https://mastra.ai/docs/memory/working-memory)
|
|
139
|
+
- [Observational Memory](https://mastra.ai/docs/memory/observational-memory)
|
|
137
140
|
- [Memory Processors](https://mastra.ai/docs/memory/memory-processors)
|
|
138
141
|
- [createThread](https://mastra.ai/reference/memory/createThread)
|
|
139
142
|
- [recall](https://mastra.ai/reference/memory/recall)
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
# Observational Memory
|
|
2
|
+
|
|
3
|
+
Observational Memory (OM) is Mastra's memory system for long-context agentic memory. Two background agents — an **Observer** that watches conversations and creates observations, and a **Reflector** that restructures observations by combining related items, reflecting on overarching patterns, and condensing where possible — maintain an observation log that replaces raw message history as it grows.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
import { Memory } from "@mastra/memory";
|
|
9
|
+
import { Agent } from "@mastra/core/agent";
|
|
10
|
+
|
|
11
|
+
export const agent = new Agent({
|
|
12
|
+
name: "my-agent",
|
|
13
|
+
instructions: "You are a helpful assistant.",
|
|
14
|
+
model: "openai/gpt-5-mini",
|
|
15
|
+
memory: new Memory({
|
|
16
|
+
options: {
|
|
17
|
+
observationalMemory: true,
|
|
18
|
+
},
|
|
19
|
+
}),
|
|
20
|
+
});
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Configuration
|
|
24
|
+
|
|
25
|
+
The `observationalMemory` option accepts `true`, `false`, or a configuration object.
|
|
26
|
+
|
|
27
|
+
Setting `observationalMemory: true` enables it with all defaults. Setting `observationalMemory: false` or omitting it disables it.
|
|
28
|
+
|
|
29
|
+
**enabled?:** (`boolean`): Enable or disable Observational Memory. When omitted from a config object, defaults to \`true\`. Only \`enabled: false\` explicitly disables it. (Default: `true`)
|
|
30
|
+
|
|
31
|
+
**model?:** (`string | LanguageModel | DynamicModel | ModelWithRetries[]`): Model for both the Observer and Reflector agents. Sets the model for both at once. Cannot be used together with \`observation.model\` or \`reflection.model\` — an error will be thrown if both are set. (Default: `'google/gemini-2.5-flash'`)
|
|
32
|
+
|
|
33
|
+
**scope?:** (`'resource' | 'thread'`): Memory scope for observations. \`'thread'\` keeps observations per-thread. \`'resource'\` shares observations across all threads for a resource, enabling cross-conversation memory. (Default: `'thread'`)
|
|
34
|
+
|
|
35
|
+
**shareTokenBudget?:** (`boolean`): Share the token budget between messages and observations. When enabled, the total budget is \`observation.messageTokens + reflection.observationTokens\`. Messages can use more space when observations are small, and vice versa. This maximizes context usage through flexible allocation. (Default: `false`)
|
|
36
|
+
|
|
37
|
+
**observation?:** (`ObservationalMemoryObservationConfig`): Configuration for the observation step. Controls when the Observer agent runs and how it behaves.
|
|
38
|
+
|
|
39
|
+
**reflection?:** (`ObservationalMemoryReflectionConfig`): Configuration for the reflection step. Controls when the Reflector agent runs and how it behaves.
|
|
40
|
+
|
|
41
|
+
### Observation config
|
|
42
|
+
|
|
43
|
+
**model?:** (`string | LanguageModel | DynamicModel | ModelWithRetries[]`): Model for the Observer agent. Cannot be set if a top-level \`model\` is also provided. (Default: `'google/gemini-2.5-flash'`)
|
|
44
|
+
|
|
45
|
+
**messageTokens?:** (`number`): Token count of unobserved messages that triggers observation. When unobserved message tokens exceed this threshold, the Observer agent is called. (Default: `30000`)
|
|
46
|
+
|
|
47
|
+
**maxTokensPerBatch?:** (`number`): Maximum tokens per batch when observing multiple threads in resource scope. Threads are chunked into batches of this size and processed in parallel. Lower values mean more parallelism but more API calls. (Default: `10000`)
|
|
48
|
+
|
|
49
|
+
**modelSettings?:** (`ObservationalMemoryModelSettings`): Model settings for the Observer agent. (Default: `{ temperature: 0.3, maxOutputTokens: 100_000 }`)
|
|
50
|
+
|
|
51
|
+
### Reflection config
|
|
52
|
+
|
|
53
|
+
**model?:** (`string | LanguageModel | DynamicModel | ModelWithRetries[]`): Model for the Reflector agent. Cannot be set if a top-level \`model\` is also provided. (Default: `'google/gemini-2.5-flash'`)
|
|
54
|
+
|
|
55
|
+
**observationTokens?:** (`number`): Token count of observations that triggers reflection. When observation tokens exceed this threshold, the Reflector agent is called to condense them. (Default: `40000`)
|
|
56
|
+
|
|
57
|
+
**modelSettings?:** (`ObservationalMemoryModelSettings`): Model settings for the Reflector agent. (Default: `{ temperature: 0, maxOutputTokens: 100_000 }`)
|
|
58
|
+
|
|
59
|
+
### Model settings
|
|
60
|
+
|
|
61
|
+
**temperature?:** (`number`): Temperature for generation. Lower values produce more consistent output. (Default: `0.3`)
|
|
62
|
+
|
|
63
|
+
**maxOutputTokens?:** (`number`): Maximum output tokens. Set high to prevent truncation of observations. (Default: `100000`)
|
|
64
|
+
|
|
65
|
+
## Examples
|
|
66
|
+
|
|
67
|
+
### Resource scope with custom thresholds
|
|
68
|
+
|
|
69
|
+
```typescript
|
|
70
|
+
import { Memory } from "@mastra/memory";
|
|
71
|
+
import { Agent } from "@mastra/core/agent";
|
|
72
|
+
|
|
73
|
+
export const agent = new Agent({
|
|
74
|
+
name: "my-agent",
|
|
75
|
+
instructions: "You are a helpful assistant.",
|
|
76
|
+
model: "openai/gpt-5-mini",
|
|
77
|
+
memory: new Memory({
|
|
78
|
+
options: {
|
|
79
|
+
observationalMemory: {
|
|
80
|
+
scope: "resource",
|
|
81
|
+
observation: {
|
|
82
|
+
messageTokens: 20_000,
|
|
83
|
+
},
|
|
84
|
+
reflection: {
|
|
85
|
+
observationTokens: 60_000,
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
}),
|
|
90
|
+
});
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### Shared token budget
|
|
94
|
+
|
|
95
|
+
```typescript
|
|
96
|
+
import { Memory } from "@mastra/memory";
|
|
97
|
+
import { Agent } from "@mastra/core/agent";
|
|
98
|
+
|
|
99
|
+
export const agent = new Agent({
|
|
100
|
+
name: "my-agent",
|
|
101
|
+
instructions: "You are a helpful assistant.",
|
|
102
|
+
model: "openai/gpt-5-mini",
|
|
103
|
+
memory: new Memory({
|
|
104
|
+
options: {
|
|
105
|
+
observationalMemory: {
|
|
106
|
+
shareTokenBudget: true,
|
|
107
|
+
observation: {
|
|
108
|
+
messageTokens: 20_000,
|
|
109
|
+
},
|
|
110
|
+
reflection: {
|
|
111
|
+
observationTokens: 80_000,
|
|
112
|
+
},
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
}),
|
|
116
|
+
});
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
When `shareTokenBudget` is enabled, the total budget is `observation.messageTokens + reflection.observationTokens` (100k in this example). If observations only use 30k tokens, messages can expand to use up to 70k. If messages are short, observations have more room before triggering reflection.
|
|
120
|
+
|
|
121
|
+
### Custom model
|
|
122
|
+
|
|
123
|
+
```typescript
|
|
124
|
+
import { Memory } from "@mastra/memory";
|
|
125
|
+
import { Agent } from "@mastra/core/agent";
|
|
126
|
+
|
|
127
|
+
export const agent = new Agent({
|
|
128
|
+
name: "my-agent",
|
|
129
|
+
instructions: "You are a helpful assistant.",
|
|
130
|
+
model: "openai/gpt-5-mini",
|
|
131
|
+
memory: new Memory({
|
|
132
|
+
options: {
|
|
133
|
+
observationalMemory: {
|
|
134
|
+
model: "openai/gpt-4o-mini",
|
|
135
|
+
},
|
|
136
|
+
},
|
|
137
|
+
}),
|
|
138
|
+
});
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
### Different models per agent
|
|
142
|
+
|
|
143
|
+
```typescript
|
|
144
|
+
import { Memory } from "@mastra/memory";
|
|
145
|
+
import { Agent } from "@mastra/core/agent";
|
|
146
|
+
|
|
147
|
+
export const agent = new Agent({
|
|
148
|
+
name: "my-agent",
|
|
149
|
+
instructions: "You are a helpful assistant.",
|
|
150
|
+
model: "openai/gpt-5-mini",
|
|
151
|
+
memory: new Memory({
|
|
152
|
+
options: {
|
|
153
|
+
observationalMemory: {
|
|
154
|
+
observation: {
|
|
155
|
+
model: "google/gemini-2.5-flash",
|
|
156
|
+
},
|
|
157
|
+
reflection: {
|
|
158
|
+
model: "openai/gpt-4o-mini",
|
|
159
|
+
},
|
|
160
|
+
},
|
|
161
|
+
},
|
|
162
|
+
}),
|
|
163
|
+
});
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
## Standalone usage
|
|
167
|
+
|
|
168
|
+
Most users should use the `Memory` class above. Using `ObservationalMemory` directly is mainly useful for benchmarking, experimentation, or when you need to control processor ordering with other processors (like [guardrails](https://mastra.ai/docs/agents/guardrails)).
|
|
169
|
+
|
|
170
|
+
```typescript
|
|
171
|
+
import { ObservationalMemory } from "@mastra/memory/processors";
|
|
172
|
+
import { Agent } from "@mastra/core/agent";
|
|
173
|
+
import { LibSQLStore } from "@mastra/libsql";
|
|
174
|
+
|
|
175
|
+
const storage = new LibSQLStore({
|
|
176
|
+
id: "my-storage",
|
|
177
|
+
url: "file:./memory.db",
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
const om = new ObservationalMemory({
|
|
181
|
+
storage: storage.stores.memory,
|
|
182
|
+
model: "google/gemini-2.5-flash",
|
|
183
|
+
scope: "resource",
|
|
184
|
+
observation: {
|
|
185
|
+
messageTokens: 20_000,
|
|
186
|
+
},
|
|
187
|
+
reflection: {
|
|
188
|
+
observationTokens: 60_000,
|
|
189
|
+
},
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
export const agent = new Agent({
|
|
193
|
+
name: "my-agent",
|
|
194
|
+
instructions: "You are a helpful assistant.",
|
|
195
|
+
model: "openai/gpt-5-mini",
|
|
196
|
+
inputProcessors: [om],
|
|
197
|
+
outputProcessors: [om],
|
|
198
|
+
});
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
### Standalone config
|
|
202
|
+
|
|
203
|
+
The standalone `ObservationalMemory` class accepts all the same options as the `observationalMemory` config object above, plus the following:
|
|
204
|
+
|
|
205
|
+
**storage:** (`MemoryStorage`): Storage adapter for persisting observations. Must be a MemoryStorage instance (from \`MastraStorage.stores.memory\`).
|
|
206
|
+
|
|
207
|
+
**onDebugEvent?:** (`(event: ObservationDebugEvent) => void`): Debug callback for observation events. Called whenever observation-related events occur. Useful for debugging and understanding the observation flow.
|
|
208
|
+
|
|
209
|
+
**obscureThreadIds?:** (`boolean`): When enabled, thread IDs are hashed before being included in observation context. This prevents the LLM from recognizing patterns in thread identifiers. Automatically enabled when using resource scope through the Memory class. (Default: `false`)
|
|
210
|
+
|
|
211
|
+
### Related
|
|
212
|
+
|
|
213
|
+
- [Observational Memory](https://mastra.ai/docs/memory/observational-memory)
|
|
214
|
+
- [Memory Overview](https://mastra.ai/docs/memory/overview)
|
|
215
|
+
- [Memory Class](https://mastra.ai/reference/memory/memory-class)
|
|
216
|
+
- [Memory Processors](https://mastra.ai/docs/memory/memory-processors)
|
|
217
|
+
- [Processors](https://mastra.ai/docs/agents/processors)
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# @mastra/mcp-docs-server
|
|
2
2
|
|
|
3
|
+
## 1.1.1-alpha.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [[`90f7894`](https://github.com/mastra-ai/mastra/commit/90f7894568dc9481f40a4d29672234fae23090bb), [`8109aee`](https://github.com/mastra-ai/mastra/commit/8109aeeab758e16cd4255a6c36f044b70eefc6a6)]:
|
|
8
|
+
- @mastra/core@1.2.1-alpha.0
|
|
9
|
+
|
|
3
10
|
## 1.1.0
|
|
4
11
|
|
|
5
12
|
### Minor Changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/mcp-docs-server",
|
|
3
|
-
"version": "1.1.0",
|
|
3
|
+
"version": "1.1.1-alpha.0",
|
|
4
4
|
"description": "MCP server for accessing Mastra.ai documentation, changelogs, and news.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"jsdom": "^26.1.0",
|
|
30
30
|
"local-pkg": "^1.1.2",
|
|
31
31
|
"zod": "^3.25.76",
|
|
32
|
-
"@mastra/core": "1.2.0",
|
|
32
|
+
"@mastra/core": "1.2.1-alpha.0",
|
|
33
33
|
"@mastra/mcp": "^1.0.0"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
@@ -46,9 +46,9 @@
|
|
|
46
46
|
"tsx": "^4.21.0",
|
|
47
47
|
"typescript": "^5.9.3",
|
|
48
48
|
"vitest": "4.0.16",
|
|
49
|
-
"@internal/
|
|
50
|
-
"@mastra/core": "1.2.0",
|
|
51
|
-
"@internal/
|
|
49
|
+
"@internal/lint": "0.0.57",
|
|
50
|
+
"@mastra/core": "1.2.1-alpha.0",
|
|
51
|
+
"@internal/types-builder": "0.0.32"
|
|
52
52
|
},
|
|
53
53
|
"homepage": "https://mastra.ai",
|
|
54
54
|
"repository": {
|
|
@@ -63,7 +63,6 @@
|
|
|
63
63
|
"node": ">=22.13.0"
|
|
64
64
|
},
|
|
65
65
|
"scripts": {
|
|
66
|
-
"build:docs": "cd ../../docs && pnpm build",
|
|
67
66
|
"prepare-docs": "tsx ./scripts/prepare-docs.ts",
|
|
68
67
|
"build:cli": "tsup --silent --config tsup.config.ts",
|
|
69
68
|
"pretest": "pnpm turbo build --filter @mastra/mcp-docs-server",
|