@mastra/memory 1.42.0-alpha.2 → 1.42.0-alpha.4

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 (44) hide show
  1. package/dist/docs/SKILL.md +1 -1
  2. package/dist/docs/assets/SOURCE_MAP.json +84 -84
  3. package/dist/docs/references/docs-agents-human-in-the-loop.md +2 -2
  4. package/dist/docs/references/docs-agents-networks.md +1 -1
  5. package/dist/docs/references/docs-guides-context-engineering.md +3 -3
  6. package/dist/docs/references/docs-harness-background-tasks.md +2 -2
  7. package/dist/docs/references/docs-harness-goals.md +2 -2
  8. package/dist/docs/references/docs-knowledge-overview.md +1 -1
  9. package/dist/docs/references/docs-memory-memory-processors.md +8 -8
  10. package/dist/docs/references/docs-memory-message-history.md +3 -3
  11. package/dist/docs/references/docs-memory-observational-memory.md +1 -1
  12. package/dist/docs/references/docs-memory-semantic-recall.md +2 -2
  13. package/dist/docs/references/docs-memory-working-memory.md +3 -2
  14. package/dist/docs/references/docs-signals-overview.md +1 -1
  15. package/dist/docs/references/docs-storage.md +12 -12
  16. package/dist/docs/references/docs-subagents.md +26 -3
  17. package/dist/docs/references/integrations-channels-github.md +1 -1
  18. package/dist/docs/references/integrations-channels-ring.md +2 -2
  19. package/dist/docs/references/integrations-databases-aurora-dsql.md +1 -1
  20. package/dist/docs/references/integrations-databases-elasticsearch.md +1 -1
  21. package/dist/docs/references/integrations-databases-libsql.md +6 -0
  22. package/dist/docs/references/integrations-databases-mongodb.md +1 -1
  23. package/dist/docs/references/integrations-databases-oracledb.md +1 -1
  24. package/dist/docs/references/integrations-databases-postgresql.md +9 -1
  25. package/dist/docs/references/integrations-databases-redis.md +1 -1
  26. package/dist/docs/references/integrations-databases-upstash.md +1 -1
  27. package/dist/docs/references/reference-memory-memory-class.md +3 -3
  28. package/dist/docs/references/reference-memory-observational-memory.md +7 -3
  29. package/dist/docs/references/reference-processors-token-limiter-processor.md +3 -3
  30. package/dist/index.cjs +1 -1
  31. package/dist/index.d.ts +2 -0
  32. package/dist/index.js +1 -1
  33. package/dist/processors/index.cjs +1 -1
  34. package/dist/processors/index.js +1 -1
  35. package/dist/processors/observational-memory/cache-boundary.d.ts +21 -0
  36. package/dist/processors/observational-memory/constants.d.ts +1 -1
  37. package/dist/processors/observational-memory/date-utils.d.ts +4 -0
  38. package/dist/processors/observational-memory/observational-memory.d.ts +1 -0
  39. package/dist/processors/observational-memory/processor.d.ts +3 -1
  40. package/dist/processors/observational-memory/thresholds.d.ts +2 -0
  41. package/dist/processors/observational-memory/types.d.ts +5 -0
  42. package/dist/{src-Bv05c6Nj.js → src-CVekC2V9.js} +102 -25
  43. package/dist/{src-D2dL-xVG.cjs → src-DaOrkH_R.cjs} +102 -25
  44. package/package.json +2 -2
