@mastra/memory 1.18.2 → 1.19.0-alpha.1
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/CHANGELOG.md +53 -0
- package/dist/{chunk-4AQHFADP.cjs → chunk-5IJQOXJM.cjs} +141 -25
- package/dist/chunk-5IJQOXJM.cjs.map +1 -0
- package/dist/{chunk-LCALB7W6.js → chunk-NZXH5WER.js} +141 -25
- package/dist/chunk-NZXH5WER.js.map +1 -0
- package/dist/docs/SKILL.md +2 -1
- package/dist/docs/assets/SOURCE_MAP.json +47 -47
- package/dist/docs/references/docs-evals-evals-with-memory.md +146 -0
- package/dist/docs/references/docs-memory-observational-memory.md +52 -17
- package/dist/docs/references/reference-memory-observational-memory.md +5 -3
- package/dist/index.cjs +13 -13
- package/dist/index.js +4 -4
- package/dist/{observational-memory-SYNXJVL4.js → observational-memory-KFKHBTCB.js} +3 -3
- package/dist/{observational-memory-SYNXJVL4.js.map → observational-memory-KFKHBTCB.js.map} +1 -1
- package/dist/{observational-memory-7M2T5EOV.cjs → observational-memory-V2APY3TO.cjs} +26 -26
- package/dist/{observational-memory-7M2T5EOV.cjs.map → observational-memory-V2APY3TO.cjs.map} +1 -1
- package/dist/processors/index.cjs +24 -24
- package/dist/processors/index.js +1 -1
- package/dist/processors/observational-memory/activation-ttl.d.ts +4 -0
- package/dist/processors/observational-memory/activation-ttl.d.ts.map +1 -0
- package/dist/processors/observational-memory/observation-turn/turn.d.ts +6 -1
- package/dist/processors/observational-memory/observation-turn/turn.d.ts.map +1 -1
- package/dist/processors/observational-memory/observational-memory.d.ts.map +1 -1
- package/dist/processors/observational-memory/observer-agent.d.ts +13 -0
- package/dist/processors/observational-memory/observer-agent.d.ts.map +1 -1
- package/dist/processors/observational-memory/observer-runner.d.ts.map +1 -1
- package/dist/processors/observational-memory/processor.d.ts.map +1 -1
- package/dist/processors/observational-memory/reflector-runner.d.ts.map +1 -1
- package/dist/processors/observational-memory/tracing.d.ts.map +1 -1
- package/dist/processors/observational-memory/types.d.ts +30 -6
- package/dist/processors/observational-memory/types.d.ts.map +1 -1
- package/package.json +5 -5
- package/dist/chunk-4AQHFADP.cjs.map +0 -1
- package/dist/chunk-LCALB7W6.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,58 @@
|
|
|
1
1
|
# @mastra/memory
|
|
2
2
|
|
|
3
|
+
## 1.19.0-alpha.1
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Added `activateAfterIdle: "auto"` for Observational Memory early activation. ([#16663](https://github.com/mastra-ai/mastra/pull/16663))
|
|
8
|
+
|
|
9
|
+
Mastra can now choose an idle activation timeout from the active model provider's prompt cache behavior. OpenAI also respects `providerOptions.openai.promptCacheRetention` when available.
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
const memory = new Memory({
|
|
13
|
+
options: {
|
|
14
|
+
observationalMemory: {
|
|
15
|
+
model: 'google/gemini-2.5-flash',
|
|
16
|
+
activateAfterIdle: 'auto',
|
|
17
|
+
activateOnProviderChange: true,
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
- Add `observeAttachments` to `ObservationConfig` for Observational Memory. Use it to control whether image/file parts on observed messages are forwarded to the Observer model alongside their placeholder text lines. ([#16671](https://github.com/mastra-ai/mastra/pull/16671))
|
|
24
|
+
- `true` (default) — forward all attachments (existing behavior).
|
|
25
|
+
- `false` — drop all attachments; placeholders still appear in the observer transcript.
|
|
26
|
+
- `string[]` — allowlist of mimeType patterns, e.g. `['image/*']` or `['application/pdf']`. Matching is case-insensitive and supports exact, `type/*`, and `*` patterns.
|
|
27
|
+
|
|
28
|
+
Useful when the Observer model is text-only (some DeepSeek endpoints, etc.) while the main agent uses a multimodal model. Tool-result attachments are filtered with the same rule.
|
|
29
|
+
|
|
30
|
+
```ts
|
|
31
|
+
new Memory({
|
|
32
|
+
options: {
|
|
33
|
+
observationalMemory: {
|
|
34
|
+
observation: {
|
|
35
|
+
model: 'deepseek/deepseek-chat', // text-only observer
|
|
36
|
+
observeAttachments: false, // or e.g. ['image/*', 'application/pdf']
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### Patch Changes
|
|
44
|
+
|
|
45
|
+
- Updated dependencies [[`c272d50`](https://github.com/mastra-ai/mastra/commit/c272d50610a54496b6b6d92ccd4d37b333a2613a), [`d8692af`](https://github.com/mastra-ai/mastra/commit/d8692afa253028e39cdce2aafa0ac414071a762e), [`841a222`](https://github.com/mastra-ai/mastra/commit/841a222560d8c19238f8213713f30535cdd82284)]:
|
|
46
|
+
- @mastra/core@1.36.0-alpha.4
|
|
47
|
+
|
|
48
|
+
## 1.18.3-alpha.0
|
|
49
|
+
|
|
50
|
+
### Patch Changes
|
|
51
|
+
|
|
52
|
+
- feat(memory): start background buffering of unobserved messages when agent goes idle ([#16694](https://github.com/mastra-ai/mastra/pull/16694))
|
|
53
|
+
|
|
54
|
+
In OM buffering mode, when the agent goes idle (turn.end()), any unobserved messages are now buffered in the background via a fire-and-forget buffer() call. This ensures observations are computed proactively rather than waiting for the next turn's step.prepare().
|
|
55
|
+
|
|
3
56
|
## 1.18.2
|
|
4
57
|
|
|
5
58
|
### Patch Changes
|
|
@@ -21,6 +21,47 @@ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
|
21
21
|
var xxhash__default = /*#__PURE__*/_interopDefault(xxhash);
|
|
22
22
|
var imageSize__default = /*#__PURE__*/_interopDefault(imageSize);
|
|
23
23
|
|
|
24
|
+
// src/processors/observational-memory/activation-ttl.ts
|
|
25
|
+
var MINUTE = 6e4;
|
|
26
|
+
var HOUR = 60 * MINUTE;
|
|
27
|
+
var SHORT_TTL = 5 * MINUTE;
|
|
28
|
+
var OPENAI_EXTENDED_TTL = HOUR;
|
|
29
|
+
var GEMINI_TTL = 24 * HOUR;
|
|
30
|
+
var DEEPSEEK_TTL = HOUR;
|
|
31
|
+
var GROQ_TTL = 2 * HOUR;
|
|
32
|
+
function normalize(value) {
|
|
33
|
+
return value?.toLowerCase() ?? "";
|
|
34
|
+
}
|
|
35
|
+
function isOpenAIShortTtlModel(modelId) {
|
|
36
|
+
return /^gpt-4/.test(modelId) || /^gpt-5(?:$|-|\.([1-4])(?:$|-))/.test(modelId);
|
|
37
|
+
}
|
|
38
|
+
function getOpenAIPromptCacheRetention(providerOptions) {
|
|
39
|
+
const openaiOptions = providerOptions?.openai;
|
|
40
|
+
return typeof openaiOptions?.promptCacheRetention === "string" ? openaiOptions.promptCacheRetention.toLowerCase() : void 0;
|
|
41
|
+
}
|
|
42
|
+
function resolveActivationTTL(activateAfterIdle, modelContext) {
|
|
43
|
+
if (activateAfterIdle !== "auto") {
|
|
44
|
+
return activateAfterIdle;
|
|
45
|
+
}
|
|
46
|
+
return resolveAutoActivationTTL(modelContext);
|
|
47
|
+
}
|
|
48
|
+
function resolveAutoActivationTTL(modelContext) {
|
|
49
|
+
const provider = normalize(modelContext?.provider);
|
|
50
|
+
const modelId = normalize(modelContext?.modelId);
|
|
51
|
+
if (provider.includes("openai")) {
|
|
52
|
+
const promptCacheRetention = getOpenAIPromptCacheRetention(modelContext?.providerOptions);
|
|
53
|
+
if (promptCacheRetention === "24h") return OPENAI_EXTENDED_TTL;
|
|
54
|
+
if (promptCacheRetention === "in_memory") return SHORT_TTL;
|
|
55
|
+
return isOpenAIShortTtlModel(modelId) ? SHORT_TTL : OPENAI_EXTENDED_TTL;
|
|
56
|
+
}
|
|
57
|
+
if (provider.includes("google") || provider.includes("gemini")) return GEMINI_TTL;
|
|
58
|
+
if (provider.includes("deepseek")) return DEEPSEEK_TTL;
|
|
59
|
+
if (provider.includes("groq")) return GROQ_TTL;
|
|
60
|
+
if (provider.includes("anthropic")) return SHORT_TTL;
|
|
61
|
+
if (provider.includes("xai") || provider.includes("grok")) return SHORT_TTL;
|
|
62
|
+
if (provider.includes("openrouter")) return SHORT_TTL;
|
|
63
|
+
return SHORT_TTL;
|
|
64
|
+
}
|
|
24
65
|
var OM_DEBUG_LOG = process.env.OM_DEBUG ? path.join(process.cwd(), "om-debug.log") : null;
|
|
25
66
|
function omDebug(msg) {
|
|
26
67
|
if (!OM_DEBUG_LOG) return;
|
|
@@ -2447,7 +2488,12 @@ var ObservationTurn = class {
|
|
|
2447
2488
|
return this._currentStep;
|
|
2448
2489
|
}
|
|
2449
2490
|
/**
|
|
2450
|
-
* Finalize the turn: save any remaining messages and return the
|
|
2491
|
+
* Finalize the turn: save any remaining messages and return the current cached record.
|
|
2492
|
+
*
|
|
2493
|
+
* When async observation buffering is enabled and there are unobserved messages,
|
|
2494
|
+
* a background buffer operation is kicked off so that observations are computed
|
|
2495
|
+
* proactively while the agent is idle, rather than waiting for the next turn.
|
|
2496
|
+
* The returned record does not wait for that background buffering pass to finish.
|
|
2451
2497
|
*/
|
|
2452
2498
|
async end() {
|
|
2453
2499
|
if (this._ended) throw new Error("Turn already ended");
|
|
@@ -2458,6 +2504,24 @@ var ObservationTurn = class {
|
|
|
2458
2504
|
if (unsavedMessages.length > 0) {
|
|
2459
2505
|
await this.om.persistMessages(unsavedMessages, this.threadId, this.resourceId);
|
|
2460
2506
|
}
|
|
2507
|
+
if (this.om.buffering.isAsyncObservationEnabled()) {
|
|
2508
|
+
const allMessages = this.messageList.get.all.db();
|
|
2509
|
+
const record = this._record;
|
|
2510
|
+
const unobservedMessages = this.om.getUnobservedMessages(allMessages, record);
|
|
2511
|
+
if (unobservedMessages.length > 0) {
|
|
2512
|
+
void this.om.buffer({
|
|
2513
|
+
threadId: this.threadId,
|
|
2514
|
+
resourceId: this.resourceId,
|
|
2515
|
+
messages: unobservedMessages,
|
|
2516
|
+
record,
|
|
2517
|
+
writer: this.writer,
|
|
2518
|
+
requestContext: this.requestContext,
|
|
2519
|
+
observabilityContext: this.observabilityContext
|
|
2520
|
+
}).catch((err) => {
|
|
2521
|
+
omDebug(`[OM:turn.end] idle buffer failed: ${err?.message}`);
|
|
2522
|
+
});
|
|
2523
|
+
}
|
|
2524
|
+
}
|
|
2461
2525
|
return { record: this._record };
|
|
2462
2526
|
}
|
|
2463
2527
|
/**
|
|
@@ -3129,6 +3193,35 @@ function isImageLikeObserverFilePart(part) {
|
|
|
3129
3193
|
}
|
|
3130
3194
|
return hasObserverImageFilenameExtension(part.filename);
|
|
3131
3195
|
}
|
|
3196
|
+
function resolveObserverAttachmentMimeType(part) {
|
|
3197
|
+
if (typeof part.mimeType === "string" && part.mimeType.length > 0) {
|
|
3198
|
+
return part.mimeType.toLowerCase();
|
|
3199
|
+
}
|
|
3200
|
+
if (part.type === "image") {
|
|
3201
|
+
return "image/*";
|
|
3202
|
+
}
|
|
3203
|
+
if (isImageLikeObserverFilePart(part)) {
|
|
3204
|
+
return "image/*";
|
|
3205
|
+
}
|
|
3206
|
+
return "application/octet-stream";
|
|
3207
|
+
}
|
|
3208
|
+
function matchObserverMimePattern(mimeType, pattern) {
|
|
3209
|
+
const normalized = pattern.trim().toLowerCase();
|
|
3210
|
+
if (!normalized) return false;
|
|
3211
|
+
if (normalized === "*" || normalized === "*/*") return true;
|
|
3212
|
+
if (normalized.endsWith("/*")) {
|
|
3213
|
+
const prefix = normalized.slice(0, normalized.length - 1);
|
|
3214
|
+
return mimeType.startsWith(prefix);
|
|
3215
|
+
}
|
|
3216
|
+
return mimeType === normalized;
|
|
3217
|
+
}
|
|
3218
|
+
function shouldIncludeObserverAttachment(part, filter) {
|
|
3219
|
+
if (filter === void 0 || filter === true) return true;
|
|
3220
|
+
if (filter === false) return false;
|
|
3221
|
+
if (!Array.isArray(filter) || filter.length === 0) return false;
|
|
3222
|
+
const mimeType = resolveObserverAttachmentMimeType(part);
|
|
3223
|
+
return filter.some((pattern) => matchObserverMimePattern(mimeType, pattern));
|
|
3224
|
+
}
|
|
3132
3225
|
function toObserverInputAttachmentPart(part) {
|
|
3133
3226
|
if (part.type === "image") {
|
|
3134
3227
|
return {
|
|
@@ -3227,22 +3320,26 @@ function mapToolResultBlockToAttachment(block) {
|
|
|
3227
3320
|
return void 0;
|
|
3228
3321
|
}
|
|
3229
3322
|
}
|
|
3230
|
-
function extractToolResultAttachments(result, counter) {
|
|
3323
|
+
function extractToolResultAttachments(result, counter, attachmentFilter) {
|
|
3231
3324
|
if (!isRecord(result) || result.type !== "content" || !Array.isArray(result.value)) {
|
|
3232
3325
|
return { resultWithoutAttachments: result, attachments: [] };
|
|
3233
3326
|
}
|
|
3234
3327
|
const record = result;
|
|
3235
3328
|
const attachments = [];
|
|
3329
|
+
let hadAttachmentBlocks = false;
|
|
3236
3330
|
const newValue = record.value.map((block) => {
|
|
3237
3331
|
const attachment = mapToolResultBlockToAttachment(block);
|
|
3238
3332
|
if (!attachment) {
|
|
3239
3333
|
return block;
|
|
3240
3334
|
}
|
|
3241
|
-
|
|
3335
|
+
hadAttachmentBlocks = true;
|
|
3336
|
+
if (shouldIncludeObserverAttachment(attachment, attachmentFilter)) {
|
|
3337
|
+
attachments.push(toObserverInputAttachmentPart(attachment));
|
|
3338
|
+
}
|
|
3242
3339
|
const placeholder = formatObserverAttachmentPlaceholder(attachment, counter);
|
|
3243
3340
|
return { type: isRecord(block) ? block.type : void 0, placeholder };
|
|
3244
3341
|
});
|
|
3245
|
-
if (
|
|
3342
|
+
if (!hadAttachmentBlocks) {
|
|
3246
3343
|
return { resultWithoutAttachments: result, attachments };
|
|
3247
3344
|
}
|
|
3248
3345
|
return { resultWithoutAttachments: { ...record, value: newValue }, attachments };
|
|
@@ -3301,6 +3398,7 @@ function getTemporalGapMarkerText(msg) {
|
|
|
3301
3398
|
function formatObserverMessage(msg, counter, options) {
|
|
3302
3399
|
const maxLen = options?.maxPartLength;
|
|
3303
3400
|
const maxToolResultTokens = options?.maxToolResultTokens ?? DEFAULT_OBSERVER_TOOL_RESULT_MAX_TOKENS;
|
|
3401
|
+
const attachmentFilter = options?.attachmentFilter;
|
|
3304
3402
|
const role = msg.role.charAt(0).toUpperCase() + msg.role.slice(1);
|
|
3305
3403
|
const attachments = [];
|
|
3306
3404
|
const messageCreatedAt = normalizeObserverCreatedAt(msg.createdAt);
|
|
@@ -3338,7 +3436,8 @@ function formatObserverMessage(msg, counter, options) {
|
|
|
3338
3436
|
);
|
|
3339
3437
|
const { resultWithoutAttachments, attachments: extractedAttachments } = extractToolResultAttachments(
|
|
3340
3438
|
resultForObserver,
|
|
3341
|
-
counter
|
|
3439
|
+
counter,
|
|
3440
|
+
attachmentFilter
|
|
3342
3441
|
);
|
|
3343
3442
|
if (extractedAttachments.length > 0) {
|
|
3344
3443
|
attachments.push(...extractedAttachments);
|
|
@@ -3367,9 +3466,11 @@ function formatObserverMessage(msg, counter, options) {
|
|
|
3367
3466
|
}
|
|
3368
3467
|
if (partType === "image" || partType === "file") {
|
|
3369
3468
|
const attachment = part;
|
|
3370
|
-
|
|
3371
|
-
|
|
3372
|
-
|
|
3469
|
+
if (shouldIncludeObserverAttachment(attachment, attachmentFilter)) {
|
|
3470
|
+
const inputAttachment = toObserverInputAttachmentPart(attachment);
|
|
3471
|
+
if (inputAttachment) {
|
|
3472
|
+
attachments.push(inputAttachment);
|
|
3473
|
+
}
|
|
3373
3474
|
}
|
|
3374
3475
|
pushLine(
|
|
3375
3476
|
partType === "image" ? "Image" : "File",
|
|
@@ -3957,13 +4058,11 @@ async function withOmTracingSpan({
|
|
|
3957
4058
|
entityType: observability.EntityType.OUTPUT_STEP_PROCESSOR,
|
|
3958
4059
|
entityName: config.entityName,
|
|
3959
4060
|
tracingContext: observabilityContext?.tracingContext ?? observabilityContext?.tracing,
|
|
3960
|
-
|
|
3961
|
-
|
|
3962
|
-
|
|
3963
|
-
|
|
3964
|
-
|
|
3965
|
-
...metadata
|
|
3966
|
-
}
|
|
4061
|
+
metadata: {
|
|
4062
|
+
omPhase: phase,
|
|
4063
|
+
omInputTokens: inputTokens,
|
|
4064
|
+
omSelectedModel: typeof model === "string" ? model : "(dynamic-model)",
|
|
4065
|
+
...metadata
|
|
3967
4066
|
},
|
|
3968
4067
|
requestContext
|
|
3969
4068
|
});
|
|
@@ -4034,7 +4133,9 @@ var ObserverRunner = class {
|
|
|
4034
4133
|
includeThreadTitle: this.observationConfig.threadTitle
|
|
4035
4134
|
})
|
|
4036
4135
|
},
|
|
4037
|
-
buildObserverHistoryMessage(messagesToObserve
|
|
4136
|
+
buildObserverHistoryMessage(messagesToObserve, {
|
|
4137
|
+
attachmentFilter: this.observationConfig.observeAttachments
|
|
4138
|
+
})
|
|
4038
4139
|
];
|
|
4039
4140
|
const doGenerate = async () => {
|
|
4040
4141
|
return withRetry(
|
|
@@ -4131,7 +4232,9 @@ var ObserverRunner = class {
|
|
|
4131
4232
|
this.observationConfig.threadTitle
|
|
4132
4233
|
)
|
|
4133
4234
|
},
|
|
4134
|
-
buildMultiThreadObserverHistoryMessage(messagesByThread, threadOrder
|
|
4235
|
+
buildMultiThreadObserverHistoryMessage(messagesByThread, threadOrder, {
|
|
4236
|
+
attachmentFilter: this.observationConfig.observeAttachments
|
|
4237
|
+
})
|
|
4135
4238
|
];
|
|
4136
4239
|
for (const msgs of messagesByThread.values()) {
|
|
4137
4240
|
for (const msg of msgs) {
|
|
@@ -4962,7 +5065,10 @@ ${unreflectedContent}` : freshRecord.bufferedReflection;
|
|
|
4962
5065
|
ttlExpiredMs: activationMetadata?.ttlExpiredMs,
|
|
4963
5066
|
previousModel: activationMetadata?.previousModel,
|
|
4964
5067
|
currentModel: activationMetadata?.currentModel,
|
|
4965
|
-
config:
|
|
5068
|
+
config: {
|
|
5069
|
+
...this.getObservationMarkerConfig(freshRecord),
|
|
5070
|
+
activateAfterIdle: activationMetadata?.activateAfterIdle ?? this.reflectionConfig.activateAfterIdle
|
|
5071
|
+
}
|
|
4966
5072
|
});
|
|
4967
5073
|
void writer.custom({ ...activationMarker, transient: true }).catch(() => {
|
|
4968
5074
|
});
|
|
@@ -5025,7 +5131,7 @@ ${unreflectedContent}` : freshRecord.bufferedReflection;
|
|
|
5025
5131
|
);
|
|
5026
5132
|
}
|
|
5027
5133
|
}
|
|
5028
|
-
const activateAfterIdle = this.reflectionConfig.activateAfterIdle;
|
|
5134
|
+
const activateAfterIdle = resolveActivationTTL(this.reflectionConfig.activateAfterIdle, currentModel);
|
|
5029
5135
|
const ttlExpiredMs = activateAfterIdle !== void 0 && lastActivityAt !== void 0 ? Date.now() - lastActivityAt : void 0;
|
|
5030
5136
|
const ttlExpired = ttlExpiredMs !== void 0 && activateAfterIdle !== void 0 && ttlExpiredMs >= activateAfterIdle;
|
|
5031
5137
|
const actorModel = getCurrentModel(currentModel);
|
|
@@ -5038,6 +5144,7 @@ ${unreflectedContent}` : freshRecord.bufferedReflection;
|
|
|
5038
5144
|
const activationMetadata = {
|
|
5039
5145
|
triggeredBy: activationTriggeredBy,
|
|
5040
5146
|
lastActivityAt: activationTriggeredBy === "ttl" ? lastActivityAt : void 0,
|
|
5147
|
+
activateAfterIdle: activationTriggeredBy === "ttl" ? activateAfterIdle : void 0,
|
|
5041
5148
|
ttlExpiredMs: activationTriggeredBy === "ttl" ? ttlExpiredMs : void 0,
|
|
5042
5149
|
previousModel: activationTriggeredBy === "provider_change" ? lastModel : void 0,
|
|
5043
5150
|
currentModel: activationTriggeredBy === "provider_change" ? actorModel : void 0
|
|
@@ -6878,6 +6985,9 @@ function parseActivationTTL(value, fieldPath) {
|
|
|
6878
6985
|
if (value === void 0 || value === false) {
|
|
6879
6986
|
return void 0;
|
|
6880
6987
|
}
|
|
6988
|
+
if (value === "auto") {
|
|
6989
|
+
return value;
|
|
6990
|
+
}
|
|
6881
6991
|
if (typeof value === "number") {
|
|
6882
6992
|
if (!Number.isFinite(value) || value < 0) {
|
|
6883
6993
|
throw new Error(`${fieldPath} must be a non-negative number of milliseconds or a duration string like "5m".`);
|
|
@@ -7050,7 +7160,8 @@ Async buffering is enabled by default \u2014 this opt-out is only needed when us
|
|
|
7050
7160
|
),
|
|
7051
7161
|
previousObserverTokens: config.observation?.previousObserverTokens ?? 2e3,
|
|
7052
7162
|
instruction: config.observation?.instruction,
|
|
7053
|
-
threadTitle: config.observation?.threadTitle ?? false
|
|
7163
|
+
threadTitle: config.observation?.threadTitle ?? false,
|
|
7164
|
+
observeAttachments: config.observation?.observeAttachments ?? true
|
|
7054
7165
|
};
|
|
7055
7166
|
this.reflectionConfig = {
|
|
7056
7167
|
model: reflectionModel,
|
|
@@ -8973,6 +9084,7 @@ ${grouped}` : grouped;
|
|
|
8973
9084
|
}
|
|
8974
9085
|
let activationTriggeredBy = "threshold";
|
|
8975
9086
|
let activationLastActivityAt;
|
|
9087
|
+
let activationActivateAfterIdle;
|
|
8976
9088
|
let activateAfterIdleExpiredMs;
|
|
8977
9089
|
let previousModel;
|
|
8978
9090
|
let currentModel;
|
|
@@ -8982,7 +9094,7 @@ ${grouped}` : grouped;
|
|
|
8982
9094
|
resourceId,
|
|
8983
9095
|
record.lastObservedAt ? new Date(record.lastObservedAt) : void 0
|
|
8984
9096
|
);
|
|
8985
|
-
const activateAfterIdle = this.observationConfig.activateAfterIdle;
|
|
9097
|
+
const activateAfterIdle = resolveActivationTTL(this.observationConfig.activateAfterIdle, opts.currentModel);
|
|
8986
9098
|
const lastActivityAt = getLastActivityFromMessages(thresholdMessages);
|
|
8987
9099
|
const ttlExpiredMs = activateAfterIdle !== void 0 && lastActivityAt !== void 0 ? Date.now() - lastActivityAt : void 0;
|
|
8988
9100
|
const ttlExpired = ttlExpiredMs !== void 0 && activateAfterIdle !== void 0 && ttlExpiredMs >= activateAfterIdle;
|
|
@@ -8996,6 +9108,7 @@ ${grouped}` : grouped;
|
|
|
8996
9108
|
} else if (ttlExpired) {
|
|
8997
9109
|
activationTriggeredBy = "ttl";
|
|
8998
9110
|
activationLastActivityAt = lastActivityAt;
|
|
9111
|
+
activationActivateAfterIdle = activateAfterIdle;
|
|
8999
9112
|
activateAfterIdleExpiredMs = ttlExpiredMs;
|
|
9000
9113
|
} else {
|
|
9001
9114
|
const status = await this.getStatus({ threadId, resourceId, messages: thresholdMessages });
|
|
@@ -9064,7 +9177,10 @@ ${grouped}` : grouped;
|
|
|
9064
9177
|
ttlExpiredMs: activateAfterIdleExpiredMs,
|
|
9065
9178
|
previousModel,
|
|
9066
9179
|
currentModel,
|
|
9067
|
-
config:
|
|
9180
|
+
config: {
|
|
9181
|
+
...this.getObservationMarkerConfig(),
|
|
9182
|
+
activateAfterIdle: activationActivateAfterIdle ?? this.observationConfig.activateAfterIdle
|
|
9183
|
+
}
|
|
9068
9184
|
});
|
|
9069
9185
|
void opts.writer.custom({ ...activationMarker, transient: true }).catch(() => {
|
|
9070
9186
|
});
|
|
@@ -9523,7 +9639,7 @@ var ObservationalMemoryProcessor = class {
|
|
|
9523
9639
|
const { threadId, resourceId } = context;
|
|
9524
9640
|
const memoryContext = memory.parseMemoryRequestContext(requestContext);
|
|
9525
9641
|
const readOnly = memoryContext?.memoryConfig?.readOnly;
|
|
9526
|
-
const actorModelContext = model?.modelId ? { provider: model.provider, modelId: model.modelId } : void 0;
|
|
9642
|
+
const actorModelContext = model?.modelId ? { provider: model.provider, modelId: model.modelId, providerOptions: args.providerOptions } : void 0;
|
|
9527
9643
|
state.__omActorModelContext = actorModelContext;
|
|
9528
9644
|
return this.engine.getTokenCounter().runWithModelContext(actorModelContext, async () => {
|
|
9529
9645
|
const reproCaptureEnabled = isOmReproCaptureEnabled();
|
|
@@ -9737,5 +9853,5 @@ exports.stripEphemeralAnchorIds = stripEphemeralAnchorIds;
|
|
|
9737
9853
|
exports.stripObservationGroups = stripObservationGroups;
|
|
9738
9854
|
exports.truncateStringByTokens = truncateStringByTokens;
|
|
9739
9855
|
exports.wrapInObservationGroup = wrapInObservationGroup;
|
|
9740
|
-
//# sourceMappingURL=chunk-
|
|
9741
|
-
//# sourceMappingURL=chunk-
|
|
9856
|
+
//# sourceMappingURL=chunk-5IJQOXJM.cjs.map
|
|
9857
|
+
//# sourceMappingURL=chunk-5IJQOXJM.cjs.map
|