@mastra/memory 1.41.0-alpha.1 → 1.41.0-alpha.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.
@@ -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.41.0-alpha.1"
6
+ version: "1.41.0-alpha.2"
7
7
  ---
8
8
 
9
9
  ## When to use
@@ -1,209 +1,209 @@
1
1
  {
2
- "version": "1.41.0-alpha.1",
2
+ "version": "1.41.0-alpha.2",
3
3
  "package": "@mastra/memory",
4
4
  "exports": {
5
5
  "d": {
6
6
  "types": "dist/processors/index.d.ts",
7
- "implementation": "dist/src-CBYx0iwC.js"
7
+ "implementation": "dist/src-Det56QOD.js"
8
8
  },
9
9
  "U": {
10
10
  "types": "dist/processors/index.d.ts",
11
- "implementation": "dist/src-CBYx0iwC.js"
11
+ "implementation": "dist/src-Det56QOD.js"
12
12
  },
13
13
  "g": {
14
14
  "types": "dist/processors/index.d.ts",
15
- "implementation": "dist/src-CBYx0iwC.js"
15
+ "implementation": "dist/src-Det56QOD.js"
16
16
  },
17
17
  "W": {
18
18
  "types": "dist/processors/index.d.ts",
19
- "implementation": "dist/src-CBYx0iwC.js"
19
+ "implementation": "dist/src-Det56QOD.js"
20
20
  },
21
21
  "G": {
22
22
  "types": "dist/processors/index.d.ts",
23
- "implementation": "dist/src-CBYx0iwC.js"
23
+ "implementation": "dist/src-Det56QOD.js"
24
24
  },
25
25
  "K": {
26
26
  "types": "dist/processors/index.d.ts",
27
- "implementation": "dist/src-CBYx0iwC.js"
27
+ "implementation": "dist/src-Det56QOD.js"
28
28
  },
29
29
  "q": {
30
30
  "types": "dist/processors/index.d.ts",
31
- "implementation": "dist/src-CBYx0iwC.js"
31
+ "implementation": "dist/src-Det56QOD.js"
32
32
  },
33
33
  "J": {
34
34
  "types": "dist/processors/index.d.ts",
35
- "implementation": "dist/src-CBYx0iwC.js"
35
+ "implementation": "dist/src-Det56QOD.js"
36
36
  },
37
37
  "M": {
38
38
  "types": "dist/processors/index.d.ts",
39
- "implementation": "dist/src-CBYx0iwC.js"
39
+ "implementation": "dist/src-Det56QOD.js"
40
40
  },
41
41
  "u": {
42
42
  "types": "dist/processors/index.d.ts",
43
- "implementation": "dist/src-CBYx0iwC.js"
43
+ "implementation": "dist/src-Det56QOD.js"
44
44
  },
45
45
  "l": {
46
46
  "types": "dist/processors/index.d.ts",
47
- "implementation": "dist/src-CBYx0iwC.js"
47
+ "implementation": "dist/src-Det56QOD.js"
48
48
  },
49
49
  "j": {
50
50
  "types": "dist/processors/index.d.ts",
51
- "implementation": "dist/src-CBYx0iwC.js"
51
+ "implementation": "dist/src-Det56QOD.js"
52
52
  },
53
53
  "D": {
54
54
  "types": "dist/processors/index.d.ts",
55
- "implementation": "dist/src-CBYx0iwC.js"
55
+ "implementation": "dist/src-Det56QOD.js"
56
56
  },
57
57
  "N": {
58
58
  "types": "dist/processors/index.d.ts",
59
- "implementation": "dist/src-CBYx0iwC.js"
59
+ "implementation": "dist/src-Det56QOD.js"
60
60
  },
61
61
  "P": {
62
62
  "types": "dist/processors/index.d.ts",
63
- "implementation": "dist/src-CBYx0iwC.js"
63
+ "implementation": "dist/src-Det56QOD.js"
64
64
  },
65
65
  "_": {
66
66
  "types": "dist/processors/index.d.ts",
67
- "implementation": "dist/src-CBYx0iwC.js"
67
+ "implementation": "dist/src-Det56QOD.js"
68
68
  },
69
69
  "v": {
70
70
  "types": "dist/processors/index.d.ts",
71
- "implementation": "dist/src-CBYx0iwC.js"
71
+ "implementation": "dist/src-Det56QOD.js"
72
72
  },
73
73
  "F": {
74
74
  "types": "dist/processors/index.d.ts",
75
- "implementation": "dist/src-CBYx0iwC.js"
75
+ "implementation": "dist/src-Det56QOD.js"
76
76
  },
77
77
  "I": {
78
78
  "types": "dist/processors/index.d.ts",
79
- "implementation": "dist/src-CBYx0iwC.js"
79
+ "implementation": "dist/src-Det56QOD.js"
80
80
  },
81
81
  "Y": {
82
82
  "types": "dist/processors/index.d.ts",
83
- "implementation": "dist/src-CBYx0iwC.js"
83
+ "implementation": "dist/src-Det56QOD.js"
84
84
  },
85
85
  "c": {
86
86
  "types": "dist/processors/index.d.ts",
87
- "implementation": "dist/src-CBYx0iwC.js"
87
+ "implementation": "dist/src-Det56QOD.js"
88
88
  },
89
89
  "L": {
90
90
  "types": "dist/processors/index.d.ts",
91
- "implementation": "dist/src-CBYx0iwC.js"
91
+ "implementation": "dist/src-Det56QOD.js"
92
92
  },
93
93
  "B": {
94
94
  "types": "dist/processors/index.d.ts",
95
- "implementation": "dist/src-CBYx0iwC.js"
95
+ "implementation": "dist/src-Det56QOD.js"
96
96
  },
97
97
  "R": {
98
98
  "types": "dist/processors/index.d.ts",
99
- "implementation": "dist/src-CBYx0iwC.js"
99
+ "implementation": "dist/src-Det56QOD.js"
100
100
  },
101
101
  "V": {
102
102
  "types": "dist/processors/index.d.ts",
103
- "implementation": "dist/src-CBYx0iwC.js"
103
+ "implementation": "dist/src-Det56QOD.js"
104
104
  },
105
105
  "y": {
106
106
  "types": "dist/processors/index.d.ts",
107
- "implementation": "dist/src-CBYx0iwC.js"
107
+ "implementation": "dist/src-Det56QOD.js"
108
108
  },
109
109
  "z": {
110
110
  "types": "dist/processors/index.d.ts",
111
- "implementation": "dist/src-CBYx0iwC.js"
111
+ "implementation": "dist/src-Det56QOD.js"
112
112
  },
113
113
  "b": {
114
114
  "types": "dist/processors/index.d.ts",
115
- "implementation": "dist/src-CBYx0iwC.js"
115
+ "implementation": "dist/src-Det56QOD.js"
116
116
  },
117
117
  "x": {
118
118
  "types": "dist/processors/index.d.ts",
119
- "implementation": "dist/src-CBYx0iwC.js"
119
+ "implementation": "dist/src-Det56QOD.js"
120
120
  },
121
121
  "f": {
122
122
  "types": "dist/processors/index.d.ts",
123
- "implementation": "dist/src-CBYx0iwC.js"
123
+ "implementation": "dist/src-Det56QOD.js"
124
124
  },
125
125
  "H": {
126
126
  "types": "dist/processors/index.d.ts",
127
- "implementation": "dist/src-CBYx0iwC.js"
127
+ "implementation": "dist/src-Det56QOD.js"
128
128
  },
129
129
  "S": {
130
130
  "types": "dist/processors/index.d.ts",
131
- "implementation": "dist/src-CBYx0iwC.js"
131
+ "implementation": "dist/src-Det56QOD.js"
132
132
  },
133
133
  "A": {
134
134
  "types": "dist/processors/index.d.ts",
135
- "implementation": "dist/src-CBYx0iwC.js"
135
+ "implementation": "dist/src-Det56QOD.js"
136
136
  },
137
137
  "C": {
138
138
  "types": "dist/processors/index.d.ts",
139
- "implementation": "dist/src-CBYx0iwC.js"
139
+ "implementation": "dist/src-Det56QOD.js"
140
140
  },
141
141
  "w": {
142
142
  "types": "dist/index.d.ts",
143
- "implementation": "dist/src-CBYx0iwC.js"
143
+ "implementation": "dist/src-Det56QOD.js"
144
144
  },
145
145
  "t": {
146
146
  "types": "dist/index.d.ts",
147
- "implementation": "dist/src-CBYx0iwC.js"
147
+ "implementation": "dist/src-Det56QOD.js"
148
148
  },
149
149
  "n": {
150
150
  "types": "dist/index.d.ts",
151
- "implementation": "dist/src-CBYx0iwC.js"
151
+ "implementation": "dist/src-Det56QOD.js"
152
152
  },
153
153
  "k": {
154
154
  "types": "dist/index.d.ts",
155
- "implementation": "dist/src-CBYx0iwC.js"
155
+ "implementation": "dist/src-Det56QOD.js"
156
156
  },
157
157
  "r": {
158
158
  "types": "dist/index.d.ts",
159
- "implementation": "dist/src-CBYx0iwC.js"
159
+ "implementation": "dist/src-Det56QOD.js"
160
160
  },
161
161
  "T": {
162
162
  "types": "dist/index.d.ts",
163
- "implementation": "dist/src-CBYx0iwC.js"
163
+ "implementation": "dist/src-Det56QOD.js"
164
164
  },
165
165
  "E": {
166
166
  "types": "dist/index.d.ts",
167
- "implementation": "dist/src-CBYx0iwC.js"
167
+ "implementation": "dist/src-Det56QOD.js"
168
168
  },
169
169
  "p": {
170
170
  "types": "dist/index.d.ts",
171
- "implementation": "dist/src-CBYx0iwC.js"
171
+ "implementation": "dist/src-Det56QOD.js"
172
172
  },
173
173
  "m": {
174
174
  "types": "dist/index.d.ts",
175
- "implementation": "dist/src-CBYx0iwC.js"
175
+ "implementation": "dist/src-Det56QOD.js"
176
176
  },
177
177
  "i": {
178
178
  "types": "dist/index.d.ts",
179
- "implementation": "dist/src-CBYx0iwC.js"
179
+ "implementation": "dist/src-Det56QOD.js"
180
180
  },
181
181
  "h": {
182
182
  "types": "dist/index.d.ts",
183
- "implementation": "dist/src-CBYx0iwC.js"
183
+ "implementation": "dist/src-Det56QOD.js"
184
184
  },
185
185
  "O": {
186
186
  "types": "dist/index.d.ts",
187
- "implementation": "dist/src-CBYx0iwC.js"
187
+ "implementation": "dist/src-Det56QOD.js"
188
188
  },
189
189
  "a": {
190
190
  "types": "dist/index.d.ts",
191
- "implementation": "dist/src-CBYx0iwC.js"
191
+ "implementation": "dist/src-Det56QOD.js"
192
192
  },
193
193
  "o": {
194
194
  "types": "dist/index.d.ts",
195
- "implementation": "dist/src-CBYx0iwC.js"
195
+ "implementation": "dist/src-Det56QOD.js"
196
196
  },
197
197
  "s": {
198
198
  "types": "dist/index.d.ts",
199
- "implementation": "dist/src-CBYx0iwC.js"
199
+ "implementation": "dist/src-Det56QOD.js"
200
200
  }
201
201
  },
202
202
  "modules": {
203
203
  "processors": {
204
204
  "index": "dist/processors/index.js",
205
205
  "chunks": [
206
- "src-CBYx0iwC.js"
206
+ "src-Det56QOD.js"
207
207
  ]
208
208
  }
209
209
  }
@@ -6,7 +6,7 @@
6
6
 
7
7
  **Added in:** `@mastra/core@1.29.0`
8
8
 
9
- Background tasks let an agent dispatch a long-running tool call without blocking the agentic loop. The tool returns an immediate acknowledgement while the LLM continues responding. The task then runs to completion in the background. When it finishes, its result is written to memory and if you use `stream()` with the [`untilIdle`](https://mastra.ai/reference/streaming/agents/stream) option the agent is re-invoked automatically so the result is processed in the same call.
9
+ Background tasks let an agent dispatch a long-running tool call without blocking the agentic loop. The tool returns an immediate acknowledgement while the LLM continues responding. The task then runs to completion in the background. When it finishes, its result is written to memory and the agent runs a follow-up turn to report it. With the [`untilIdle`](https://mastra.ai/reference/streaming/agents/stream) option, that turn streams on the same call; otherwise the agent is notified on the thread, as described in [Report a result after the stream ends](#report-a-result-after-the-stream-ends).
10
10
 
11
11
  ## When to use background tasks
12
12
 
@@ -187,6 +187,50 @@ export const mastra = new Mastra({
187
187
  })
188
188
  ```
189
189
 
190
+ ### Report a result after the stream ends
191
+
192
+ When a deferred task finishes and no `untilIdle` stream is open for its thread, Mastra sends the agent a `notification` signal with the tag `background-task`. The signal names the tool call and task, and tells the agent the result is now on the tool call. It doesn't copy the result into the prompt. This covers a `stream()` call without `untilIdle`, a client that disconnected, and a task resumed after it [suspended](#suspending-and-resuming).
193
+
194
+ - If the thread is idle, the signal wakes the agent, which runs a turn on the thread to report the outcome.
195
+ - If a run is already active on the thread, including the run that dispatched the task, the signal is delivered to that run's next model request. If that run ends without making another request, the signal runs as its own turn.
196
+ - If an `untilIdle` stream is open for the thread, no signal is sent, because that stream runs its own follow-up turn.
197
+ - If the caller cancelled or aborted the `untilIdle` stream that was waiting for the task, no signal is sent either: stopping the stream means the caller doesn't want a reply for that work. A task that suspended and is answered later isn't covered by this, because the stream stopped waiting for it when it suspended.
198
+
199
+ A run that a signal starts on an idle thread, such as a message sent with `agent.sendSignal()`, stays open until the tasks it dispatched finish, and reports them itself. To end woken runs after their own turn instead, set the temporary `wokenRunsEndAfterTurn` option. Their tasks then report back with this signal when they finish:
200
+
201
+ ```typescript
202
+ import { Mastra } from '@mastra/core'
203
+
204
+ export const mastra = new Mastra({
205
+ backgroundTasks: {
206
+ enabled: true,
207
+ wokenRunsEndAfterTurn: true,
208
+ },
209
+ })
210
+ ```
211
+
212
+ A signal's own `ifIdle.streamOptions.untilIdle` takes precedence over the option in both directions. In the next major release, ending after the turn becomes the only behavior and `wokenRunsEndAfterTurn` is removed. To keep a woken run open after that, pass `untilIdle: true` in `ifIdle.streamOptions`. Agent controller sessions and channels already pass it.
213
+
214
+ If you combine `wokenRunsEndAfterTurn` with `notifyAgentOnFinish: false`, nothing reports the tasks of a woken run, so your app has to send the completion itself.
215
+
216
+ If your app sends its own completion signal, for example from `onTaskComplete`, set `notifyAgentOnFinish: false` on the Mastra `backgroundTasks` config so the agent isn't told twice:
217
+
218
+ ```typescript
219
+ import { Mastra } from '@mastra/core'
220
+
221
+ export const mastra = new Mastra({
222
+ backgroundTasks: {
223
+ enabled: true,
224
+ notifyAgentOnFinish: false,
225
+ onTaskComplete: async task => {
226
+ // Send your own notification to task.threadId
227
+ },
228
+ },
229
+ })
230
+ ```
231
+
232
+ The signal needs memory with a thread and resource. A task dispatched without them only writes its result to the task record. Awaited tasks don't send the signal, because the run that dispatched them waits for the result.
233
+
190
234
  ### Aggregate properties
191
235
 
192
236
  `stream()` with `untilIdle` returns a `MastraModelOutput` that looks like the one from a regular `stream()` call, but `fullStream` alone spans the initial turn and any auto-continuations. Aggregate properties (`text`, `toolCalls`, `toolResults`, `finishReason`, `messageList`, `getFullOutput()`) still resolve against the **first turn's** internal buffer. If you need an aggregate view across continuations, consume `fullStream` yourself and accumulate.
@@ -292,6 +336,31 @@ await mastra.backgroundTaskManager?.resume(taskId, {
292
336
  })
293
337
  ```
294
338
 
339
+ On the resumed run, `context.agent.suspendPayload` holds the `data` the tool suspended with. Use it to tell which request an answer belongs to without encoding that in `resumeData`.
340
+
341
+ ### Answer a suspended task from a client
342
+
343
+ While an agent's background tool call is suspended, the assistant message that holds the call records the open request under `metadata.suspendedTools[toolCallId]`. The entry carries `toolName`, `args`, `suspendPayload`, `taskId`, `runId`, and `suspendedAt`, so a chat that reloads the thread can still show the request. The entry is removed when the task resumes or is cancelled.
344
+
345
+ The entry is written by the process that dispatched the tool call, the same process that writes the task's result into the thread. A task that a worker picks up after a restart has no such process, so neither the open request nor the result reaches the thread.
346
+
347
+ To answer the request over HTTP, call `POST /api/background-tasks/:backgroundTaskId/resume` with the answer in `resumeData`. The [client SDK](https://mastra.ai/reference/client-js/mastra-client) wraps the route as `resumeBackgroundTask()`:
348
+
349
+ ```typescript
350
+ import { MastraClient } from '@mastra/client-js'
351
+
352
+ const client = new MastraClient({ baseUrl: 'http://localhost:4111' })
353
+
354
+ const task = await client.getBackgroundTask(taskId)
355
+ await client.resumeBackgroundTask(
356
+ taskId,
357
+ { reviewer: 'alice@example.com' },
358
+ { suspendedAt: task.suspendedAt },
359
+ )
360
+ ```
361
+
362
+ Pass the `suspendedAt` you read from the task or the `suspendedTools` entry. When the task has resumed or suspended again since, the server returns `409 Conflict` instead of delivering a stale answer. The route also returns `409` when the task isn't suspended or no concurrency slot is free, and `404` when the task doesn't exist or belongs to another resource. Calling it requires the `background-tasks:execute` permission.
363
+
295
364
  ### Resume when no slot is free
296
365
 
297
366
  By default, `resume()` throws `Concurrency limit reached` when every concurrency slot is in use. Pass `{ onNoSlot: 'queue' }` to queue the resume instead:
@@ -307,7 +376,7 @@ The queue lives in the memory of the process that called `resume()`. If that pro
307
376
 
308
377
  ### What happens to the agent loop
309
378
 
310
- When a task suspends mid-`stream()` with `untilIdle`, the wrapper treats it as terminal for the current iteration and closes. Once the resume payload is available, call `agent.resumeStream(resumeData, { runId, toolCallId, memory, untilIdle: true })` to continue immediately. The resumed background task completes and adds its result to the message list before the agent runs a follow-up turn on the same SSE connection. To drive the resume out of band, call `mastra.backgroundTaskManager.resume(taskId, resumeData)` directly. Its result is still written into the thread for the next user turn.
379
+ When a task suspends mid-`stream()` with `untilIdle`, the wrapper treats it as terminal for the current iteration and closes. Once the resume payload is available, call `agent.resumeStream(resumeData, { runId, toolCallId, memory, untilIdle: true })` to continue immediately. The resumed background task completes and adds its result to the message list before the agent runs a follow-up turn on the same SSE connection. To drive the resume out of band, call `mastra.backgroundTaskManager.resume(taskId, resumeData)` directly, or use the [resume route](#answer-a-suspended-task-from-a-client). When the task finishes, its result is written into the thread and the agent [wakes to report it](#report-a-result-after-the-stream-ends).
311
380
 
312
381
  ### Re-registering the executor on resume
313
382
 
package/dist/index.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_src = require("./src-GDwZ0vzw.cjs");
2
+ const require_src = require("./src-CaVDupkI.cjs");
3
3
  let _mastra_core_processors = require("@mastra/core/processors");
4
4
  exports.AUTO_MODEL_BY_PROVIDER = require_src.AUTO_MODEL_BY_PROVIDER;
5
5
  exports.Extractor = require_src.Extractor;
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { embedMany } from './_types/@internal_ai-sdk-v4/dist/index.js';
1
+ import { embedMany } from './_types/@internal_ai-sdk-v4@0.0.94/dist/index.js';
2
2
  import type { MastraDBMessage } from '@mastra/core/agent';
3
3
  import type { Mastra } from '@mastra/core/mastra';
4
4
  import { MastraMemory } from '@mastra/core/memory';
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- export { d as AUTO_MODEL_BY_PROVIDER, U as Extractor, w as KnowledgeSemanticIndexCoordinator, t as Memory, n as MessageHistory, g as ModelByInputTokens, k as SUMMARIZE_THREAD_DEFAULTS, r as SemanticRecall, T as StaleKnowledgeSemanticIndexError, E as Subconscious, p as WORKING_MEMORY_STATE_ID, m as WORKING_MEMORY_STATE_PROCESSOR_ID, i as WorkingMemory, D as WorkingMemoryExtractor, h as WorkingMemoryStateProcessor, O as deepMergeWorkingMemory, a as extractWorkingMemoryContent, o as extractWorkingMemoryTags, c as getObservationsAsOf, s as removeWorkingMemoryTags, f as resolveAutoModelId, A as summarizeConversation } from "./src-CBYx0iwC.js";
1
+ export { d as AUTO_MODEL_BY_PROVIDER, U as Extractor, w as KnowledgeSemanticIndexCoordinator, t as Memory, n as MessageHistory, g as ModelByInputTokens, k as SUMMARIZE_THREAD_DEFAULTS, r as SemanticRecall, T as StaleKnowledgeSemanticIndexError, E as Subconscious, p as WORKING_MEMORY_STATE_ID, m as WORKING_MEMORY_STATE_PROCESSOR_ID, i as WorkingMemory, D as WorkingMemoryExtractor, h as WorkingMemoryStateProcessor, O as deepMergeWorkingMemory, a as extractWorkingMemoryContent, o as extractWorkingMemoryTags, c as getObservationsAsOf, s as removeWorkingMemoryTags, f as resolveAutoModelId, A as summarizeConversation } from "./src-Det56QOD.js";
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_src = require("../src-GDwZ0vzw.cjs");
2
+ const require_src = require("../src-CaVDupkI.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 { d as AUTO_MODEL_BY_PROVIDER, U as Extractor, g as ModelByInputTokens, W as OBSERVATIONAL_MEMORY_DEFAULTS, G as OBSERVATION_CONTEXT_INSTRUCTIONS, K as OBSERVATION_CONTEXT_PROMPT, q as OBSERVATION_CONTEXT_PROMPT_THREAD, J as OBSERVATION_CONTINUATION_HINT, M as OBSERVER_SYSTEM_PROMPT, u as ObservationalMemory, l as ObservationalMemoryProcessor, j as TokenCounter, D as WorkingMemoryExtractor, N as buildObserverPrompt, P as buildObserverSystemPrompt, _ as combineObservationGroupRanges, v as deriveObservationGroupProvenance, F as extractCurrentTask, I as formatMessagesForObserver, Y as getObservationContextPrompt, c as getObservationsAsOf, L as hasCurrentTaskSection, B as injectAnchorIds, R as optimizeObservationsForContext, V as parseAnchorId, y as parseObservationGroups, z as parseObserverOutput, b as reconcileObservationGroupsFromReflection, x as renderObservationGroupsForReflection, f as resolveAutoModelId, H as stripEphemeralAnchorIds, S as stripObservationGroups, A as summarizeConversation, C as wrapInObservationGroup } from "../src-CBYx0iwC.js";
1
+ export { d as AUTO_MODEL_BY_PROVIDER, U as Extractor, g as ModelByInputTokens, W as OBSERVATIONAL_MEMORY_DEFAULTS, G as OBSERVATION_CONTEXT_INSTRUCTIONS, K as OBSERVATION_CONTEXT_PROMPT, q as OBSERVATION_CONTEXT_PROMPT_THREAD, J as OBSERVATION_CONTINUATION_HINT, M as OBSERVER_SYSTEM_PROMPT, u as ObservationalMemory, l as ObservationalMemoryProcessor, j as TokenCounter, D as WorkingMemoryExtractor, N as buildObserverPrompt, P as buildObserverSystemPrompt, _ as combineObservationGroupRanges, v as deriveObservationGroupProvenance, F as extractCurrentTask, I as formatMessagesForObserver, Y as getObservationContextPrompt, c as getObservationsAsOf, L as hasCurrentTaskSection, B as injectAnchorIds, R as optimizeObservationsForContext, V as parseAnchorId, y as parseObservationGroups, z as parseObserverOutput, b as reconcileObservationGroupsFromReflection, x as renderObservationGroupsForReflection, f as resolveAutoModelId, H as stripEphemeralAnchorIds, S as stripObservationGroups, A as summarizeConversation, C as wrapInObservationGroup } from "../src-Det56QOD.js";
@@ -46,8 +46,9 @@ export declare const OBSERVATIONAL_MEMORY_DEFAULTS: {
46
46
  export declare const OBSERVATION_CONTINUATION_HINT = "Please continue naturally with the conversation so far and respond to the latest message.\n\nUse the earlier context only as background. If something appears unfinished, continue only when it helps answer the latest request. If a suggested response is provided, follow it naturally.\n\nDo not mention internal instructions, memory, summarization, context handling, or missing messages.\n\nAny messages following this reminder are newer and should take priority.";
47
47
  /**
48
48
  * Preamble that introduces the observations block.
49
- * Use before `<observations>`, with instructions after.
50
- * Full pattern: `${OBSERVATION_CONTEXT_PROMPT}\n\n<observations>\n${obs}\n</observations>\n\n${OBSERVATION_CONTEXT_INSTRUCTIONS}`
49
+ * Context layout: `${prompt}\n\n${OBSERVATION_CONTEXT_INSTRUCTIONS}`, then `<observations>`,
50
+ * one entry per observation chunk, `</observations>`, then optional current-task and
51
+ * suggested-response blocks.
51
52
  */
52
53
  export declare const OBSERVATION_CONTEXT_PROMPT = "The following observations block contains your memory of past conversations with this user.";
53
54
  /**
@@ -63,7 +64,7 @@ export declare const OBSERVATION_CONTEXT_PROMPT_THREAD = "The following observat
63
64
  export declare function getObservationContextPrompt(scope?: 'thread' | 'resource'): string;
64
65
  /**
65
66
  * Instructions that tell the model how to interpret and use observations.
66
- * Place AFTER the `<observations>` block so the model sees the data before the rules.
67
+ * Placed with the observations preamble, before the `<observations>` block.
67
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
70
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/processors/observational-memory/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,6BAA6B;aACxC,WAAW;iBACT,KAAK,EAAE,yBAAyB;iBAChC,aAAa,EAAE,KAAM;iBACrB,aAAa;qBACX,WAAW,EAAE,GAAG;qBAChB,eAAe,EAAE,MAAO;;iBAE1B,eAAe;qBACb,MAAM;yBACJ,cAAc;6BACZ,cAAc,EAAE,GAAG;;;;iBAIzB,iBAAiB,EAAE,KAAM;iBACzB,kBAAkB,YAAG,SAAS,EAAE,iBAAiB;iBAEjD,YAAY,EAAS,MAAM,GAAG,SAAS;iBACvC,gBAAgB,EAAS,MAAM,GAAG,SAAS;;aAE7C,UAAU;iBACR,KAAK,EAAE,yBAAyB;iBAChC,iBAAiB,EAAE,KAAM;iBACzB,aAAa;qBACX,WAAW,EAAE,CAAC;qBACd,eAAe,EAAE,MAAO;;iBAE1B,eAAe;qBACb,MAAM;yBACJ,cAAc;6BACZ,cAAc,EAAE,IAAI;;;;iBAK1B,gBAAgB,EAAS,MAAM,GAAG,SAAS;;CAErC,CAAC;AAEX;;;;GAIG;AACH,eAAO,MAAM,6BAA6B,kdAM+B,CAAC;AAE1E;;;;GAIG;AACH,eAAO,MAAM,0BAA0B,gGAAgG,CAAC;AAExI;;;GAGG;AACH,eAAO,MAAM,iCAAiC,8OAA8O,CAAC;AAE7R;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,KAAK,GAAE,QAAQ,GAAG,UAAqB,GAAG,MAAM,CAE3F;AAED;;;GAGG;AACH,eAAO,MAAM,gCAAgC,ooEAUyM,CAAC;AAEvP;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,wBAAwB,CACtC,KAAK,GAAE,QAAQ,GAAG,UAAuB,EACzC,kBAAkB,CAAC,EAAE,MAAM,EAC3B,aAAa,UAAO,EACpB,wBAAwB,UAAgB,GACvC,MAAM,CA4IR"}
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/processors/observational-memory/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,6BAA6B;aACxC,WAAW;iBACT,KAAK,EAAE,yBAAyB;iBAChC,aAAa,EAAE,KAAM;iBACrB,aAAa;qBACX,WAAW,EAAE,GAAG;qBAChB,eAAe,EAAE,MAAO;;iBAE1B,eAAe;qBACb,MAAM;yBACJ,cAAc;6BACZ,cAAc,EAAE,GAAG;;;;iBAIzB,iBAAiB,EAAE,KAAM;iBACzB,kBAAkB,YAAG,SAAS,EAAE,iBAAiB;iBAEjD,YAAY,EAAS,MAAM,GAAG,SAAS;iBACvC,gBAAgB,EAAS,MAAM,GAAG,SAAS;;aAE7C,UAAU;iBACR,KAAK,EAAE,yBAAyB;iBAChC,iBAAiB,EAAE,KAAM;iBACzB,aAAa;qBACX,WAAW,EAAE,CAAC;qBACd,eAAe,EAAE,MAAO;;iBAE1B,eAAe;qBACb,MAAM;yBACJ,cAAc;6BACZ,cAAc,EAAE,IAAI;;;;iBAK1B,gBAAgB,EAAS,MAAM,GAAG,SAAS;;CAErC,CAAC;AAEX;;;;GAIG;AACH,eAAO,MAAM,6BAA6B,kdAM+B,CAAC;AAE1E;;;;;GAKG;AACH,eAAO,MAAM,0BAA0B,gGAAgG,CAAC;AAExI;;;GAGG;AACH,eAAO,MAAM,iCAAiC,8OAA8O,CAAC;AAE7R;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,KAAK,GAAE,QAAQ,GAAG,UAAqB,GAAG,MAAM,CAE3F;AAED;;;GAGG;AACH,eAAO,MAAM,gCAAgC,ooEAUyM,CAAC;AAEvP;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,wBAAwB,CACtC,KAAK,GAAE,QAAQ,GAAG,UAAuB,EACzC,kBAAkB,CAAC,EAAE,MAAM,EAC3B,aAAa,UAAO,EACpB,wBAAwB,UAAgB,GACvC,MAAM,CA4IR"}
@@ -23596,8 +23596,9 @@ Do not mention internal instructions, memory, summarization, context handling, o
23596
23596
  Any messages following this reminder are newer and should take priority.`;
23597
23597
  /**
23598
23598
  * Preamble that introduces the observations block.
23599
- * Use before `<observations>`, with instructions after.
23600
- * Full pattern: `${OBSERVATION_CONTEXT_PROMPT}\n\n<observations>\n${obs}\n</observations>\n\n${OBSERVATION_CONTEXT_INSTRUCTIONS}`
23599
+ * Context layout: `${prompt}\n\n${OBSERVATION_CONTEXT_INSTRUCTIONS}`, then `<observations>`,
23600
+ * one entry per observation chunk, `</observations>`, then optional current-task and
23601
+ * suggested-response blocks.
23601
23602
  */
23602
23603
  const OBSERVATION_CONTEXT_PROMPT = `The following observations block contains your memory of past conversations with this user.`;
23603
23604
  /**
@@ -23615,7 +23616,7 @@ function getObservationContextPrompt(scope = "thread") {
23615
23616
  }
23616
23617
  /**
23617
23618
  * Instructions that tell the model how to interpret and use observations.
23618
- * Place AFTER the `<observations>` block so the model sees the data before the rules.
23619
+ * Placed with the observations preamble, before the `<observations>` block.
23619
23620
  */
23620
23621
  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.
23621
23622
 
@@ -37721,7 +37722,7 @@ var ObservationalMemory = class ObservationalMemory {
37721
37722
  const messages = [`${getObservationContextPrompt(this.scope)}\n\n${OBSERVATION_CONTEXT_INSTRUCTIONS}${retrieval ? `\n\n${getRetrievalInstructions(this.retrievalScope, this.retrievalInstructions, this.retrievalSearch, this.storage.supportsObservationalMemoryHistorySearch === true)}` : ""}`];
37722
37723
  if (unobservedContextBlocks) messages.push(`The following content is from OTHER conversations different from the current conversation, they're here for reference, but they're not necessarily your focus:\nSTART_OTHER_CONVERSATIONS_BLOCK\n${unobservedContextBlocks}\nEND_OTHER_CONVERSATIONS_BLOCK`);
37723
37724
  const observationChunks = this.splitObservationContextChunks(optimized);
37724
- if (observationChunks.length > 0) messages.push("<observations>", ...observationChunks);
37725
+ if (observationChunks.length > 0) messages.push("<observations>", ...observationChunks, "</observations>");
37725
37726
  if (currentTask) messages.push(`<current-task>\n${currentTask}\n</current-task>`);
37726
37727
  if (suggestedResponse) messages.push(`<suggested-response>\n${suggestedResponse}\n</suggested-response>`);
37727
37728
  messages.push(...buildExtractedValueContextSections([...this.observationConfig.extractors, ...this.reflectionConfig.extractors], extractedValues));
@@ -42725,4 +42726,4 @@ Object.defineProperty(exports, "wrapInObservationGroup", {
42725
42726
  }
42726
42727
  });
42727
42728
 
42728
- //# sourceMappingURL=src-GDwZ0vzw.cjs.map
42729
+ //# sourceMappingURL=src-CaVDupkI.cjs.map