@@ -45,7 +45,7 @@ const parentAgent = new Agent({
45
45
  id: 'parent-agent',
46
46
  instructions: `You coordinate research and writing using specialized agents.
47
47
  Delegate to research-agent for facts, then writing-agent for content.`,
48
- model: 'openai/gpt-6.1-sol',
48
+ model: 'openai/gpt-6.2-sol',
49
49
  agents: { researchAgent, writingAgent },
50
50
  memory: new Memory({
51
51
  storage: new LibSQLStore({ id: 'storage', url: 'file:mastra.db' }),
@@ -61,6 +61,29 @@ for await (const chunk of stream.textStream) {
61
61
  }
62
62
  ```
63
63
 
64
+ ## Delegate to workflows
65
+
66
+ A parent agent can also delegate to workflows. Add them to the [`workflows`](https://mastra.ai/reference/agents/agent) option next to `agents`. Mastra converts each workflow to a `workflow-<key>` tool, the same way it converts each subagent to an `agent-<key>` tool. The model calls the tool with `inputData` that matches the workflow's `inputSchema`, plus `initialState` when the workflow defines a `stateSchema`. The tool starts a new run and returns its `runId` with the workflow `result`. When the run finishes with a failed status, the tool returns the `runId` with an `error` message instead, and the model can read it. When the workflow throws during execution, the tool call fails with an `AGENT_WORKFLOW_TOOL_EXECUTION_FAILED` error. Give each workflow a `description` so the parent agent knows when to use it.
67
+
68
+ A delegation doesn't always finish in one call. When a workflow step suspends, the tool call suspends too, and the parent agent emits a `tool-call-suspended` chunk with the step's `suspendPayload`. Resuming the tool call resumes the same workflow run, not a new one. See [use `suspend()` in supervisor agents](https://mastra.ai/docs/agents/human-in-the-loop).
69
+
70
+ ```typescript
71
+ import { Agent } from '@mastra/core/agent'
72
+ import { researchWorkflow } from '../workflows/research-workflow'
73
+
74
+ // researchAgent and writingAgent are defined in this file, as in the Quickstart
75
+
76
+ const parentAgent = new Agent({
77
+ id: 'parent-agent',
78
+ instructions: 'You coordinate research and writing using specialized agents and workflows.',
79
+ model: 'openai/gpt-6.2-sol',
80
+ agents: { researchAgent, writingAgent },
81
+ workflows: { researchWorkflow }, // tool name: "workflow-researchWorkflow"
82
+ })
83
+ ```
84
+
85
+ The delegation hooks below run for subagents only. For more on workflow tools, see [Workflows as tools](https://mastra.ai/docs/agents/tools).
86
+
64
87
  ## Delegation hooks
65
88
 
66
89
  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.
@@ -438,7 +461,7 @@ import { createRubricScorer } from '@mastra/evals/scorers/prebuilt'
438
461
  const parentAgent = new Agent({
439
462
  id: 'parent-agent',
440
463
  instructions: 'You coordinate research and writing using specialized agents.',
441
- model: 'openai/gpt-6.1-sol',
464
+ model: 'openai/gpt-6.2-sol',
442
465
  agents: { researchAgent, writingAgent },
443
466
  })
444
467
 
@@ -504,7 +527,7 @@ import { Agent } from '@mastra/core/agent'
504
527
  const parentAgent = new Agent({
505
528
  id: 'parent-agent',
506
529
  instructions: 'Coordinate research and writing using the available agents.',
507
- model: 'openai/gpt-6.1-sol',
530
+ model: 'openai/gpt-6.2-sol',
508
531
  agents: { researchAgent, writingAgent },
509
532
  backgroundTasks: {
510
533
  tools: {
@@ -105,7 +105,7 @@ export const devAgent = new Agent({
105
105
  id: 'dev-agent',
106
106
  name: 'Development Agent',
107
107
  instructions: 'Triage pull request activity and help resolve issues.',
108
- model: 'openai/gpt-6.1-sol',
108
+ model: 'openai/gpt-6.2-sol',
109
109
  memory: new Memory(),
110
110
  signals: [githubSignals],
111
111
  })
@@ -70,7 +70,7 @@ export const homeAgent = new Agent({
70
70
  id: 'home-agent',
71
71
  name: 'Home Agent',
72
72
  instructions: 'Watch the front door and say briefly whether each event needs attention.',
73
- model: 'openai/gpt-6.1-sol',
73
+ model: 'openai/gpt-6.2-sol',
74
74
  memory: new Memory(),
75
75
  signals: [new RingSignals()],
76
76
  })
@@ -283,7 +283,7 @@ export const homeAgent = new Agent({
283
283
  id: 'home-agent',
284
284
  name: 'Home Agent',
285
285
  instructions: 'Watch the front door and say briefly whether each event needs attention.',
286
- model: 'openai/gpt-6.1-sol',
286
+ model: 'openai/gpt-6.2-sol',
287
287
  memory: new Memory(),
288
288
  channels: {
289
289
  resolveResourceId: ({ thread, message, defaultResourceId }) =>
@@ -245,7 +245,7 @@ export const dsqlAgent = new Agent({
245
245
  name: 'DSQL Agent',
246
246
  instructions:
247
247
  'You are an AI agent with the ability to automatically recall memories from previous interactions.',
248
- model: 'openai/gpt-6.1-sol',
248
+ model: 'openai/gpt-6.2-sol',
249
249
  memory: new Memory({
250
250
  storage: new DSQLStore({
251
251
  id: 'dsql-agent-storage',
@@ -110,7 +110,7 @@ export const elasticsearchAgent = new Agent({
110
110
  name: 'Elasticsearch Agent',
111
111
  instructions:
112
112
  'You are an AI agent with the ability to automatically recall memories from previous interactions.',
113
- model: 'openai/gpt-6.1-sol',
113
+ model: 'openai/gpt-6.2-sol',
114
114
  memory: new Memory({
115
115
  storage: new ElasticSearchStore({
116
116
  id: 'elasticsearch-agent-storage',
@@ -119,6 +119,12 @@ The storage implementation creates the core storage tables automatically, includ
119
119
 
120
120
  `LibSQLStore` exposes notification storage through `getStore('notifications')`.
121
121
 
122
+ ### Pending signals
123
+
124
+ The memory domain keeps the [pending signals](https://mastra.ai/docs/server/pubsub) of evented agents as rows of `mastra_messages` under the reserved thread ID `mastra-queue:pending:<threadId>`, and under `mastra-queue:taken:<threadId>` once a run takes them, without a resource ID. When the run saves its messages, the row moves to its thread and becomes a normal message. Message reads by thread or resource, `updateMessages`, `deleteMessages`, and thread cloning never act on a queued signal, and deleting a thread deletes its queued signals with its messages. Thread IDs that start with `mastra-queue:` are reserved: saving such a thread, cloning to it, or saving or listing its messages fails. Processes share pending signals when the store opens a file or a remote database. An in-memory database (`:memory:`), an embedded replica (`syncUrl`), and a local `client` you pass in keep them to one process. A `file:` URL is shared only by processes on the same machine.
125
+
126
+ `init()` adds one nullable column for pending signals, `signalRunId` on `mastra_threads`. Existing messages and threads are unchanged. A store created with `disableInit: true` reads and saves messages before its migration, because those methods don't use the new column, but it needs `init()` or your own migration run against the database before it sends or claims pending signals.
127
+
122
128
  ## Initialization
123
129
 
124
130
  When you pass storage to the Mastra class, `init()` is called automatically to create the [core schema](https://mastra.ai/reference/storage/overview):
@@ -212,7 +212,7 @@ export const mongodbAgent = new Agent({
212
212
  name: 'mongodb-agent',
213
213
  instructions:
214
214
  'You are an AI agent with the ability to automatically recall memories from previous interactions.',
215
- model: 'openai/gpt-6.1-sol',
215
+ model: 'openai/gpt-6.2-sol',
216
216
  memory: new Memory({
217
217
  storage: new MongoDBStore({
218
218
  id: 'mongodb-storage',
@@ -228,7 +228,7 @@ export const oracleAgent = new Agent({
228
228
  id: 'oracle-agent',
229
229
  name: 'Oracle Agent',
230
230
  instructions: 'You are an assistant with persistent OracleDB-backed memory.',
231
- model: 'openai/gpt-6.1-sol',
231
+ model: 'openai/gpt-6.2-sol',
232
232
  memory: new Memory({ storage }),
233
233
  })
234
234
  ```
@@ -140,6 +140,14 @@ The storage implementation handles schema creation and updates automatically. It
140
140
 
141
141
  `PostgresStore` exposes notification storage through `getStore('notifications')`.
142
142
 
143
+ ### Pending signals
144
+
145
+ The memory domain keeps the [pending signals](https://mastra.ai/docs/server/pubsub) of evented agents as rows of the messages table under the reserved thread ID `mastra-queue:pending:<threadId>`, and under `mastra-queue:taken:<threadId>` once a run takes them, without a resource ID, and every process that shares the database sees them. When the run saves its messages, the row moves to its thread and becomes a normal message. Message reads by thread or resource, `updateMessages`, `deleteMessages`, and thread cloning never act on a queued signal, and deleting a thread deletes its queued signals with its messages. Thread IDs that start with `mastra-queue:` are reserved: saving such a thread, cloning to it, or saving or listing its messages fails.
146
+
147
+ `init()` adds one nullable column, `signalRunId`, to the threads table. `exportSchemas()` includes it. Message reads and saves don't use this column. If you set `disableInit`, run `init()` once or apply the same column with your own migration, as in [separate schema initialization](#separate-schema-initialization), before the store sends or claims pending signals.
148
+
149
+ `saveMessages`, `updateMessages`, `deleteMessages`, `deleteThread`, and `updateThreadResourceId` run at READ COMMITTED, whatever `default_transaction_isolation` is set to. They lock the thread rows they touch for the whole transaction, so concurrent writes to one thread run one after another. [`prune()`](https://mastra.ai/reference/storage/retention) takes no thread lock and can deadlock with the end of a run whose signals are in the rows it deletes. Postgres then cancels one of the two transactions. When `prune()` is the one cancelled, it rejects with the deadlock error, and you can call it again. When the end of the run is cancelled, Mastra logs the warning `Could not close the stored signals of an ended run`.
150
+
143
151
  ### Observability
144
152
 
145
153
  PostgreSQL supports observability and can handle low trace volumes. Throughput capacity depends on deployment factors such as hardware, schema design, indexing, and retention policies, and should be validated for your specific environment. For high-volume production environments, consider:
@@ -442,7 +450,7 @@ export const pgAgent = new Agent({
442
450
  name: 'PG Agent',
443
451
  instructions:
444
452
  'You are an AI agent with the ability to automatically recall memories from previous interactions.',
445
- model: 'openai/gpt-6.1-sol',
453
+ model: 'openai/gpt-6.2-sol',
446
454
  memory: new Memory({
447
455
  storage: new PostgresStore({
448
456
  id: 'pg-agent-storage',
@@ -165,7 +165,7 @@ export const redisAgent = new Agent({
165
165
  name: 'Redis Agent',
166
166
  instructions:
167
167
  'You are an AI agent with the ability to automatically recall memories from previous interactions.',
168
- model: 'openai/gpt-6.1-sol',
168
+ model: 'openai/gpt-6.2-sol',
169
169
  memory: new Memory({
170
170
  storage: new RedisStore({
171
171
  id: 'redis-agent-storage',
@@ -107,7 +107,7 @@ export const upstashAgent = new Agent({
107
107
  name: 'Upstash Agent',
108
108
  instructions:
109
109
  'You are an AI agent with the ability to automatically recall memories from previous interactions.',
110
- model: 'openai/gpt-6.1-sol',
110
+ model: 'openai/gpt-6.2-sol',
111
111
  memory: new Memory({
112
112
  storage: new UpstashStore({
113
113
  id: 'upstash-agent-storage',
@@ -16,7 +16,7 @@ export const agent = new Agent({
16
16
  id: 'test-agent',
17
17
  name: 'test-agent',
18
18
  instructions: 'You are an agent with memory.',
19
- model: 'openai/gpt-6.1-sol',
19
+ model: 'openai/gpt-6.2-sol',
20
20
  memory: new Memory({
21
21
  options: {
22
22
  workingMemory: {
@@ -148,7 +148,7 @@ import { LibSQLStore, LibSQLVector } from '@mastra/libsql'
148
148
  export const agent = new Agent({
149
149
  name: 'test-agent',
150
150
  instructions: 'You are an agent with memory.',
151
- model: 'openai/gpt-6.1-sol',
151
+ model: 'openai/gpt-6.2-sol',
152
152
  memory: new Memory({
153
153
  storage: new LibSQLStore({
154
154
  id: 'test-agent-storage',
@@ -185,7 +185,7 @@ import { PostgresStore, PgVector } from '@mastra/pg'
185
185
  export const agent = new Agent({
186
186
  name: 'pg-agent',
187
187
  instructions: 'You are an agent with optimized PostgreSQL memory.',
188
- model: 'openai/gpt-6.1-sol',
188
+ model: 'openai/gpt-6.2-sol',
189
189
  memory: new Memory({
190
190
  storage: new PostgresStore({
191
191
  id: 'pg-agent-storage',
@@ -35,8 +35,12 @@ Observer input is multimodal-aware. OM keeps text placeholders like `[Image #1:
35
35
 
36
36
  OM performs thresholding with fast local token estimation. Text uses `tokenx`, and image-like inputs use provider-aware heuristics plus deterministic fallbacks when metadata is incomplete.
37
37
 
38
+ By default, live date hints follow the observation block rather than changing its absolute-date prefix. The complete hint suffix is limited to 8,000 characters and 64 date cues, including its tags, current-day explanation, and any omission notice. Set `observationalMemory: { liveDateHints: false }` to omit the suffix. Unchanged observations then produce the same OM context across days. Other context sections or messages can still change.
39
+
38
40
  **enabled** (`boolean`): Enable or disable Observational Memory. When omitted from a config object, defaults to true. Only enabled: false explicitly disables it. (Default: `true`)
39
41
 
42
+ **liveDateHints** (`boolean`): Append current-day and relative-date cues after the observations, using their recorded time zone. Set to false to keep date hints out of the Actor context. Absolute dates and static date gaps remain unchanged. (Default: `true`)
43
+
40
44
  **model** (`'auto' | string | LanguageModel | DynamicModel | ModelByInputTokens | ModelWithRetries[]`): Model for both the Observer and Reflector agents. Cannot be used together with observation.model or reflection.model. When all model fields are omitted, each role defaults to "auto". Automatic selection prefers google/gemini-2.5-flash when GOOGLE_GENERATIVE_AI_API_KEY is configured, then a low-cost model for the active provider, then the active main model. Use "default" for the legacy fixed default. (Default: `'auto'`)
41
45
 
42
46
  **autoModels** (`Record<string, string>`): Overrides the model automatic selection picks for a provider, keyed by provider ID. For example, { openai: "\_\_GATEWAY_OPENAI_MODEL_LUNA\_\_" }. Providers not listed use the built-in pick.
@@ -210,7 +214,7 @@ export const agent = new Agent({
210
214
  id: 'health-assistant',
211
215
  name: 'health-assistant',
212
216
  instructions: 'You are a health and wellness assistant.',
213
- model: 'openai/gpt-6.1-sol',
217
+ model: 'openai/gpt-6.2-sol',
214
218
  memory: new Memory({
215
219
  options: {
216
220
  observationalMemory: {
@@ -246,7 +250,7 @@ export const agent = new Agent({
246
250
  id: 'my-agent',
247
251
  name: 'my-agent',
248
252
  instructions: 'You are a helpful assistant.',
249
- model: 'openai/gpt-6.1-sol',
253
+ model: 'openai/gpt-6.2-sol',
250
254
  memory: new Memory({
251
255
  options: {
252
256
  observationalMemory: {
@@ -1117,7 +1121,7 @@ const selector = new ModelByInputTokens({
1117
1121
  upTo: {
1118
1122
  10_000: 'google/gemini-2.5-flash', // Fast for small inputs
1119
1123
  40_000: 'openai/gpt-6-luna', // Stronger for medium inputs
1120
- 1_000_000: 'openai/gpt-6.1-sol', // Most capable for large inputs
1124
+ 1_000_000: 'openai/gpt-6.2-sol', // Most capable for large inputs
1121
1125
  },
1122
1126
  })
1123
1127
  ```
@@ -107,7 +107,7 @@ export const agent = new Agent({
107
107
  id: 'context-limited-agent',
108
108
  name: 'context-limited-agent',
109
109
  instructions: 'You are a helpful assistant',
110
- model: 'openai/gpt-6.1-sol',
110
+ model: 'openai/gpt-6.2-sol',
111
111
  memory: new Memory({/* ... */}),
112
112
  inputProcessors: [
113
113
  new TokenLimiterProcessor({ limit: 4000 }), // Limits historical messages to ~4000 tokens
@@ -127,7 +127,7 @@ export const agent = new Agent({
127
127
  id: 'multi-step-agent',
128
128
  name: 'multi-step-agent',
129
129
  instructions: 'You are a helpful research assistant with access to tools',
130
- model: 'openai/gpt-6.1-sol',
130
+ model: 'openai/gpt-6.2-sol',
131
131
  inputProcessors: [
132
132
  new TokenLimiterProcessor({ limit: 8000 }), // Applied at every step
133
133
  ],
@@ -153,7 +153,7 @@ export const agent = new Agent({
153
153
  id: 'response-limited-agent',
154
154
  name: 'response-limited-agent',
155
155
  instructions: 'You are a helpful assistant',
156
- model: 'openai/gpt-6.1-sol',
156
+ model: 'openai/gpt-6.2-sol',
157
157
  outputProcessors: [
158
158
  new TokenLimiterProcessor({
159
159
  limit: 1000,
package/dist/index.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_src = require("./src-D2dL-xVG.cjs");
2
+ const require_src = require("./src-DaOrkH_R.cjs");
3
3
  let _mastra_core_processors = require("@mastra/core/processors");
4
4
  let _mastra_core_memory = require("@mastra/core/memory");
5
5
  exports.AUTO_MODEL_BY_PROVIDER = require_src.AUTO_MODEL_BY_PROVIDER;
package/dist/index.d.ts CHANGED
@@ -29,6 +29,8 @@ export type { SummarizeConversationOptions, SummarizeConversationResult, Summari
29
29
  * Inlined here to avoid importing runtime exports that don't exist on older @mastra/core versions.
30
30
  */
31
31
  type MemoryObservationalMemoryOptions = Omit<ObservationalMemoryOptions, 'model' | 'observation' | 'reflection'> & {
32
+ /** Append live relative-date cues after observations. Defaults to true. */
33
+ liveDateHints?: ObservationalMemoryConfig['liveDateHints'];
32
34
  model?: ObservationalMemoryConfig['model'];
33
35
  observation?: ObservationalMemoryConfig['observation'];
34
36
  reflection?: ObservationalMemoryConfig['reflection'];
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- export { m as AUTO_MODEL_BY_PROVIDER, K as Extractor, D as KnowledgeSemanticIndexCoordinator, t as Memory, n as MessageHistory, y as ModelByInputTokens, M as SUMMARIZE_THREAD_DEFAULTS, r as SemanticRecall, O as StaleKnowledgeSemanticIndexError, k as Subconscious, g as WORKING_MEMORY_STATE_ID, _ as WORKING_MEMORY_STATE_PROCESSOR_ID, i as WorkingMemory, A as WorkingMemoryExtractor, v as WorkingMemoryStateProcessor, a as asUserTurn, j as deepMergeWorkingMemory, o as escapeTurnMarkup, s as extractWorkingMemoryContent, c as extractWorkingMemoryTags, d as getObservationsAsOf, l as removeWorkingMemoryTags, h as resolveAutoModelId, u as sealTurnMarkup, N as summarizeConversation } from "./src-Bv05c6Nj.js";
1
+ export { m as AUTO_MODEL_BY_PROVIDER, K as Extractor, D as KnowledgeSemanticIndexCoordinator, t as Memory, n as MessageHistory, y as ModelByInputTokens, M as SUMMARIZE_THREAD_DEFAULTS, r as SemanticRecall, O as StaleKnowledgeSemanticIndexError, k as Subconscious, g as WORKING_MEMORY_STATE_ID, _ as WORKING_MEMORY_STATE_PROCESSOR_ID, i as WorkingMemory, A as WorkingMemoryExtractor, v as WorkingMemoryStateProcessor, a as asUserTurn, j as deepMergeWorkingMemory, o as escapeTurnMarkup, s as extractWorkingMemoryContent, c as extractWorkingMemoryTags, d as getObservationsAsOf, l as removeWorkingMemoryTags, h as resolveAutoModelId, u as sealTurnMarkup, N as summarizeConversation } from "./src-CVekC2V9.js";
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_src = require("../src-D2dL-xVG.cjs");
2
+ const require_src = require("../src-DaOrkH_R.cjs");
3
3
  exports.AUTO_MODEL_BY_PROVIDER = require_src.AUTO_MODEL_BY_PROVIDER;
4
4
  exports.Extractor = require_src.Extractor;
5
5
  exports.ModelByInputTokens = require_src.ModelByInputTokens;
@@ -1 +1 @@
1
- export { m as AUTO_MODEL_BY_PROVIDER, K as Extractor, y as ModelByInputTokens, q as OBSERVATIONAL_MEMORY_DEFAULTS, J as OBSERVATION_CONTEXT_INSTRUCTIONS, Y as OBSERVATION_CONTEXT_PROMPT, X as OBSERVATION_CONTEXT_PROMPT_THREAD, Z as OBSERVATION_CONTINUATION_HINT, F as OBSERVER_SYSTEM_PROMPT, p as ObservationalMemory, f as ObservationalMemoryProcessor, P as TokenCounter, A as WorkingMemoryExtractor, I as buildObserverPrompt, L as buildObserverSystemPrompt, b as combineObservationGroupRanges, x as deriveObservationGroupProvenance, R as extractCurrentTask, z as formatMessagesForObserver, Q as getObservationContextPrompt, d as getObservationsAsOf, B as hasCurrentTaskSection, U as injectAnchorIds, V as optimizeObservationsForContext, W as parseAnchorId, S as parseObservationGroups, H as parseObserverOutput, C as reconcileObservationGroupsFromReflection, w as renderObservationGroupsForReflection, h as resolveAutoModelId, G as stripEphemeralAnchorIds, T as stripObservationGroups, N as summarizeConversation, E as wrapInObservationGroup } from "../src-Bv05c6Nj.js";
1
+ export { m as AUTO_MODEL_BY_PROVIDER, K as Extractor, y as ModelByInputTokens, q as OBSERVATIONAL_MEMORY_DEFAULTS, J as OBSERVATION_CONTEXT_INSTRUCTIONS, Y as OBSERVATION_CONTEXT_PROMPT, X as OBSERVATION_CONTEXT_PROMPT_THREAD, Z as OBSERVATION_CONTINUATION_HINT, F as OBSERVER_SYSTEM_PROMPT, p as ObservationalMemory, f as ObservationalMemoryProcessor, P as TokenCounter, A as WorkingMemoryExtractor, I as buildObserverPrompt, L as buildObserverSystemPrompt, b as combineObservationGroupRanges, x as deriveObservationGroupProvenance, R as extractCurrentTask, z as formatMessagesForObserver, Q as getObservationContextPrompt, d as getObservationsAsOf, B as hasCurrentTaskSection, U as injectAnchorIds, V as optimizeObservationsForContext, W as parseAnchorId, S as parseObservationGroups, H as parseObserverOutput, C as reconcileObservationGroupsFromReflection, w as renderObservationGroupsForReflection, h as resolveAutoModelId, G as stripEphemeralAnchorIds, T as stripObservationGroups, N as summarizeConversation, E as wrapInObservationGroup } from "../src-CVekC2V9.js";
@@ -0,0 +1,21 @@
1
+ import type { ProcessLLMRequestArgs } from '@mastra/core/processors';
2
+ type Prompt = ProcessLLMRequestArgs['prompt'];
3
+ /**
4
+ * Hints where the stable part of memory's context ends: the last observation chunk.
5
+ *
6
+ * Memory renders each observation chunk as its own closed `<observations>` block, newest last, and puts what
7
+ * changes more often (date hints, the current task, the suggested response) after them. An update that only adds
8
+ * chunks leaves every earlier message unchanged, so a prompt cache that ends on the last chunk stays valid.
9
+ *
10
+ * The hint is `providerOptions.mastra.cacheBoundary: true`, set on the prompt of one model call only, so it is never
11
+ * stored. Provider adapters never forward `providerOptions.mastra`; a model adapter that supports prompt caching can
12
+ * turn it into a real cache mark within its own limits.
13
+ *
14
+ * Chat Completions endpoints (`*.chat`) get no hint: core merges their leading system messages into one and skips the
15
+ * merge when an earlier message carries `providerOptions`. Only a chunk memory rendered itself is hinted: `rendered` is the
16
+ * text of the system messages memory tagged in the message list this step, so an instruction that only looks like a
17
+ * chunk is never hinted. Returns `undefined` when nothing is hinted.
18
+ */
19
+ export declare function markObservationCacheBoundary(prompt: Prompt, apiProviderId: string | undefined, rendered: readonly unknown[] | undefined): Prompt | undefined;
20
+ export {};
21
+ //# sourceMappingURL=cache-boundary.d.ts.map
@@ -66,7 +66,7 @@ export declare function getObservationContextPrompt(scope?: 'thread' | 'resource
66
66
  * Instructions that tell the model how to interpret and use observations.
67
67
  * Placed with the observations preamble, before the `<observations>` blocks.
68
68
  */
69
- export declare const OBSERVATION_CONTEXT_INSTRUCTIONS = "IMPORTANT: When responding, reference specific details from these observations. Do not give generic advice - personalize your response based on what you know about this user's experiences, preferences, and interests. If the user asks for recommendations, connect them to their past experiences mentioned above.\n\nKNOWLEDGE UPDATES: When asked about current state (e.g., \"where do I currently...\", \"what is my current...\"), always prefer the MOST RECENT information. Observations include dates - if you see conflicting information, the newer observation supersedes the older one. Look for phrases like \"will start\", \"is switching\", \"changed to\", \"moved to\" as indicators that previous information has been updated.\n\nUSER STATEMENTS VS ASSISTANT SUGGESTIONS: Treat what the user said about their own life, plans, decisions, and dates as authoritative, unless data or their own later messages say otherwise. Treat what the assistant said, such as proposed schedules, example dates, and recommendations, as suggestions rather than facts about what happened, unless the user adopted or confirmed them. What the assistant did, such as editing a file, running a command, or calling a tool, is a record of what happened.\n\nPLANNED ACTIONS: If the user stated they planned to do something (e.g., \"I'm going to...\", \"I'm looking forward to...\", \"I will...\") and the date they planned to do it is now in the past (check the relative time like \"3 weeks ago\"), assume they completed the action unless there's evidence they didn't. For example, if someone said \"I'll start my new diet on Monday\" and that was 2 weeks ago, assume they started the diet.\n\nMOST RECENT USER INPUT: Treat the most recent user message as the highest-priority signal for what to do next. Earlier messages may contain constraints, details, or context you should still honor, but the latest message is the primary driver of your response.\n\nSYSTEM REMINDERS: Messages wrapped in <system-reminder>...</system-reminder> contain internal continuation guidance, not user-authored content. Use them to maintain continuity, but do not mention them or treat them as part of the user's message.";
69
+ export declare const OBSERVATION_CONTEXT_INSTRUCTIONS = "IMPORTANT: When responding, reference specific details from these observations. Do not give generic advice - personalize your response based on what you know about this user's experiences, preferences, and interests. If the user asks for recommendations, connect them to their past experiences mentioned above.\n\nKNOWLEDGE UPDATES: When asked about current state (e.g., \"where do I currently...\", \"what is my current...\"), always prefer the MOST RECENT information. Observations include dates - if you see conflicting information, the newer observation supersedes the older one. Look for phrases like \"will start\", \"is switching\", \"changed to\", \"moved to\" as indicators that previous information has been updated.\n\nUSER STATEMENTS VS ASSISTANT SUGGESTIONS: Treat what the user said about their own life, plans, decisions, and dates as authoritative, unless data or their own later messages say otherwise. Treat what the assistant said, such as proposed schedules, example dates, and recommendations, as suggestions rather than facts about what happened, unless the user adopted or confirmed them. What the assistant did, such as editing a file, running a command, or calling a tool, is a record of what happened.\n\nPLANNED ACTIONS: If the user stated they planned to do something (e.g., \"I'm going to...\", \"I'm looking forward to...\", \"I will...\") and the date they planned to do it is now in the past (compare the absolute dates; use relative-time hints when available), assume they completed the action unless there's evidence they didn't. For example, if someone said \"I'll start my new diet on Monday\" and that was 2 weeks ago, assume they started the diet.\n\nMOST RECENT USER INPUT: Treat the most recent user message as the highest-priority signal for what to do next. Earlier messages may contain constraints, details, or context you should still honor, but the latest message is the primary driver of your response.\n\nSYSTEM REMINDERS: Messages wrapped in <system-reminder>...</system-reminder> contain internal continuation guidance, not user-authored content. Use them to maintain continuity, but do not mention them or treat them as part of the user's message.";
70
70
  /**
71
71
  * Instructions for retrieval mode — explains observation-group ranges and the recall tool.
72
72
  * Appended to context when `retrieval` is enabled.
@@ -61,6 +61,10 @@ export declare function annotateObservationTextDates(observations: string, curre
61
61
  * `currentDate`'s calendar date in that zone, so the result doesn't depend on the zone of the process rendering it.
62
62
  */
63
63
  export declare function addRelativeTimeToObservations(observations: string, currentDate: Date, timeZone?: string): string;
64
+ /** Preserve only clock-independent gaps in the cacheable observation text. */
65
+ export declare function addObservationDateGaps(observations: string): string;
66
+ /** Live cues are bounded and separate from the absolute observation prefix. */
67
+ export declare function buildObservationDateHints(observations: string, currentDate: Date, timeZone?: string): string | undefined;
64
68
  export declare const MIN_TEMPORAL_GAP_MS: number;
65
69
  export declare function formatTemporalGap(diffMs: number): string | null;
66
70
  export declare function formatTemporalTimestamp(date: Date): string;
@@ -74,6 +74,7 @@ import type { ObservationDebugEvent, ObservationalMemoryConfig, ObserveHookConte
74
74
  export declare class ObservationalMemory {
75
75
  private storage;
76
76
  private tokenCounter;
77
+ private readonly liveDateHints;
77
78
  readonly scope: 'resource' | 'thread';
78
79
  /** Whether retrieval-mode observation groups are enabled. */
79
80
  readonly retrieval: boolean;
@@ -2,7 +2,7 @@ import type { MastraDBMessage, MessageList } from '@mastra/core/agent';
2
2
  import type { MemoryRunState } from '@mastra/core/memory';
3
3
  import type { MemoryOperationAttributes } from '@mastra/core/observability';
4
4
  import { SpanType } from '@mastra/core/observability';
5
- import type { Processor, ProcessAPIErrorArgs, ProcessAPIErrorResult, ProcessInputStepArgs, ProcessOutputResultArgs, ProcessorSpanPhase } from '@mastra/core/processors';
5
+ import type { Processor, ProcessAPIErrorArgs, ProcessAPIErrorResult, ProcessInputStepArgs, ProcessLLMRequestArgs, ProcessLLMRequestResult, ProcessOutputResultArgs, ProcessorSpanPhase } from '@mastra/core/processors';
6
6
  import type { ObservationalMemoryRecord } from '@mastra/core/storage';
7
7
  import type { ObservationalMemory } from './observational-memory.js';
8
8
  /** Subset of Memory that the processor needs — avoids circular imports. */
@@ -56,6 +56,8 @@ export declare class ObservationalMemoryProcessor implements Processor<'observat
56
56
  */
57
57
  private endActiveTurn;
58
58
  processInputStep(args: ProcessInputStepArgs): Promise<MessageList | MastraDBMessage[]>;
59
+ /** Hints memory's cache boundary on this model call's prompt only, so the hint is never stored. */
60
+ processLLMRequest({ prompt, model, apiProviderId, messageList }: ProcessLLMRequestArgs): ProcessLLMRequestResult;
59
61
  processOutputResult(args: ProcessOutputResultArgs): Promise<MessageList | MastraDBMessage[]>;
60
62
  processAPIError(args: ProcessAPIErrorArgs): Promise<ProcessAPIErrorResult | void>;
61
63
  get config(): {
@@ -22,6 +22,8 @@ export declare function calculateDynamicThreshold(threshold: number | ThresholdR
22
22
  * Resolve bufferTokens config value.
23
23
  * Values in (0, 1) are treated as ratios of the message threshold.
24
24
  * e.g. bufferTokens: 0.25 with messageTokens: 20_000 → 5_000
25
+ * Ratios resolve to at least 1 and below the threshold, so tiny thresholds
26
+ * (e.g. messageTokens: 2) don't round to 0 or up to the threshold itself.
25
27
  */
26
28
  export declare function resolveBufferTokens(bufferTokens: number | false | undefined, messageTokens: number | ThresholdRange): number | undefined;
27
29
  /**
@@ -864,6 +864,11 @@ export interface ObservationalMemoryConfig {
864
864
  storage: MemoryStorage;
865
865
  /** Active Memory instance, when Observational Memory is created by Memory. */
866
866
  memory?: Memory;
867
+ /**
868
+ * Append live relative-date cues after observations. Set false to omit the cues.
869
+ * @default true
870
+ */
871
+ liveDateHints?: boolean;
867
872
  /**
868
873
  * Enable retrieval-mode observation group metadata.
869
874
  * When true, observation groups are treated as durable pointers to raw