@mastra/server 1.16.0-alpha.3 → 1.16.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.
- package/CHANGELOG.md +35 -0
- package/dist/{chunk-PIORYI6S.js → chunk-645P6ZAV.js} +11 -3
- package/dist/chunk-645P6ZAV.js.map +1 -0
- package/dist/{chunk-YIVUZPOV.cjs → chunk-ALMN74MG.cjs} +80 -76
- package/dist/chunk-ALMN74MG.cjs.map +1 -0
- package/dist/{chunk-4Y4RMTIA.cjs → chunk-OCSZZ5UK.cjs} +11 -3
- package/dist/chunk-OCSZZ5UK.cjs.map +1 -0
- package/dist/{chunk-TVGJFK3J.js → chunk-R3IO7NKS.js} +8 -5
- package/dist/chunk-R3IO7NKS.js.map +1 -0
- package/dist/{chunk-457RSMZH.cjs → chunk-UTQV3JAT.cjs} +338 -117
- package/dist/chunk-UTQV3JAT.cjs.map +1 -0
- package/dist/{chunk-7DAVYYZ6.js → chunk-V4IWGD6S.js} +9 -5
- package/dist/chunk-V4IWGD6S.js.map +1 -0
- package/dist/{chunk-ZPHHURXX.cjs → chunk-VCBFCDP3.cjs} +21 -18
- package/dist/chunk-VCBFCDP3.cjs.map +1 -0
- package/dist/{chunk-ZRUDCNFS.js → chunk-W2QMKHBI.js} +338 -118
- package/dist/chunk-W2QMKHBI.js.map +1 -0
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/{observational-memory-OZ7TG4DZ-COUORCVN.cjs → observational-memory-K2U3QQIO-MBBXGVVG.cjs} +32 -28
- package/dist/{observational-memory-OZ7TG4DZ-COUORCVN.cjs.map → observational-memory-K2U3QQIO-MBBXGVVG.cjs.map} +1 -1
- package/dist/observational-memory-K2U3QQIO-MOPJN5M7.js +3 -0
- package/dist/{observational-memory-OZ7TG4DZ-MYYBYEP6.js.map → observational-memory-K2U3QQIO-MOPJN5M7.js.map} +1 -1
- package/dist/server/handlers/agent-builder.cjs +16 -16
- package/dist/server/handlers/agent-builder.js +1 -1
- package/dist/server/handlers/memory.cjs +27 -27
- package/dist/server/handlers/memory.d.ts +16 -0
- package/dist/server/handlers/memory.d.ts.map +1 -1
- package/dist/server/handlers/memory.js +1 -1
- package/dist/server/handlers.cjs +4 -4
- package/dist/server/handlers.js +2 -2
- package/dist/server/schemas/index.cjs +44 -44
- package/dist/server/schemas/index.js +1 -1
- package/dist/server/schemas/memory.d.ts +8 -0
- package/dist/server/schemas/memory.d.ts.map +1 -1
- package/dist/server/server-adapter/index.cjs +42 -42
- package/dist/server/server-adapter/index.js +2 -2
- package/dist/server/server-adapter/routes/memory.d.ts +16 -0
- package/dist/server/server-adapter/routes/memory.d.ts.map +1 -1
- package/package.json +5 -5
- package/dist/chunk-457RSMZH.cjs.map +0 -1
- package/dist/chunk-4Y4RMTIA.cjs.map +0 -1
- package/dist/chunk-7DAVYYZ6.js.map +0 -1
- package/dist/chunk-PIORYI6S.js.map +0 -1
- package/dist/chunk-TVGJFK3J.js.map +0 -1
- package/dist/chunk-YIVUZPOV.cjs.map +0 -1
- package/dist/chunk-ZPHHURXX.cjs.map +0 -1
- package/dist/chunk-ZRUDCNFS.js.map +0 -1
- package/dist/observational-memory-OZ7TG4DZ-MYYBYEP6.js +0 -3
|
@@ -4,11 +4,12 @@ import { Agent } from '@mastra/core/agent';
|
|
|
4
4
|
import { coreFeatures } from '@mastra/core/features';
|
|
5
5
|
import { resolveModelConfig } from '@mastra/core/llm';
|
|
6
6
|
import { setThreadOMMetadata, getThreadOMMetadata, parseMemoryRequestContext } from '@mastra/core/memory';
|
|
7
|
+
import { getOrCreateSpan, SpanType, createObservabilityContext } from '@mastra/core/observability';
|
|
7
8
|
import { MessageHistory } from '@mastra/core/processors';
|
|
8
9
|
import { randomBytes, createHash, randomUUID } from 'crypto';
|
|
9
10
|
import { AsyncLocalStorage } from 'async_hooks';
|
|
10
11
|
|
|
11
|
-
// ../memory/dist/chunk-
|
|
12
|
+
// ../memory/dist/chunk-7A3UGAXY.js
|
|
12
13
|
|
|
13
14
|
// ../../node_modules/.pnpm/xxhash-wasm@1.1.0/node_modules/xxhash-wasm/esm/xxhash-wasm.js
|
|
14
15
|
var t = new Uint8Array([0, 97, 115, 109, 1, 0, 0, 0, 1, 48, 8, 96, 3, 127, 127, 127, 1, 127, 96, 3, 127, 127, 127, 0, 96, 2, 127, 127, 0, 96, 1, 127, 1, 127, 96, 3, 127, 127, 126, 1, 126, 96, 3, 126, 127, 127, 1, 126, 96, 2, 127, 126, 0, 96, 1, 127, 1, 126, 3, 11, 10, 0, 0, 2, 1, 3, 4, 5, 6, 1, 7, 5, 3, 1, 0, 1, 7, 85, 9, 3, 109, 101, 109, 2, 0, 5, 120, 120, 104, 51, 50, 0, 0, 6, 105, 110, 105, 116, 51, 50, 0, 2, 8, 117, 112, 100, 97, 116, 101, 51, 50, 0, 3, 8, 100, 105, 103, 101, 115, 116, 51, 50, 0, 4, 5, 120, 120, 104, 54, 52, 0, 5, 6, 105, 110, 105, 116, 54, 52, 0, 7, 8, 117, 112, 100, 97, 116, 101, 54, 52, 0, 8, 8, 100, 105, 103, 101, 115, 116, 54, 52, 0, 9, 10, 251, 22, 10, 242, 1, 1, 4, 127, 32, 0, 32, 1, 106, 33, 3, 32, 1, 65, 16, 79, 4, 127, 32, 3, 65, 16, 107, 33, 6, 32, 2, 65, 168, 136, 141, 161, 2, 106, 33, 3, 32, 2, 65, 137, 235, 208, 208, 7, 107, 33, 4, 32, 2, 65, 207, 140, 162, 142, 6, 106, 33, 5, 3, 64, 32, 3, 32, 0, 40, 2, 0, 65, 247, 148, 175, 175, 120, 108, 106, 65, 13, 119, 65, 177, 243, 221, 241, 121, 108, 33, 3, 32, 4, 32, 0, 65, 4, 106, 34, 0, 40, 2, 0, 65, 247, 148, 175, 175, 120, 108, 106, 65, 13, 119, 65, 177, 243, 221, 241, 121, 108, 33, 4, 32, 2, 32, 0, 65, 4, 106, 34, 0, 40, 2, 0, 65, 247, 148, 175, 175, 120, 108, 106, 65, 13, 119, 65, 177, 243, 221, 241, 121, 108, 33, 2, 32, 5, 32, 0, 65, 4, 106, 34, 0, 40, 2, 0, 65, 247, 148, 175, 175, 120, 108, 106, 65, 13, 119, 65, 177, 243, 221, 241, 121, 108, 33, 5, 32, 6, 32, 0, 65, 4, 106, 34, 0, 79, 13, 0, 11, 32, 2, 65, 12, 119, 32, 5, 65, 18, 119, 106, 32, 4, 65, 7, 119, 106, 32, 3, 65, 1, 119, 106, 5, 32, 2, 65, 177, 207, 217, 178, 1, 106, 11, 32, 1, 106, 32, 0, 32, 1, 65, 15, 113, 16, 1, 11, 146, 1, 0, 32, 1, 32, 2, 106, 33, 2, 3, 64, 32, 1, 65, 4, 106, 32, 2, 75, 69, 4, 64, 32, 0, 32, 1, 40, 2, 0, 65, 189, 220, 202, 149, 124, 108, 106, 65, 17, 119, 65, 175, 214, 211, 190, 2, 108, 33, 0, 32, 1, 65, 4, 106, 33, 1, 12, 1, 11, 11, 3, 64, 32, 1, 32, 2, 79, 69, 4, 64, 32, 0, 32, 1, 45, 0, 0, 65, 177, 207, 217, 178, 1, 108, 106, 65, 11, 119, 65, 177, 243, 221, 241, 121, 108, 33, 0, 32, 1, 65, 1, 106, 33, 1, 12, 1, 11, 11, 32, 0, 32, 0, 65, 15, 118, 115, 65, 247, 148, 175, 175, 120, 108, 34, 0, 65, 13, 118, 32, 0, 115, 65, 189, 220, 202, 149, 124, 108, 34, 0, 65, 16, 118, 32, 0, 115, 11, 63, 0, 32, 0, 65, 8, 106, 32, 1, 65, 168, 136, 141, 161, 2, 106, 54, 2, 0, 32, 0, 65, 12, 106, 32, 1, 65, 137, 235, 208, 208, 7, 107, 54, 2, 0, 32, 0, 65, 16, 106, 32, 1, 54, 2, 0, 32, 0, 65, 20, 106, 32, 1, 65, 207, 140, 162, 142, 6, 106, 54, 2, 0, 11, 195, 4, 1, 6, 127, 32, 1, 32, 2, 106, 33, 6, 32, 0, 65, 24, 106, 33, 4, 32, 0, 65, 40, 106, 40, 2, 0, 33, 3, 32, 0, 32, 0, 40, 2, 0, 32, 2, 106, 54, 2, 0, 32, 0, 65, 4, 106, 34, 5, 32, 5, 40, 2, 0, 32, 2, 65, 16, 79, 32, 0, 40, 2, 0, 65, 16, 79, 114, 114, 54, 2, 0, 32, 2, 32, 3, 106, 65, 16, 73, 4, 64, 32, 3, 32, 4, 106, 32, 1, 32, 2, 252, 10, 0, 0, 32, 0, 65, 40, 106, 32, 2, 32, 3, 106, 54, 2, 0, 15, 11, 32, 3, 4, 64, 32, 3, 32, 4, 106, 32, 1, 65, 16, 32, 3, 107, 34, 2, 252, 10, 0, 0, 32, 0, 65, 8, 106, 34, 3, 32, 3, 40, 2, 0, 32, 4, 40, 2, 0, 65, 247, 148, 175, 175, 120, 108, 106, 65, 13, 119, 65, 177, 243, 221, 241, 121, 108, 54, 2, 0, 32, 0, 65, 12, 106, 34, 3, 32, 3, 40, 2, 0, 32, 4, 65, 4, 106, 40, 2, 0, 65, 247, 148, 175, 175, 120, 108, 106, 65, 13, 119, 65, 177, 243, 221, 241, 121, 108, 54, 2, 0, 32, 0, 65, 16, 106, 34, 3, 32, 3, 40, 2, 0, 32, 4, 65, 8, 106, 40, 2, 0, 65, 247, 148, 175, 175, 120, 108, 106, 65, 13, 119, 65, 177, 243, 221, 241, 121, 108, 54, 2, 0, 32, 0, 65, 20, 106, 34, 3, 32, 3, 40, 2, 0, 32, 4, 65, 12, 106, 40, 2, 0, 65, 247, 148, 175, 175, 120, 108, 106, 65, 13, 119, 65, 177, 243, 221, 241, 121, 108, 54, 2, 0, 32, 0, 65, 40, 106, 65, 0, 54, 2, 0, 32, 1, 32, 2, 106, 33, 1, 11, 32, 1, 32, 6, 65, 16, 107, 77, 4, 64, 32, 6, 65, 16, 107, 33, 8, 32, 0, 65, 8, 106, 40, 2, 0, 33, 2, 32, 0, 65, 12, 106, 40, 2, 0, 33, 3, 32, 0, 65, 16, 106, 40, 2, 0, 33, 5, 32, 0, 65, 20, 106, 40, 2, 0, 33, 7, 3, 64, 32, 2, 32, 1, 40, 2, 0, 65, 247, 148, 175, 175, 120, 108, 106, 65, 13, 119, 65, 177, 243, 221, 241, 121, 108, 33, 2, 32, 3, 32, 1, 65, 4, 106, 34, 1, 40, 2, 0, 65, 247, 148, 175, 175, 120, 108, 106, 65, 13, 119, 65, 177, 243, 221, 241, 121, 108, 33, 3, 32, 5, 32, 1, 65, 4, 106, 34, 1, 40, 2, 0, 65, 247, 148, 175, 175, 120, 108, 106, 65, 13, 119, 65, 177, 243, 221, 241, 121, 108, 33, 5, 32, 7, 32, 1, 65, 4, 106, 34, 1, 40, 2, 0, 65, 247, 148, 175, 175, 120, 108, 106, 65, 13, 119, 65, 177, 243, 221, 241, 121, 108, 33, 7, 32, 8, 32, 1, 65, 4, 106, 34, 1, 79, 13, 0, 11, 32, 0, 65, 8, 106, 32, 2, 54, 2, 0, 32, 0, 65, 12, 106, 32, 3, 54, 2, 0, 32, 0, 65, 16, 106, 32, 5, 54, 2, 0, 32, 0, 65, 20, 106, 32, 7, 54, 2, 0, 11, 32, 1, 32, 6, 73, 4, 64, 32, 4, 32, 1, 32, 6, 32, 1, 107, 34, 1, 252, 10, 0, 0, 32, 0, 65, 40, 106, 32, 1, 54, 2, 0, 11, 11, 97, 1, 1, 127, 32, 0, 65, 16, 106, 40, 2, 0, 33, 1, 32, 0, 65, 4, 106, 40, 2, 0, 4, 127, 32, 1, 65, 12, 119, 32, 0, 65, 20, 106, 40, 2, 0, 65, 18, 119, 106, 32, 0, 65, 12, 106, 40, 2, 0, 65, 7, 119, 106, 32, 0, 65, 8, 106, 40, 2, 0, 65, 1, 119, 106, 5, 32, 1, 65, 177, 207, 217, 178, 1, 106, 11, 32, 0, 40, 2, 0, 106, 32, 0, 65, 24, 106, 32, 0, 65, 40, 106, 40, 2, 0, 16, 1, 11, 255, 3, 2, 3, 126, 1, 127, 32, 0, 32, 1, 106, 33, 6, 32, 1, 65, 32, 79, 4, 126, 32, 6, 65, 32, 107, 33, 6, 32, 2, 66, 214, 235, 130, 238, 234, 253, 137, 245, 224, 0, 124, 33, 3, 32, 2, 66, 177, 169, 172, 193, 173, 184, 212, 166, 61, 125, 33, 4, 32, 2, 66, 249, 234, 208, 208, 231, 201, 161, 228, 225, 0, 124, 33, 5, 3, 64, 32, 3, 32, 0, 41, 3, 0, 66, 207, 214, 211, 190, 210, 199, 171, 217, 66, 126, 124, 66, 31, 137, 66, 135, 149, 175, 175, 152, 182, 222, 155, 158, 127, 126, 33, 3, 32, 4, 32, 0, 65, 8, 106, 34, 0, 41, 3, 0, 66, 207, 214, 211, 190, 210, 199, 171, 217, 66, 126, 124, 66, 31, 137, 66, 135, 149, 175, 175, 152, 182, 222, 155, 158, 127, 126, 33, 4, 32, 2, 32, 0, 65, 8, 106, 34, 0, 41, 3, 0, 66, 207, 214, 211, 190, 210, 199, 171, 217, 66, 126, 124, 66, 31, 137, 66, 135, 149, 175, 175, 152, 182, 222, 155, 158, 127, 126, 33, 2, 32, 5, 32, 0, 65, 8, 106, 34, 0, 41, 3, 0, 66, 207, 214, 211, 190, 210, 199, 171, 217, 66, 126, 124, 66, 31, 137, 66, 135, 149, 175, 175, 152, 182, 222, 155, 158, 127, 126, 33, 5, 32, 6, 32, 0, 65, 8, 106, 34, 0, 79, 13, 0, 11, 32, 2, 66, 12, 137, 32, 5, 66, 18, 137, 124, 32, 4, 66, 7, 137, 124, 32, 3, 66, 1, 137, 124, 32, 3, 66, 207, 214, 211, 190, 210, 199, 171, 217, 66, 126, 66, 31, 137, 66, 135, 149, 175, 175, 152, 182, 222, 155, 158, 127, 126, 133, 66, 135, 149, 175, 175, 152, 182, 222, 155, 158, 127, 126, 66, 157, 163, 181, 234, 131, 177, 141, 138, 250, 0, 125, 32, 4, 66, 207, 214, 211, 190, 210, 199, 171, 217, 66, 126, 66, 31, 137, 66, 135, 149, 175, 175, 152, 182, 222, 155, 158, 127, 126, 133, 66, 135, 149, 175, 175, 152, 182, 222, 155, 158, 127, 126, 66, 157, 163, 181, 234, 131, 177, 141, 138, 250, 0, 125, 32, 2, 66, 207, 214, 211, 190, 210, 199, 171, 217, 66, 126, 66, 31, 137, 66, 135, 149, 175, 175, 152, 182, 222, 155, 158, 127, 126, 133, 66, 135, 149, 175, 175, 152, 182, 222, 155, 158, 127, 126, 66, 157, 163, 181, 234, 131, 177, 141, 138, 250, 0, 125, 32, 5, 66, 207, 214, 211, 190, 210, 199, 171, 217, 66, 126, 66, 31, 137, 66, 135, 149, 175, 175, 152, 182, 222, 155, 158, 127, 126, 133, 66, 135, 149, 175, 175, 152, 182, 222, 155, 158, 127, 126, 66, 157, 163, 181, 234, 131, 177, 141, 138, 250, 0, 125, 5, 32, 2, 66, 197, 207, 217, 178, 241, 229, 186, 234, 39, 124, 11, 32, 1, 173, 124, 32, 0, 32, 1, 65, 31, 113, 16, 6, 11, 134, 2, 0, 32, 1, 32, 2, 106, 33, 2, 3, 64, 32, 2, 32, 1, 65, 8, 106, 79, 4, 64, 32, 1, 41, 3, 0, 66, 207, 214, 211, 190, 210, 199, 171, 217, 66, 126, 66, 31, 137, 66, 135, 149, 175, 175, 152, 182, 222, 155, 158, 127, 126, 32, 0, 133, 66, 27, 137, 66, 135, 149, 175, 175, 152, 182, 222, 155, 158, 127, 126, 66, 157, 163, 181, 234, 131, 177, 141, 138, 250, 0, 125, 33, 0, 32, 1, 65, 8, 106, 33, 1, 12, 1, 11, 11, 32, 1, 65, 4, 106, 32, 2, 77, 4, 64, 32, 0, 32, 1, 53, 2, 0, 66, 135, 149, 175, 175, 152, 182, 222, 155, 158, 127, 126, 133, 66, 23, 137, 66, 207, 214, 211, 190, 210, 199, 171, 217, 66, 126, 66, 249, 243, 221, 241, 153, 246, 153, 171, 22, 124, 33, 0, 32, 1, 65, 4, 106, 33, 1, 11, 3, 64, 32, 1, 32, 2, 73, 4, 64, 32, 0, 32, 1, 49, 0, 0, 66, 197, 207, 217, 178, 241, 229, 186, 234, 39, 126, 133, 66, 11, 137, 66, 135, 149, 175, 175, 152, 182, 222, 155, 158, 127, 126, 33, 0, 32, 1, 65, 1, 106, 33, 1, 12, 1, 11, 11, 32, 0, 32, 0, 66, 33, 136, 133, 66, 207, 214, 211, 190, 210, 199, 171, 217, 66, 126, 34, 0, 32, 0, 66, 29, 136, 133, 66, 249, 243, 221, 241, 153, 246, 153, 171, 22, 126, 34, 0, 32, 0, 66, 32, 136, 133, 11, 77, 0, 32, 0, 65, 8, 106, 32, 1, 66, 214, 235, 130, 238, 234, 253, 137, 245, 224, 0, 124, 55, 3, 0, 32, 0, 65, 16, 106, 32, 1, 66, 177, 169, 172, 193, 173, 184, 212, 166, 61, 125, 55, 3, 0, 32, 0, 65, 24, 106, 32, 1, 55, 3, 0, 32, 0, 65, 32, 106, 32, 1, 66, 249, 234, 208, 208, 231, 201, 161, 228, 225, 0, 124, 55, 3, 0, 11, 244, 4, 2, 3, 127, 4, 126, 32, 1, 32, 2, 106, 33, 5, 32, 0, 65, 40, 106, 33, 4, 32, 0, 65, 200, 0, 106, 40, 2, 0, 33, 3, 32, 0, 32, 0, 41, 3, 0, 32, 2, 173, 124, 55, 3, 0, 32, 2, 32, 3, 106, 65, 32, 73, 4, 64, 32, 3, 32, 4, 106, 32, 1, 32, 2, 252, 10, 0, 0, 32, 0, 65, 200, 0, 106, 32, 2, 32, 3, 106, 54, 2, 0, 15, 11, 32, 3, 4, 64, 32, 3, 32, 4, 106, 32, 1, 65, 32, 32, 3, 107, 34, 2, 252, 10, 0, 0, 32, 0, 65, 8, 106, 34, 3, 32, 3, 41, 3, 0, 32, 4, 41, 3, 0, 66, 207, 214, 211, 190, 210, 199, 171, 217, 66, 126, 124, 66, 31, 137, 66, 135, 149, 175, 175, 152, 182, 222, 155, 158, 127, 126, 55, 3, 0, 32, 0, 65, 16, 106, 34, 3, 32, 3, 41, 3, 0, 32, 4, 65, 8, 106, 41, 3, 0, 66, 207, 214, 211, 190, 210, 199, 171, 217, 66, 126, 124, 66, 31, 137, 66, 135, 149, 175, 175, 152, 182, 222, 155, 158, 127, 126, 55, 3, 0, 32, 0, 65, 24, 106, 34, 3, 32, 3, 41, 3, 0, 32, 4, 65, 16, 106, 41, 3, 0, 66, 207, 214, 211, 190, 210, 199, 171, 217, 66, 126, 124, 66, 31, 137, 66, 135, 149, 175, 175, 152, 182, 222, 155, 158, 127, 126, 55, 3, 0, 32, 0, 65, 32, 106, 34, 3, 32, 3, 41, 3, 0, 32, 4, 65, 24, 106, 41, 3, 0, 66, 207, 214, 211, 190, 210, 199, 171, 217, 66, 126, 124, 66, 31, 137, 66, 135, 149, 175, 175, 152, 182, 222, 155, 158, 127, 126, 55, 3, 0, 32, 0, 65, 200, 0, 106, 65, 0, 54, 2, 0, 32, 1, 32, 2, 106, 33, 1, 11, 32, 1, 65, 32, 106, 32, 5, 77, 4, 64, 32, 5, 65, 32, 107, 33, 2, 32, 0, 65, 8, 106, 41, 3, 0, 33, 6, 32, 0, 65, 16, 106, 41, 3, 0, 33, 7, 32, 0, 65, 24, 106, 41, 3, 0, 33, 8, 32, 0, 65, 32, 106, 41, 3, 0, 33, 9, 3, 64, 32, 6, 32, 1, 41, 3, 0, 66, 207, 214, 211, 190, 210, 199, 171, 217, 66, 126, 124, 66, 31, 137, 66, 135, 149, 175, 175, 152, 182, 222, 155, 158, 127, 126, 33, 6, 32, 7, 32, 1, 65, 8, 106, 34, 1, 41, 3, 0, 66, 207, 214, 211, 190, 210, 199, 171, 217, 66, 126, 124, 66, 31, 137, 66, 135, 149, 175, 175, 152, 182, 222, 155, 158, 127, 126, 33, 7, 32, 8, 32, 1, 65, 8, 106, 34, 1, 41, 3, 0, 66, 207, 214, 211, 190, 210, 199, 171, 217, 66, 126, 124, 66, 31, 137, 66, 135, 149, 175, 175, 152, 182, 222, 155, 158, 127, 126, 33, 8, 32, 9, 32, 1, 65, 8, 106, 34, 1, 41, 3, 0, 66, 207, 214, 211, 190, 210, 199, 171, 217, 66, 126, 124, 66, 31, 137, 66, 135, 149, 175, 175, 152, 182, 222, 155, 158, 127, 126, 33, 9, 32, 2, 32, 1, 65, 8, 106, 34, 1, 79, 13, 0, 11, 32, 0, 65, 8, 106, 32, 6, 55, 3, 0, 32, 0, 65, 16, 106, 32, 7, 55, 3, 0, 32, 0, 65, 24, 106, 32, 8, 55, 3, 0, 32, 0, 65, 32, 106, 32, 9, 55, 3, 0, 11, 32, 1, 32, 5, 73, 4, 64, 32, 4, 32, 1, 32, 5, 32, 1, 107, 34, 1, 252, 10, 0, 0, 32, 0, 65, 200, 0, 106, 32, 1, 54, 2, 0, 11, 11, 188, 2, 1, 5, 126, 32, 0, 65, 24, 106, 41, 3, 0, 33, 1, 32, 0, 41, 3, 0, 34, 2, 66, 32, 90, 4, 126, 32, 0, 65, 8, 106, 41, 3, 0, 34, 3, 66, 1, 137, 32, 0, 65, 16, 106, 41, 3, 0, 34, 4, 66, 7, 137, 124, 32, 1, 66, 12, 137, 32, 0, 65, 32, 106, 41, 3, 0, 34, 5, 66, 18, 137, 124, 124, 32, 3, 66, 207, 214, 211, 190, 210, 199, 171, 217, 66, 126, 66, 31, 137, 66, 135, 149, 175, 175, 152, 182, 222, 155, 158, 127, 126, 133, 66, 135, 149, 175, 175, 152, 182, 222, 155, 158, 127, 126, 66, 157, 163, 181, 234, 131, 177, 141, 138, 250, 0, 125, 32, 4, 66, 207, 214, 211, 190, 210, 199, 171, 217, 66, 126, 66, 31, 137, 66, 135, 149, 175, 175, 152, 182, 222, 155, 158, 127, 126, 133, 66, 135, 149, 175, 175, 152, 182, 222, 155, 158, 127, 126, 66, 157, 163, 181, 234, 131, 177, 141, 138, 250, 0, 125, 32, 1, 66, 207, 214, 211, 190, 210, 199, 171, 217, 66, 126, 66, 31, 137, 66, 135, 149, 175, 175, 152, 182, 222, 155, 158, 127, 126, 133, 66, 135, 149, 175, 175, 152, 182, 222, 155, 158, 127, 126, 66, 157, 163, 181, 234, 131, 177, 141, 138, 250, 0, 125, 32, 5, 66, 207, 214, 211, 190, 210, 199, 171, 217, 66, 126, 66, 31, 137, 66, 135, 149, 175, 175, 152, 182, 222, 155, 158, 127, 126, 133, 66, 135, 149, 175, 175, 152, 182, 222, 155, 158, 127, 126, 66, 157, 163, 181, 234, 131, 177, 141, 138, 250, 0, 125, 5, 32, 1, 66, 197, 207, 217, 178, 241, 229, 186, 234, 39, 124, 11, 32, 2, 124, 32, 0, 65, 40, 106, 32, 2, 66, 31, 131, 167, 16, 6, 11]);
|
|
@@ -1039,7 +1040,7 @@ function imageSize(input) {
|
|
|
1039
1040
|
throw new TypeError(`unsupported file type: ${type}`);
|
|
1040
1041
|
}
|
|
1041
1042
|
|
|
1042
|
-
// ../memory/dist/chunk-
|
|
1043
|
+
// ../memory/dist/chunk-7A3UGAXY.js
|
|
1043
1044
|
function formatRelativeTime(date, currentDate) {
|
|
1044
1045
|
const diffMs = currentDate.getTime() - date.getTime();
|
|
1045
1046
|
const diffDays = Math.floor(diffMs / (1e3 * 60 * 60 * 24));
|
|
@@ -1336,6 +1337,51 @@ function createThreadUpdateMarker(params) {
|
|
|
1336
1337
|
}
|
|
1337
1338
|
};
|
|
1338
1339
|
}
|
|
1340
|
+
function isTieredModelTarget(model) {
|
|
1341
|
+
if (typeof model === "string") {
|
|
1342
|
+
return true;
|
|
1343
|
+
}
|
|
1344
|
+
if (!model || typeof model !== "object") {
|
|
1345
|
+
return false;
|
|
1346
|
+
}
|
|
1347
|
+
return "modelId" in model || "id" in model || "providerId" in model || "provider" in model || "doGenerate" in model && "doStream" in model;
|
|
1348
|
+
}
|
|
1349
|
+
function normalizeThresholds(config) {
|
|
1350
|
+
const entries = Object.entries(config.upTo);
|
|
1351
|
+
if (entries.length === 0) {
|
|
1352
|
+
throw new Error('ModelByInputTokens requires at least one threshold in "upTo"');
|
|
1353
|
+
}
|
|
1354
|
+
for (const [limitStr, model] of entries) {
|
|
1355
|
+
const limit = Number(limitStr);
|
|
1356
|
+
if (!Number.isFinite(limit) || limit <= 0) {
|
|
1357
|
+
throw new Error(`ModelByInputTokens threshold keys must be positive numbers. Got: ${limitStr}`);
|
|
1358
|
+
}
|
|
1359
|
+
if (!isTieredModelTarget(model)) {
|
|
1360
|
+
throw new Error(`ModelByInputTokens requires a valid model target for threshold ${limitStr}`);
|
|
1361
|
+
}
|
|
1362
|
+
}
|
|
1363
|
+
return entries.map(([limitStr, model]) => ({ limit: Number(limitStr), model })).sort((a, b) => a.limit - b.limit);
|
|
1364
|
+
}
|
|
1365
|
+
var ModelByInputTokens = class {
|
|
1366
|
+
thresholds;
|
|
1367
|
+
constructor(config) {
|
|
1368
|
+
this.thresholds = normalizeThresholds(config);
|
|
1369
|
+
}
|
|
1370
|
+
resolve(inputTokens) {
|
|
1371
|
+
for (const { limit, model } of this.thresholds) {
|
|
1372
|
+
if (inputTokens <= limit) {
|
|
1373
|
+
return model;
|
|
1374
|
+
}
|
|
1375
|
+
}
|
|
1376
|
+
const maxLimit = this.thresholds[this.thresholds.length - 1].limit;
|
|
1377
|
+
throw new Error(
|
|
1378
|
+
`ModelByInputTokens: input token count (${inputTokens}) exceeds the largest configured threshold (${maxLimit}). Please configure a higher threshold or use a larger model.`
|
|
1379
|
+
);
|
|
1380
|
+
}
|
|
1381
|
+
getThresholds() {
|
|
1382
|
+
return this.thresholds.map((t2) => t2.limit);
|
|
1383
|
+
}
|
|
1384
|
+
};
|
|
1339
1385
|
var OBSERVATION_GROUP_PATTERN = /<observation-group\s([^>]*)>([\s\S]*?)<\/observation-group>/g;
|
|
1340
1386
|
var ATTRIBUTE_PATTERN = /([\w][\w-]*)="([^"]*)"/g;
|
|
1341
1387
|
var REFLECTION_GROUP_SPLIT_PATTERN = /^##\s+Group\s+/m;
|
|
@@ -4478,8 +4524,10 @@ var ObservationalMemory = class _ObservationalMemory {
|
|
|
4478
4524
|
onDebugEvent;
|
|
4479
4525
|
/** Internal Observer agent - created lazily */
|
|
4480
4526
|
observerAgent;
|
|
4527
|
+
observerAgentModel;
|
|
4481
4528
|
/** Internal Reflector agent - created lazily */
|
|
4482
4529
|
reflectorAgent;
|
|
4530
|
+
reflectorAgentModel;
|
|
4483
4531
|
shouldObscureThreadIds = false;
|
|
4484
4532
|
hasher = e();
|
|
4485
4533
|
threadIdCache = /* @__PURE__ */ new Map();
|
|
@@ -4786,7 +4834,15 @@ var ObservationalMemory = class _ObservationalMemory {
|
|
|
4786
4834
|
this.storage = config.storage;
|
|
4787
4835
|
this.scope = config.scope ?? "thread";
|
|
4788
4836
|
this.retrieval = this.scope === "thread" && (config.retrieval ?? OBSERVATIONAL_MEMORY_DEFAULTS.retrieval);
|
|
4789
|
-
const resolveModel = (m) =>
|
|
4837
|
+
const resolveModel = (m) => {
|
|
4838
|
+
if (m === "default") {
|
|
4839
|
+
return OBSERVATIONAL_MEMORY_DEFAULTS.observation.model;
|
|
4840
|
+
}
|
|
4841
|
+
if (m instanceof ModelByInputTokens) {
|
|
4842
|
+
return m;
|
|
4843
|
+
}
|
|
4844
|
+
return m;
|
|
4845
|
+
};
|
|
4790
4846
|
const observationModel = resolveModel(config.model) ?? resolveModel(config.observation?.model) ?? resolveModel(config.reflection?.model);
|
|
4791
4847
|
const reflectionModel = resolveModel(config.model) ?? resolveModel(config.reflection?.model) ?? resolveModel(config.observation?.model);
|
|
4792
4848
|
if (!observationModel || !reflectionModel) {
|
|
@@ -4803,7 +4859,9 @@ See https://mastra.ai/docs/memory/observational-memory#models for model recommen
|
|
|
4803
4859
|
const messageTokens = config.observation?.messageTokens ?? OBSERVATIONAL_MEMORY_DEFAULTS.observation.messageTokens;
|
|
4804
4860
|
const observationTokens = config.reflection?.observationTokens ?? OBSERVATIONAL_MEMORY_DEFAULTS.reflection.observationTokens;
|
|
4805
4861
|
const isSharedBudget = config.shareTokenBudget ?? false;
|
|
4806
|
-
const isDefaultModelSelection = (model) =>
|
|
4862
|
+
const isDefaultModelSelection = (model) => {
|
|
4863
|
+
return model === void 0 || model === "default";
|
|
4864
|
+
};
|
|
4807
4865
|
const observationSelectedModel = config.model ?? config.observation?.model ?? config.reflection?.model;
|
|
4808
4866
|
const reflectionSelectedModel = config.model ?? config.reflection?.model ?? config.observation?.model;
|
|
4809
4867
|
const observationDefaultMaxOutputTokens = config.observation?.modelSettings?.maxOutputTokens ?? (isDefaultModelSelection(observationSelectedModel) ? OBSERVATIONAL_MEMORY_DEFAULTS.observation.modelSettings.maxOutputTokens : void 0);
|
|
@@ -4906,6 +4964,15 @@ Async buffering is enabled by default \u2014 this opt-out is only needed when us
|
|
|
4906
4964
|
async waitForBuffering(threadId, resourceId, timeoutMs = 3e4) {
|
|
4907
4965
|
return _ObservationalMemory.awaitBuffering(threadId, resourceId, this.scope, timeoutMs);
|
|
4908
4966
|
}
|
|
4967
|
+
getConcreteModel(model, inputTokens) {
|
|
4968
|
+
if (model instanceof ModelByInputTokens) {
|
|
4969
|
+
if (inputTokens === void 0) {
|
|
4970
|
+
throw new Error("ModelByInputTokens requires inputTokens for resolution");
|
|
4971
|
+
}
|
|
4972
|
+
return model.resolve(inputTokens);
|
|
4973
|
+
}
|
|
4974
|
+
return model;
|
|
4975
|
+
}
|
|
4909
4976
|
getModelToResolve(model) {
|
|
4910
4977
|
if (Array.isArray(model)) {
|
|
4911
4978
|
return model[0]?.model ?? "unknown";
|
|
@@ -4944,7 +5011,11 @@ Async buffering is enabled by default \u2014 this opt-out is only needed when us
|
|
|
4944
5011
|
*/
|
|
4945
5012
|
async getCompressionStartLevel(requestContext) {
|
|
4946
5013
|
try {
|
|
4947
|
-
const
|
|
5014
|
+
const modelConfig = this.getConcreteModel(
|
|
5015
|
+
this.reflectionConfig.model,
|
|
5016
|
+
this.reflectionConfig.model instanceof ModelByInputTokens ? 1 : void 0
|
|
5017
|
+
);
|
|
5018
|
+
const resolved = await this.resolveModelContext(modelConfig, requestContext);
|
|
4948
5019
|
const modelId = resolved?.modelId ?? "";
|
|
4949
5020
|
if (modelId.includes("gemini-2.5-flash")) {
|
|
4950
5021
|
return 2;
|
|
@@ -4966,34 +5037,97 @@ Async buffering is enabled by default \u2014 this opt-out is only needed when us
|
|
|
4966
5037
|
runWithTokenCounterModelContext(modelContext, fn) {
|
|
4967
5038
|
return this.tokenCounter.runWithModelContext(modelContext, fn);
|
|
4968
5039
|
}
|
|
5040
|
+
async formatRoutingModel(model, requestContext) {
|
|
5041
|
+
if (!model) {
|
|
5042
|
+
return void 0;
|
|
5043
|
+
}
|
|
5044
|
+
if (typeof model === "string") {
|
|
5045
|
+
return model;
|
|
5046
|
+
}
|
|
5047
|
+
const resolvedModel = await this.resolveModelContext(model, requestContext);
|
|
5048
|
+
if (resolvedModel) {
|
|
5049
|
+
return this.formatModelName(resolvedModel);
|
|
5050
|
+
}
|
|
5051
|
+
const runtimeModel = this.getRuntimeModelContext(model);
|
|
5052
|
+
return runtimeModel ? this.formatModelName(runtimeModel) : void 0;
|
|
5053
|
+
}
|
|
5054
|
+
async withOmTracingSpan(options) {
|
|
5055
|
+
const { phase, inputTokens, resolvedModel, selectedThreshold, routingModel, requestContext, tracingContext, fn } = options;
|
|
5056
|
+
const selectedModel = await this.formatRoutingModel(resolvedModel, requestContext) ?? "(unknown)";
|
|
5057
|
+
if (!tracingContext) {
|
|
5058
|
+
return fn();
|
|
5059
|
+
}
|
|
5060
|
+
const span = getOrCreateSpan({
|
|
5061
|
+
type: SpanType.GENERIC,
|
|
5062
|
+
name: `om.${phase}`,
|
|
5063
|
+
attributes: {
|
|
5064
|
+
omPhase: phase,
|
|
5065
|
+
omInputTokens: inputTokens,
|
|
5066
|
+
omSelectedModel: selectedModel,
|
|
5067
|
+
...selectedThreshold !== void 0 ? { omSelectedThreshold: selectedThreshold } : {},
|
|
5068
|
+
...routingModel ? {
|
|
5069
|
+
omRoutingStrategy: "model-by-input-tokens",
|
|
5070
|
+
omRoutingThresholds: routingModel.getThresholds().join(",")
|
|
5071
|
+
} : {}
|
|
5072
|
+
},
|
|
5073
|
+
tracingContext,
|
|
5074
|
+
requestContext
|
|
5075
|
+
});
|
|
5076
|
+
if (!span) {
|
|
5077
|
+
return fn();
|
|
5078
|
+
}
|
|
5079
|
+
const observabilityContext = createObservabilityContext({ currentSpan: span });
|
|
5080
|
+
return span.executeInContext(() => fn(observabilityContext));
|
|
5081
|
+
}
|
|
4969
5082
|
/**
|
|
4970
5083
|
* Get the full config including resolved model names.
|
|
4971
5084
|
* This is async because it needs to resolve the model configs.
|
|
4972
5085
|
*/
|
|
4973
5086
|
async getResolvedConfig(requestContext) {
|
|
4974
|
-
const
|
|
5087
|
+
const resolveRouting = async (modelConfig) => {
|
|
4975
5088
|
try {
|
|
5089
|
+
if (modelConfig instanceof ModelByInputTokens) {
|
|
5090
|
+
const routing = await Promise.all(
|
|
5091
|
+
modelConfig.getThresholds().map(async (upTo) => {
|
|
5092
|
+
const resolvedModel = modelConfig.resolve(upTo);
|
|
5093
|
+
const resolved2 = await this.resolveModelContext(resolvedModel, requestContext);
|
|
5094
|
+
return {
|
|
5095
|
+
upTo,
|
|
5096
|
+
model: resolved2?.modelId ? this.formatModelName(resolved2) : "(unknown)"
|
|
5097
|
+
};
|
|
5098
|
+
})
|
|
5099
|
+
);
|
|
5100
|
+
return {
|
|
5101
|
+
model: routing[0]?.model ?? "(unknown)",
|
|
5102
|
+
routing
|
|
5103
|
+
};
|
|
5104
|
+
}
|
|
4976
5105
|
const resolved = await this.resolveModelContext(modelConfig, requestContext);
|
|
4977
|
-
return
|
|
5106
|
+
return {
|
|
5107
|
+
model: resolved?.modelId ? this.formatModelName(resolved) : "(unknown)"
|
|
5108
|
+
};
|
|
4978
5109
|
} catch (error) {
|
|
4979
5110
|
omError("[OM] Failed to resolve model config", error);
|
|
4980
|
-
return "(unknown)";
|
|
5111
|
+
return { model: "(unknown)" };
|
|
4981
5112
|
}
|
|
4982
5113
|
};
|
|
4983
|
-
const [
|
|
4984
|
-
|
|
4985
|
-
|
|
5114
|
+
const [observationResolved, reflectionResolved] = await Promise.all([
|
|
5115
|
+
resolveRouting(this.observationConfig.model),
|
|
5116
|
+
resolveRouting(this.reflectionConfig.model)
|
|
4986
5117
|
]);
|
|
4987
5118
|
return {
|
|
4988
5119
|
scope: this.scope,
|
|
5120
|
+
shareTokenBudget: this.observationConfig.shareTokenBudget,
|
|
4989
5121
|
observation: {
|
|
4990
5122
|
messageTokens: this.observationConfig.messageTokens,
|
|
4991
|
-
model:
|
|
4992
|
-
previousObserverTokens: this.observationConfig.previousObserverTokens
|
|
5123
|
+
model: observationResolved.model,
|
|
5124
|
+
previousObserverTokens: this.observationConfig.previousObserverTokens,
|
|
5125
|
+
routing: observationResolved.routing
|
|
4993
5126
|
},
|
|
4994
5127
|
reflection: {
|
|
4995
5128
|
observationTokens: this.reflectionConfig.observationTokens,
|
|
4996
|
-
model:
|
|
5129
|
+
model: reflectionResolved.model,
|
|
5130
|
+
routing: reflectionResolved.routing
|
|
4997
5131
|
}
|
|
4998
5132
|
};
|
|
4999
5133
|
}
|
|
@@ -5095,8 +5229,11 @@ Async buffering is enabled by default \u2014 this opt-out is only needed when us
|
|
|
5095
5229
|
/**
|
|
5096
5230
|
* Get or create the Observer agent
|
|
5097
5231
|
*/
|
|
5098
|
-
getObserverAgent() {
|
|
5099
|
-
if (
|
|
5232
|
+
getObserverAgent(model) {
|
|
5233
|
+
if (this.observerAgent && this.observerAgentModel === void 0) {
|
|
5234
|
+
return this.observerAgent;
|
|
5235
|
+
}
|
|
5236
|
+
if (!this.observerAgent || this.observerAgentModel !== model) {
|
|
5100
5237
|
const systemPrompt = buildObserverSystemPrompt(
|
|
5101
5238
|
false,
|
|
5102
5239
|
this.observationConfig.instruction,
|
|
@@ -5106,23 +5243,28 @@ Async buffering is enabled by default \u2014 this opt-out is only needed when us
|
|
|
5106
5243
|
id: "observational-memory-observer",
|
|
5107
5244
|
name: "Observer",
|
|
5108
5245
|
instructions: systemPrompt,
|
|
5109
|
-
model
|
|
5246
|
+
model
|
|
5110
5247
|
});
|
|
5248
|
+
this.observerAgentModel = model;
|
|
5111
5249
|
}
|
|
5112
5250
|
return this.observerAgent;
|
|
5113
5251
|
}
|
|
5114
5252
|
/**
|
|
5115
5253
|
* Get or create the Reflector agent
|
|
5116
5254
|
*/
|
|
5117
|
-
getReflectorAgent() {
|
|
5118
|
-
if (
|
|
5255
|
+
getReflectorAgent(model) {
|
|
5256
|
+
if (this.reflectorAgent && this.reflectorAgentModel === void 0) {
|
|
5257
|
+
return this.reflectorAgent;
|
|
5258
|
+
}
|
|
5259
|
+
if (!this.reflectorAgent || this.reflectorAgentModel !== model) {
|
|
5119
5260
|
const systemPrompt = buildReflectorSystemPrompt(this.reflectionConfig.instruction);
|
|
5120
5261
|
this.reflectorAgent = new Agent({
|
|
5121
5262
|
id: "observational-memory-reflector",
|
|
5122
5263
|
name: "Reflector",
|
|
5123
5264
|
instructions: systemPrompt,
|
|
5124
|
-
model
|
|
5265
|
+
model
|
|
5125
5266
|
});
|
|
5267
|
+
this.reflectorAgentModel = model;
|
|
5126
5268
|
}
|
|
5127
5269
|
return this.reflectorAgent;
|
|
5128
5270
|
}
|
|
@@ -5602,7 +5744,6 @@ ${unreflectedContent}` : bufferedReflection;
|
|
|
5602
5744
|
* Call the Observer agent to extract observations.
|
|
5603
5745
|
*/
|
|
5604
5746
|
async callObserver(existingObservations, messagesToObserve, abortSignal, options) {
|
|
5605
|
-
const agent = this.getObserverAgent();
|
|
5606
5747
|
const observerMessages = [
|
|
5607
5748
|
{
|
|
5608
5749
|
role: "user",
|
|
@@ -5617,18 +5758,35 @@ ${unreflectedContent}` : bufferedReflection;
|
|
|
5617
5758
|
},
|
|
5618
5759
|
buildObserverHistoryMessage(messagesToObserve)
|
|
5619
5760
|
];
|
|
5761
|
+
const inputTokens = this.tokenCounter.countMessages(messagesToObserve);
|
|
5762
|
+
const requestContext = options?.requestContext;
|
|
5763
|
+
const tracingContext = options?.tracingContext;
|
|
5764
|
+
const routingModel = this.observationConfig.model instanceof ModelByInputTokens ? this.observationConfig.model : void 0;
|
|
5765
|
+
const selectedThreshold = routingModel?.getThresholds().find((threshold) => inputTokens <= threshold);
|
|
5766
|
+
const resolvedModel = this.getConcreteModel(this.observationConfig.model, inputTokens);
|
|
5767
|
+
const agent = this.getObserverAgent(resolvedModel);
|
|
5620
5768
|
const doGenerate = async () => {
|
|
5621
|
-
const result2 = await this.
|
|
5622
|
-
|
|
5623
|
-
|
|
5624
|
-
|
|
5625
|
-
|
|
5626
|
-
|
|
5627
|
-
|
|
5628
|
-
|
|
5629
|
-
|
|
5630
|
-
|
|
5631
|
-
|
|
5769
|
+
const result2 = await this.withOmTracingSpan({
|
|
5770
|
+
phase: "observer",
|
|
5771
|
+
inputTokens,
|
|
5772
|
+
resolvedModel,
|
|
5773
|
+
selectedThreshold,
|
|
5774
|
+
routingModel,
|
|
5775
|
+
requestContext,
|
|
5776
|
+
tracingContext,
|
|
5777
|
+
fn: async (observabilityContext) => this.withAbortCheck(async () => {
|
|
5778
|
+
const streamResult = await agent.stream(observerMessages, {
|
|
5779
|
+
...observabilityContext,
|
|
5780
|
+
modelSettings: {
|
|
5781
|
+
...this.observationConfig.modelSettings
|
|
5782
|
+
},
|
|
5783
|
+
providerOptions: this.observationConfig.providerOptions,
|
|
5784
|
+
...abortSignal ? { abortSignal } : {},
|
|
5785
|
+
...requestContext ? { requestContext } : {}
|
|
5786
|
+
});
|
|
5787
|
+
return streamResult.getFullOutput();
|
|
5788
|
+
}, abortSignal)
|
|
5789
|
+
});
|
|
5632
5790
|
return result2;
|
|
5633
5791
|
};
|
|
5634
5792
|
let result = await doGenerate();
|
|
@@ -5661,18 +5819,12 @@ ${unreflectedContent}` : bufferedReflection;
|
|
|
5661
5819
|
* Returns per-thread results with observations, currentTask, and suggestedContinuation,
|
|
5662
5820
|
* plus the total usage for the batch.
|
|
5663
5821
|
*/
|
|
5664
|
-
async callMultiThreadObserver(existingObservations, messagesByThread, threadOrder, priorMetadataByThread, abortSignal, requestContext, wasTruncated) {
|
|
5822
|
+
async callMultiThreadObserver(existingObservations, messagesByThread, threadOrder, priorMetadataByThread, abortSignal, requestContext, wasTruncated, tracingContext) {
|
|
5665
5823
|
const systemPrompt = buildObserverSystemPrompt(
|
|
5666
5824
|
true,
|
|
5667
5825
|
this.observationConfig.instruction,
|
|
5668
5826
|
this.observationConfig.threadTitle
|
|
5669
5827
|
);
|
|
5670
|
-
const agent = new Agent({
|
|
5671
|
-
id: "multi-thread-observer",
|
|
5672
|
-
name: "multi-thread-observer",
|
|
5673
|
-
model: this.observationConfig.model,
|
|
5674
|
-
instructions: systemPrompt
|
|
5675
|
-
});
|
|
5676
5828
|
const observerMessages = [
|
|
5677
5829
|
{
|
|
5678
5830
|
role: "user",
|
|
@@ -5693,18 +5845,38 @@ ${unreflectedContent}` : bufferedReflection;
|
|
|
5693
5845
|
for (const msg of allMessages) {
|
|
5694
5846
|
this.observedMessageIds.add(msg.id);
|
|
5695
5847
|
}
|
|
5848
|
+
const inputTokens = this.tokenCounter.countMessages(allMessages);
|
|
5849
|
+
const routingModel = this.observationConfig.model instanceof ModelByInputTokens ? this.observationConfig.model : void 0;
|
|
5850
|
+
const selectedThreshold = routingModel?.getThresholds().find((threshold) => inputTokens <= threshold);
|
|
5851
|
+
const resolvedModel = this.getConcreteModel(this.observationConfig.model, inputTokens);
|
|
5852
|
+
const agent = new Agent({
|
|
5853
|
+
id: "multi-thread-observer",
|
|
5854
|
+
name: "multi-thread-observer",
|
|
5855
|
+
model: resolvedModel,
|
|
5856
|
+
instructions: systemPrompt
|
|
5857
|
+
});
|
|
5696
5858
|
const doGenerate = async () => {
|
|
5697
|
-
const result2 = await this.
|
|
5698
|
-
|
|
5699
|
-
|
|
5700
|
-
|
|
5701
|
-
|
|
5702
|
-
|
|
5703
|
-
|
|
5704
|
-
|
|
5705
|
-
|
|
5706
|
-
|
|
5707
|
-
|
|
5859
|
+
const result2 = await this.withOmTracingSpan({
|
|
5860
|
+
phase: "observer",
|
|
5861
|
+
inputTokens,
|
|
5862
|
+
resolvedModel,
|
|
5863
|
+
selectedThreshold,
|
|
5864
|
+
routingModel,
|
|
5865
|
+
requestContext,
|
|
5866
|
+
tracingContext,
|
|
5867
|
+
fn: async (observabilityContext) => this.withAbortCheck(async () => {
|
|
5868
|
+
const streamResult = await agent.stream(observerMessages, {
|
|
5869
|
+
...observabilityContext,
|
|
5870
|
+
modelSettings: {
|
|
5871
|
+
...this.observationConfig.modelSettings
|
|
5872
|
+
},
|
|
5873
|
+
providerOptions: this.observationConfig.providerOptions,
|
|
5874
|
+
...abortSignal ? { abortSignal } : {},
|
|
5875
|
+
...requestContext ? { requestContext } : {}
|
|
5876
|
+
});
|
|
5877
|
+
return streamResult.getFullOutput();
|
|
5878
|
+
}, abortSignal)
|
|
5879
|
+
});
|
|
5708
5880
|
return result2;
|
|
5709
5881
|
};
|
|
5710
5882
|
let result = await doGenerate();
|
|
@@ -5746,9 +5918,12 @@ ${unreflectedContent}` : bufferedReflection;
|
|
|
5746
5918
|
* Call the Reflector agent to condense observations.
|
|
5747
5919
|
* Includes compression validation and retry logic.
|
|
5748
5920
|
*/
|
|
5749
|
-
async callReflector(observations, manualPrompt, streamContext, observationTokensThreshold, abortSignal, skipContinuationHints, compressionStartLevel, requestContext) {
|
|
5750
|
-
const agent = this.getReflectorAgent();
|
|
5921
|
+
async callReflector(observations, manualPrompt, streamContext, observationTokensThreshold, abortSignal, skipContinuationHints, compressionStartLevel, requestContext, tracingContext) {
|
|
5751
5922
|
const originalTokens = this.tokenCounter.countObservations(observations);
|
|
5923
|
+
const routingModel = this.reflectionConfig.model instanceof ModelByInputTokens ? this.reflectionConfig.model : void 0;
|
|
5924
|
+
const selectedThreshold = routingModel?.getThresholds().find((threshold) => originalTokens <= threshold);
|
|
5925
|
+
const resolvedModel = this.getConcreteModel(this.reflectionConfig.model, originalTokens);
|
|
5926
|
+
const agent = this.getReflectorAgent(resolvedModel);
|
|
5752
5927
|
const targetThreshold = observationTokensThreshold ?? getMaxThreshold(this.reflectionConfig.observationTokens);
|
|
5753
5928
|
let totalUsage = { inputTokens: 0, outputTokens: 0, totalTokens: 0 };
|
|
5754
5929
|
const startLevel = compressionStartLevel ?? 0;
|
|
@@ -5765,37 +5940,47 @@ ${unreflectedContent}` : bufferedReflection;
|
|
|
5765
5940
|
`[OM:callReflector] ${isRetry ? `retry #${attemptNumber - 1}` : "first attempt"}: level=${currentLevel}, originalTokens=${originalTokens}, targetThreshold=${targetThreshold}, promptLen=${prompt.length}, skipContinuationHints=${skipContinuationHints}`
|
|
5766
5941
|
);
|
|
5767
5942
|
let chunkCount = 0;
|
|
5768
|
-
const result = await this.
|
|
5769
|
-
|
|
5770
|
-
|
|
5771
|
-
|
|
5772
|
-
|
|
5773
|
-
|
|
5774
|
-
|
|
5775
|
-
|
|
5776
|
-
|
|
5777
|
-
|
|
5778
|
-
|
|
5779
|
-
|
|
5780
|
-
|
|
5781
|
-
omDebug(`[OM:callReflector] chunk#${chunkCount}: type=${chunk.type}${preview}`);
|
|
5782
|
-
}
|
|
5783
|
-
},
|
|
5784
|
-
onFinish(event) {
|
|
5785
|
-
omDebug(
|
|
5786
|
-
`[OM:callReflector] onFinish: chunks=${chunkCount}, finishReason=${event.finishReason}, inputTokens=${event.usage?.inputTokens}, outputTokens=${event.usage?.outputTokens}, textLen=${event.text?.length}`
|
|
5787
|
-
);
|
|
5788
|
-
},
|
|
5789
|
-
onAbort(event) {
|
|
5790
|
-
omDebug(`[OM:callReflector] onAbort: chunks=${chunkCount}, reason=${event?.reason ?? "unknown"}`);
|
|
5943
|
+
const result = await this.withOmTracingSpan({
|
|
5944
|
+
phase: "reflector",
|
|
5945
|
+
inputTokens: originalTokens,
|
|
5946
|
+
resolvedModel,
|
|
5947
|
+
selectedThreshold,
|
|
5948
|
+
routingModel,
|
|
5949
|
+
requestContext,
|
|
5950
|
+
tracingContext,
|
|
5951
|
+
fn: async (observabilityContext) => this.withAbortCheck(async () => {
|
|
5952
|
+
const streamResult = await agent.stream(prompt, {
|
|
5953
|
+
...observabilityContext,
|
|
5954
|
+
modelSettings: {
|
|
5955
|
+
...this.reflectionConfig.modelSettings
|
|
5791
5956
|
},
|
|
5792
|
-
|
|
5793
|
-
|
|
5794
|
-
}
|
|
5795
|
-
|
|
5796
|
-
|
|
5797
|
-
|
|
5798
|
-
|
|
5957
|
+
providerOptions: this.reflectionConfig.providerOptions,
|
|
5958
|
+
...abortSignal ? { abortSignal } : {},
|
|
5959
|
+
...requestContext ? { requestContext } : {},
|
|
5960
|
+
...attemptNumber === 1 ? {
|
|
5961
|
+
onChunk(chunk) {
|
|
5962
|
+
chunkCount++;
|
|
5963
|
+
if (chunkCount === 1 || chunkCount % 50 === 0) {
|
|
5964
|
+
const preview = chunk.type === "text-delta" ? ` text="${chunk.textDelta?.slice(0, 80)}..."` : chunk.type === "tool-call" ? ` tool=${chunk.toolName}` : "";
|
|
5965
|
+
omDebug(`[OM:callReflector] chunk#${chunkCount}: type=${chunk.type}${preview}`);
|
|
5966
|
+
}
|
|
5967
|
+
},
|
|
5968
|
+
onFinish(event) {
|
|
5969
|
+
omDebug(
|
|
5970
|
+
`[OM:callReflector] onFinish: chunks=${chunkCount}, finishReason=${event.finishReason}, inputTokens=${event.usage?.inputTokens}, outputTokens=${event.usage?.outputTokens}, textLen=${event.text?.length}`
|
|
5971
|
+
);
|
|
5972
|
+
},
|
|
5973
|
+
onAbort(event) {
|
|
5974
|
+
omDebug(`[OM:callReflector] onAbort: chunks=${chunkCount}, reason=${event?.reason ?? "unknown"}`);
|
|
5975
|
+
},
|
|
5976
|
+
onError({ error }) {
|
|
5977
|
+
omError(`[OM:callReflector] onError after ${chunkCount} chunks`, error);
|
|
5978
|
+
}
|
|
5979
|
+
} : {}
|
|
5980
|
+
});
|
|
5981
|
+
return streamResult.getFullOutput();
|
|
5982
|
+
}, abortSignal)
|
|
5983
|
+
});
|
|
5799
5984
|
omDebug(
|
|
5800
5985
|
`[OM:callReflector] attempt #${attemptNumber} returned: textLen=${result.text?.length}, textPreview="${result.text?.slice(0, 120)}...", inputTokens=${result.usage?.inputTokens ?? result.totalUsage?.inputTokens}, outputTokens=${result.usage?.outputTokens ?? result.totalUsage?.outputTokens}`
|
|
5801
5986
|
);
|
|
@@ -6100,7 +6285,7 @@ ${suggestedResponse}
|
|
|
6100
6285
|
* Tries async activation first if enabled, then falls back to sync observation.
|
|
6101
6286
|
* Returns whether observation succeeded.
|
|
6102
6287
|
*/
|
|
6103
|
-
async handleThresholdReached(messageList, record, threadId, resourceId, threshold, lockKey, writer, abortSignal, abort, requestContext) {
|
|
6288
|
+
async handleThresholdReached(messageList, record, threadId, resourceId, threshold, lockKey, writer, abortSignal, abort, requestContext, tracingContext) {
|
|
6104
6289
|
let observationSucceeded = false;
|
|
6105
6290
|
let updatedRecord = record;
|
|
6106
6291
|
let activatedMessageIds;
|
|
@@ -6199,7 +6384,8 @@ ${suggestedResponse}
|
|
|
6199
6384
|
currentThreadMessages: freshUnobservedMessages,
|
|
6200
6385
|
writer,
|
|
6201
6386
|
abortSignal,
|
|
6202
|
-
requestContext
|
|
6387
|
+
requestContext,
|
|
6388
|
+
tracingContext
|
|
6203
6389
|
});
|
|
6204
6390
|
} else {
|
|
6205
6391
|
await this.doSynchronousObservation({
|
|
@@ -6208,7 +6394,8 @@ ${suggestedResponse}
|
|
|
6208
6394
|
unobservedMessages: freshUnobservedMessages,
|
|
6209
6395
|
writer,
|
|
6210
6396
|
abortSignal,
|
|
6211
|
-
requestContext
|
|
6397
|
+
requestContext,
|
|
6398
|
+
tracingContext
|
|
6212
6399
|
});
|
|
6213
6400
|
}
|
|
6214
6401
|
updatedRecord = await this.getOrCreateRecord(threadId, resourceId);
|
|
@@ -6478,7 +6665,17 @@ ${suggestedResponse}
|
|
|
6478
6665
|
* 5. Filter out already-observed messages
|
|
6479
6666
|
*/
|
|
6480
6667
|
async processInputStep(args) {
|
|
6481
|
-
const {
|
|
6668
|
+
const {
|
|
6669
|
+
messageList,
|
|
6670
|
+
requestContext,
|
|
6671
|
+
tracingContext,
|
|
6672
|
+
stepNumber,
|
|
6673
|
+
state: _state,
|
|
6674
|
+
writer,
|
|
6675
|
+
abortSignal,
|
|
6676
|
+
abort,
|
|
6677
|
+
model
|
|
6678
|
+
} = args;
|
|
6482
6679
|
const state = _state ?? {};
|
|
6483
6680
|
omDebug(
|
|
6484
6681
|
`[OM:processInputStep:ENTER] step=${stepNumber}, hasMastraMemory=${!!requestContext?.get("MastraMemory")}, hasMemoryInfo=${!!messageList?.serialize()?.memoryInfo?.threadId}`
|
|
@@ -6600,7 +6797,8 @@ ${suggestedResponse}
|
|
|
6600
6797
|
threadId,
|
|
6601
6798
|
writer,
|
|
6602
6799
|
messageList,
|
|
6603
|
-
requestContext
|
|
6800
|
+
requestContext,
|
|
6801
|
+
tracingContext
|
|
6604
6802
|
});
|
|
6605
6803
|
record = await this.getOrCreateRecord(threadId, resourceId);
|
|
6606
6804
|
}
|
|
@@ -6617,7 +6815,8 @@ ${suggestedResponse}
|
|
|
6617
6815
|
threadId,
|
|
6618
6816
|
writer,
|
|
6619
6817
|
messageList,
|
|
6620
|
-
requestContext
|
|
6818
|
+
requestContext,
|
|
6819
|
+
tracingContext
|
|
6621
6820
|
});
|
|
6622
6821
|
record = await this.getOrCreateRecord(threadId, resourceId);
|
|
6623
6822
|
} else if (this.isAsyncReflectionEnabled()) {
|
|
@@ -6673,7 +6872,8 @@ ${suggestedResponse}
|
|
|
6673
6872
|
lockKey,
|
|
6674
6873
|
writer,
|
|
6675
6874
|
unbufferedPendingTokens,
|
|
6676
|
-
requestContext
|
|
6875
|
+
requestContext,
|
|
6876
|
+
tracingContext
|
|
6677
6877
|
);
|
|
6678
6878
|
}
|
|
6679
6879
|
} else if (this.isAsyncObservationEnabled()) {
|
|
@@ -6689,7 +6889,8 @@ ${suggestedResponse}
|
|
|
6689
6889
|
lockKey,
|
|
6690
6890
|
writer,
|
|
6691
6891
|
unbufferedPendingTokens,
|
|
6692
|
-
requestContext
|
|
6892
|
+
requestContext,
|
|
6893
|
+
tracingContext
|
|
6693
6894
|
);
|
|
6694
6895
|
}
|
|
6695
6896
|
}
|
|
@@ -6708,7 +6909,8 @@ ${suggestedResponse}
|
|
|
6708
6909
|
writer,
|
|
6709
6910
|
abortSignal,
|
|
6710
6911
|
abort,
|
|
6711
|
-
requestContext
|
|
6912
|
+
requestContext,
|
|
6913
|
+
tracingContext
|
|
6712
6914
|
);
|
|
6713
6915
|
if (observationSucceeded) {
|
|
6714
6916
|
const observedIds = activatedMessageIds?.length ? activatedMessageIds : Array.isArray(updatedRecord.observedMessageIds) ? updatedRecord.observedMessageIds : void 0;
|
|
@@ -7117,7 +7319,16 @@ ${threadClose}`;
|
|
|
7117
7319
|
* Do synchronous observation (fallback when no buffering)
|
|
7118
7320
|
*/
|
|
7119
7321
|
async doSynchronousObservation(opts) {
|
|
7120
|
-
const {
|
|
7322
|
+
const {
|
|
7323
|
+
record,
|
|
7324
|
+
threadId,
|
|
7325
|
+
unobservedMessages,
|
|
7326
|
+
writer,
|
|
7327
|
+
abortSignal,
|
|
7328
|
+
reflectionHooks,
|
|
7329
|
+
requestContext,
|
|
7330
|
+
tracingContext
|
|
7331
|
+
} = opts;
|
|
7121
7332
|
this.emitDebugEvent({
|
|
7122
7333
|
type: "observation_triggered",
|
|
7123
7334
|
timestamp: /* @__PURE__ */ new Date(),
|
|
@@ -7176,6 +7387,7 @@ ${threadClose}`;
|
|
|
7176
7387
|
const threadOMMetadata = getThreadOMMetadata(thread?.metadata);
|
|
7177
7388
|
const result = await this.callObserver(observerContext, messagesToObserve, abortSignal, {
|
|
7178
7389
|
requestContext,
|
|
7390
|
+
tracingContext,
|
|
7179
7391
|
priorCurrentTask: threadOMMetadata?.currentTask,
|
|
7180
7392
|
priorSuggestedResponse: threadOMMetadata?.suggestedResponse,
|
|
7181
7393
|
priorThreadTitle: thread?.title,
|
|
@@ -7283,7 +7495,8 @@ ${threadClose}`;
|
|
|
7283
7495
|
writer,
|
|
7284
7496
|
abortSignal,
|
|
7285
7497
|
reflectionHooks,
|
|
7286
|
-
requestContext
|
|
7498
|
+
requestContext,
|
|
7499
|
+
tracingContext
|
|
7287
7500
|
});
|
|
7288
7501
|
} catch (error) {
|
|
7289
7502
|
if (lastMessage?.id) {
|
|
@@ -7301,10 +7514,7 @@ ${threadClose}`;
|
|
|
7301
7514
|
});
|
|
7302
7515
|
}
|
|
7303
7516
|
}
|
|
7304
|
-
|
|
7305
|
-
throw error;
|
|
7306
|
-
}
|
|
7307
|
-
omError("[OM] Observation failed", error);
|
|
7517
|
+
throw error;
|
|
7308
7518
|
} finally {
|
|
7309
7519
|
await this.storage.setObservingFlag(record.id, false);
|
|
7310
7520
|
unregisterOp(record.id, "observing");
|
|
@@ -7324,7 +7534,7 @@ ${threadClose}`;
|
|
|
7324
7534
|
* @param lockKey - Lock key for this scope
|
|
7325
7535
|
* @param writer - Optional stream writer for emitting buffering markers
|
|
7326
7536
|
*/
|
|
7327
|
-
async startAsyncBufferedObservation(record, threadId, unobservedMessages, lockKey, writer, contextWindowTokens, requestContext) {
|
|
7537
|
+
async startAsyncBufferedObservation(record, threadId, unobservedMessages, lockKey, writer, contextWindowTokens, requestContext, tracingContext) {
|
|
7328
7538
|
const bufferKey = this.getObservationBufferKey(lockKey);
|
|
7329
7539
|
const currentTokens = contextWindowTokens ?? await this.tokenCounter.countMessagesAsync(unobservedMessages) + (record.pendingMessageTokens ?? 0);
|
|
7330
7540
|
_ObservationalMemory.lastBufferedBoundary.set(bufferKey, currentTokens);
|
|
@@ -7338,7 +7548,8 @@ ${threadClose}`;
|
|
|
7338
7548
|
unobservedMessages,
|
|
7339
7549
|
bufferKey,
|
|
7340
7550
|
writer,
|
|
7341
|
-
requestContext
|
|
7551
|
+
requestContext,
|
|
7552
|
+
tracingContext
|
|
7342
7553
|
).finally(() => {
|
|
7343
7554
|
_ObservationalMemory.asyncBufferingOps.delete(bufferKey);
|
|
7344
7555
|
unregisterOp(record.id, "bufferingObservation");
|
|
@@ -7352,7 +7563,7 @@ ${threadClose}`;
|
|
|
7352
7563
|
* Internal method that waits for existing buffering operation and then runs new buffering.
|
|
7353
7564
|
* This implements the mutex-wait behavior.
|
|
7354
7565
|
*/
|
|
7355
|
-
async runAsyncBufferedObservation(record, threadId, unobservedMessages, bufferKey, writer, requestContext) {
|
|
7566
|
+
async runAsyncBufferedObservation(record, threadId, unobservedMessages, bufferKey, writer, requestContext, tracingContext) {
|
|
7356
7567
|
const existingOp = _ObservationalMemory.asyncBufferingOps.get(bufferKey);
|
|
7357
7568
|
if (existingOp) {
|
|
7358
7569
|
try {
|
|
@@ -7432,7 +7643,8 @@ ${threadClose}`;
|
|
|
7432
7643
|
cycleId,
|
|
7433
7644
|
startedAt,
|
|
7434
7645
|
writer,
|
|
7435
|
-
requestContext
|
|
7646
|
+
requestContext,
|
|
7647
|
+
tracingContext
|
|
7436
7648
|
);
|
|
7437
7649
|
const maxTs = this.getMaxMessageTimestamp(messagesToBuffer);
|
|
7438
7650
|
const cursor = new Date(maxTs.getTime() + 1);
|
|
@@ -7462,7 +7674,7 @@ ${threadClose}`;
|
|
|
7462
7674
|
* The observer sees: active observations + existing buffered observations + message history
|
|
7463
7675
|
* (excluding already-buffered messages).
|
|
7464
7676
|
*/
|
|
7465
|
-
async doAsyncBufferedObservation(record, threadId, messagesToBuffer, cycleId, startedAt, writer, requestContext) {
|
|
7677
|
+
async doAsyncBufferedObservation(record, threadId, messagesToBuffer, cycleId, startedAt, writer, requestContext, tracingContext) {
|
|
7466
7678
|
const bufferedChunks = this.getBufferedChunks(record);
|
|
7467
7679
|
const bufferedChunksText = bufferedChunks.map((c) => c.observations).join("\n\n");
|
|
7468
7680
|
const combinedObservations = this.combineObservationsForBuffering(record.activeObservations, bufferedChunksText);
|
|
@@ -7477,6 +7689,7 @@ ${threadClose}`;
|
|
|
7477
7689
|
{
|
|
7478
7690
|
skipContinuationHints: true,
|
|
7479
7691
|
requestContext,
|
|
7692
|
+
tracingContext,
|
|
7480
7693
|
priorCurrentTask: threadOMMetadata?.currentTask,
|
|
7481
7694
|
priorSuggestedResponse: threadOMMetadata?.suggestedResponse,
|
|
7482
7695
|
priorThreadTitle: thread?.title,
|
|
@@ -7917,7 +8130,8 @@ ${unreflectedContent}` : freshRecord.bufferedReflection;
|
|
|
7917
8130
|
writer,
|
|
7918
8131
|
abortSignal,
|
|
7919
8132
|
reflectionHooks,
|
|
7920
|
-
requestContext
|
|
8133
|
+
requestContext,
|
|
8134
|
+
tracingContext
|
|
7921
8135
|
} = opts;
|
|
7922
8136
|
const { threads: allThreads } = await this.storage.listThreads({ filter: { resourceId } });
|
|
7923
8137
|
const threadMetadataMap = /* @__PURE__ */ new Map();
|
|
@@ -8095,7 +8309,8 @@ ${unreflectedContent}` : freshRecord.bufferedReflection;
|
|
|
8095
8309
|
batchPriorMetadata,
|
|
8096
8310
|
abortSignal,
|
|
8097
8311
|
requestContext,
|
|
8098
|
-
wasTruncated
|
|
8312
|
+
wasTruncated,
|
|
8313
|
+
tracingContext
|
|
8099
8314
|
);
|
|
8100
8315
|
return batchResult;
|
|
8101
8316
|
});
|
|
@@ -8223,7 +8438,8 @@ ${unreflectedContent}` : freshRecord.bufferedReflection;
|
|
|
8223
8438
|
writer,
|
|
8224
8439
|
abortSignal,
|
|
8225
8440
|
reflectionHooks,
|
|
8226
|
-
requestContext
|
|
8441
|
+
requestContext,
|
|
8442
|
+
tracingContext
|
|
8227
8443
|
});
|
|
8228
8444
|
} catch (error) {
|
|
8229
8445
|
for (const [threadId, msgs] of threadsWithMessages) {
|
|
@@ -8245,10 +8461,7 @@ ${unreflectedContent}` : freshRecord.bufferedReflection;
|
|
|
8245
8461
|
}
|
|
8246
8462
|
}
|
|
8247
8463
|
}
|
|
8248
|
-
|
|
8249
|
-
throw error;
|
|
8250
|
-
}
|
|
8251
|
-
omError("[OM] Resource-scoped observation failed", error);
|
|
8464
|
+
throw error;
|
|
8252
8465
|
} finally {
|
|
8253
8466
|
await this.storage.setObservingFlag(record.id, false);
|
|
8254
8467
|
unregisterOp(record.id, "observing");
|
|
@@ -8296,7 +8509,16 @@ ${unreflectedContent}` : freshRecord.bufferedReflection;
|
|
|
8296
8509
|
* in the background at intervals, and activated when the threshold is reached.
|
|
8297
8510
|
*/
|
|
8298
8511
|
async maybeReflect(opts) {
|
|
8299
|
-
const {
|
|
8512
|
+
const {
|
|
8513
|
+
record,
|
|
8514
|
+
observationTokens,
|
|
8515
|
+
writer,
|
|
8516
|
+
abortSignal,
|
|
8517
|
+
messageList,
|
|
8518
|
+
reflectionHooks,
|
|
8519
|
+
requestContext,
|
|
8520
|
+
tracingContext
|
|
8521
|
+
} = opts;
|
|
8300
8522
|
const lockKey = this.getLockKey(record.threadId, record.resourceId);
|
|
8301
8523
|
const reflectThreshold = getMaxThreshold(this.reflectionConfig.observationTokens);
|
|
8302
8524
|
if (this.isAsyncReflectionEnabled() && observationTokens < reflectThreshold) {
|
|
@@ -8375,7 +8597,8 @@ ${unreflectedContent}` : freshRecord.bufferedReflection;
|
|
|
8375
8597
|
abortSignal,
|
|
8376
8598
|
void 0,
|
|
8377
8599
|
void 0,
|
|
8378
|
-
requestContext
|
|
8600
|
+
requestContext,
|
|
8601
|
+
tracingContext
|
|
8379
8602
|
);
|
|
8380
8603
|
const reflectionTokenCount = this.tokenCounter.countObservations(reflectResult.observations);
|
|
8381
8604
|
await this.storage.createReflectionGeneration({
|
|
@@ -8421,10 +8644,7 @@ ${unreflectedContent}` : freshRecord.bufferedReflection;
|
|
|
8421
8644
|
await writer.custom(failedMarker).catch(() => {
|
|
8422
8645
|
});
|
|
8423
8646
|
}
|
|
8424
|
-
|
|
8425
|
-
throw error;
|
|
8426
|
-
}
|
|
8427
|
-
omError("[OM] Reflection failed", error);
|
|
8647
|
+
throw error;
|
|
8428
8648
|
} finally {
|
|
8429
8649
|
await this.storage.setReflectingFlag(record.id, false);
|
|
8430
8650
|
reflectionHooks?.onReflectionEnd?.();
|
|
@@ -8614,6 +8834,6 @@ function getObservationsAsOf(activeObservations, asOf) {
|
|
|
8614
8834
|
return chunks.join("\n\n");
|
|
8615
8835
|
}
|
|
8616
8836
|
|
|
8617
|
-
export { OBSERVATIONAL_MEMORY_DEFAULTS, OBSERVATION_CONTEXT_INSTRUCTIONS, OBSERVATION_CONTEXT_PROMPT, OBSERVATION_CONTINUATION_HINT, OBSERVER_SYSTEM_PROMPT, ObservationalMemory, TokenCounter, buildObserverPrompt, buildObserverSystemPrompt, combineObservationGroupRanges, deriveObservationGroupProvenance, e, estimateTokenCount, extractCurrentTask, formatMessagesForObserver, formatToolResultForObserver, getObservationsAsOf, hasCurrentTaskSection, injectAnchorIds, optimizeObservationsForContext, parseAnchorId, parseObservationGroups, parseObserverOutput, reconcileObservationGroupsFromReflection, renderObservationGroupsForReflection, resolveToolResultValue, stripEphemeralAnchorIds, stripObservationGroups, truncateStringByTokens, wrapInObservationGroup };
|
|
8618
|
-
//# sourceMappingURL=chunk-
|
|
8619
|
-
//# sourceMappingURL=chunk-
|
|
8837
|
+
export { ModelByInputTokens, OBSERVATIONAL_MEMORY_DEFAULTS, OBSERVATION_CONTEXT_INSTRUCTIONS, OBSERVATION_CONTEXT_PROMPT, OBSERVATION_CONTINUATION_HINT, OBSERVER_SYSTEM_PROMPT, ObservationalMemory, TokenCounter, buildObserverPrompt, buildObserverSystemPrompt, combineObservationGroupRanges, deriveObservationGroupProvenance, e, estimateTokenCount, extractCurrentTask, formatMessagesForObserver, formatToolResultForObserver, getObservationsAsOf, hasCurrentTaskSection, injectAnchorIds, optimizeObservationsForContext, parseAnchorId, parseObservationGroups, parseObserverOutput, reconcileObservationGroupsFromReflection, renderObservationGroupsForReflection, resolveToolResultValue, stripEphemeralAnchorIds, stripObservationGroups, truncateStringByTokens, wrapInObservationGroup };
|
|
8838
|
+
//# sourceMappingURL=chunk-W2QMKHBI.js.map
|
|
8839
|
+
//# sourceMappingURL=chunk-W2QMKHBI.js.map
|