@mastra/core 1.3.0-alpha.1 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +297 -0
- package/dist/agent/index.cjs +8 -8
- package/dist/agent/index.js +1 -1
- package/dist/{chunk-LULKG6NF.js → chunk-3MJCJLZS.js} +4 -4
- package/dist/{chunk-LULKG6NF.js.map → chunk-3MJCJLZS.js.map} +1 -1
- package/dist/{chunk-OV7OOUUR.js → chunk-44SUGDBR.js} +2 -2
- package/dist/{chunk-OV7OOUUR.js.map → chunk-44SUGDBR.js.map} +1 -1
- package/dist/{chunk-ELBCIHOB.js → chunk-57QAF2ZQ.js} +4 -4
- package/dist/{chunk-ELBCIHOB.js.map → chunk-57QAF2ZQ.js.map} +1 -1
- package/dist/{chunk-GMSEZYLZ.js → chunk-BXLLXTT4.js} +3 -3
- package/dist/{chunk-GMSEZYLZ.js.map → chunk-BXLLXTT4.js.map} +1 -1
- package/dist/{chunk-GZD6443M.cjs → chunk-C3XU7ZDC.cjs} +2 -2
- package/dist/{chunk-GZD6443M.cjs.map → chunk-C3XU7ZDC.cjs.map} +1 -1
- package/dist/{chunk-DULE2DRR.cjs → chunk-EH6SAGEO.cjs} +48 -48
- package/dist/{chunk-DULE2DRR.cjs.map → chunk-EH6SAGEO.cjs.map} +1 -1
- package/dist/{chunk-DD7377YA.cjs → chunk-EUG4AON3.cjs} +7 -7
- package/dist/{chunk-DD7377YA.cjs.map → chunk-EUG4AON3.cjs.map} +1 -1
- package/dist/{chunk-U4EG3D6G.cjs → chunk-GCTAD6B7.cjs} +5 -5
- package/dist/{chunk-U4EG3D6G.cjs.map → chunk-GCTAD6B7.cjs.map} +1 -1
- package/dist/{chunk-VJDLIS2E.js → chunk-JNE2ABVB.js} +9 -9
- package/dist/chunk-JNE2ABVB.js.map +1 -0
- package/dist/{chunk-D5B5ON7A.cjs → chunk-KAJNBNWP.cjs} +23 -5
- package/dist/chunk-KAJNBNWP.cjs.map +1 -0
- package/dist/{chunk-MAX37NGP.js → chunk-KUTU2YZF.js} +4 -4
- package/dist/{chunk-MAX37NGP.js.map → chunk-KUTU2YZF.js.map} +1 -1
- package/dist/{chunk-ZIWDJWC3.cjs → chunk-NCC45KOB.cjs} +7 -7
- package/dist/{chunk-ZIWDJWC3.cjs.map → chunk-NCC45KOB.cjs.map} +1 -1
- package/dist/{chunk-YMXQDOSQ.js → chunk-PHYJYZ32.js} +7 -7
- package/dist/{chunk-YMXQDOSQ.js.map → chunk-PHYJYZ32.js.map} +1 -1
- package/dist/{chunk-AFF24QUP.js → chunk-SIZEIYNH.js} +36 -34
- package/dist/chunk-SIZEIYNH.js.map +1 -0
- package/dist/{chunk-SZH2YH74.cjs → chunk-TERSHTY5.cjs} +15 -15
- package/dist/chunk-TERSHTY5.cjs.map +1 -0
- package/dist/{chunk-5VMWMXSI.cjs → chunk-UHVG25VW.cjs} +14 -14
- package/dist/{chunk-5VMWMXSI.cjs.map → chunk-UHVG25VW.cjs.map} +1 -1
- package/dist/{chunk-VHAFCFYP.js → chunk-WL3AW3YA.js} +22 -4
- package/dist/chunk-WL3AW3YA.js.map +1 -0
- package/dist/{chunk-ZC6IHDHX.cjs → chunk-YNXIGRQE.cjs} +44 -42
- package/dist/chunk-YNXIGRQE.cjs.map +1 -0
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +269 -269
- package/dist/docs/references/docs-memory-observational-memory.md +9 -78
- package/dist/docs/references/reference-memory-observational-memory.md +7 -316
- package/dist/evals/index.cjs +20 -20
- package/dist/evals/index.js +3 -3
- package/dist/evals/scoreTraces/index.cjs +5 -5
- package/dist/evals/scoreTraces/index.js +2 -2
- package/dist/index.cjs +4 -4
- package/dist/index.js +2 -2
- package/dist/llm/index.cjs +10 -10
- package/dist/llm/index.js +2 -2
- package/dist/llm/model/provider-types.generated.d.ts +9 -0
- package/dist/loop/index.cjs +12 -12
- package/dist/loop/index.js +1 -1
- package/dist/loop/network/index.d.ts.map +1 -1
- package/dist/loop/network/validation.d.ts +8 -0
- package/dist/loop/network/validation.d.ts.map +1 -1
- package/dist/mastra/index.cjs +2 -2
- package/dist/mastra/index.js +1 -1
- package/dist/memory/index.cjs +14 -14
- package/dist/memory/index.js +1 -1
- package/dist/processors/index.cjs +41 -41
- package/dist/processors/index.js +1 -1
- package/dist/provider-registry-C6XCYX44.cjs +40 -0
- package/dist/{provider-registry-BJJRUX4P.cjs.map → provider-registry-C6XCYX44.cjs.map} +1 -1
- package/dist/provider-registry-NWU4YFQW.js +3 -0
- package/dist/{provider-registry-VZYB342T.js.map → provider-registry-NWU4YFQW.js.map} +1 -1
- package/dist/provider-registry.json +20 -2
- package/dist/relevance/index.cjs +3 -3
- package/dist/relevance/index.js +1 -1
- package/dist/storage/constants.cjs +27 -27
- package/dist/storage/constants.js +1 -1
- package/dist/storage/domains/memory/base.d.ts +4 -4
- package/dist/storage/domains/memory/inmemory.d.ts +1 -1
- package/dist/storage/index.cjs +117 -117
- package/dist/storage/index.js +2 -2
- package/dist/storage/types.d.ts +2 -2
- package/dist/storage/types.d.ts.map +1 -1
- package/dist/stream/index.cjs +8 -8
- package/dist/stream/index.js +1 -1
- package/dist/tool-loop-agent/index.cjs +4 -4
- package/dist/tool-loop-agent/index.js +1 -1
- package/dist/vector/index.cjs +7 -7
- package/dist/vector/index.js +1 -1
- package/dist/workflows/evented/index.cjs +10 -10
- package/dist/workflows/evented/index.js +1 -1
- package/dist/workflows/index.cjs +25 -25
- package/dist/workflows/index.js +1 -1
- package/package.json +7 -7
- package/src/llm/model/provider-types.generated.d.ts +9 -0
- package/dist/chunk-AFF24QUP.js.map +0 -1
- package/dist/chunk-D5B5ON7A.cjs.map +0 -1
- package/dist/chunk-SZH2YH74.cjs.map +0 -1
- package/dist/chunk-VHAFCFYP.js.map +0 -1
- package/dist/chunk-VJDLIS2E.js.map +0 -1
- package/dist/chunk-ZC6IHDHX.cjs.map +0 -1
- package/dist/provider-registry-BJJRUX4P.cjs +0 -40
- package/dist/provider-registry-VZYB342T.js +0 -3
|
@@ -24,21 +24,11 @@ export const agent = new Agent({
|
|
|
24
24
|
});
|
|
25
25
|
```
|
|
26
26
|
|
|
27
|
-
That's it. The agent now has humanlike long-term memory that persists across conversations.
|
|
28
|
-
|
|
29
|
-
```typescript
|
|
30
|
-
const memory = new Memory({
|
|
31
|
-
options: {
|
|
32
|
-
observationalMemory: {
|
|
33
|
-
model: "deepseek/deepseek-reasoner",
|
|
34
|
-
},
|
|
35
|
-
},
|
|
36
|
-
});
|
|
37
|
-
```
|
|
27
|
+
That's it. The agent now has humanlike long-term memory that persists across conversations.
|
|
38
28
|
|
|
39
29
|
See [configuration options](https://mastra.ai/reference/memory/observational-memory) for full API details.
|
|
40
30
|
|
|
41
|
-
> **Note:** OM currently only supports `@mastra/pg`, `@mastra/libsql`, and `@mastra/mongodb` storage adapters. It uses background agents for managing memory.
|
|
31
|
+
> **Note:** OM currently only supports `@mastra/pg`, `@mastra/libsql`, and `@mastra/mongodb` storage adapters. It also uses background agents for managing memory. The default model (configurable) is `google/gemini-2.5-flash` as it's the one we've tested the most.
|
|
42
32
|
|
|
43
33
|
## Benefits
|
|
44
34
|
|
|
@@ -87,9 +77,7 @@ The result is a three-tier system:
|
|
|
87
77
|
|
|
88
78
|
The Observer and Reflector run in the background. Any model that works with Mastra's model routing (e.g. `openai/...`, `google/...`, `deepseek/...`) can be used.
|
|
89
79
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
We recommend `google/gemini-2.5-flash` — it works well for both observation and reflection, and its 1M token context window gives the Reflector headroom.
|
|
80
|
+
The default is `google/gemini-2.5-flash` — it works well for both observation and reflection, and its 1M token context window gives the Reflector headroom.
|
|
93
81
|
|
|
94
82
|
We've also tested `deepseek`, `qwen3`, and `glm-4.7` for the Observer. For the Reflector, make sure the model's context window can fit all observations. Note that Claude 4.5 models currently don't work well as observer or reflector.
|
|
95
83
|
|
|
@@ -112,14 +100,9 @@ See [model configuration](https://mastra.ai/reference/memory/observational-memor
|
|
|
112
100
|
Each thread has its own observations.
|
|
113
101
|
|
|
114
102
|
```typescript
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
model: "google/gemini-2.5-flash",
|
|
119
|
-
scope: "thread",
|
|
120
|
-
},
|
|
121
|
-
},
|
|
122
|
-
});
|
|
103
|
+
observationalMemory: {
|
|
104
|
+
scope: "thread",
|
|
105
|
+
}
|
|
123
106
|
```
|
|
124
107
|
|
|
125
108
|
### Resource scope
|
|
@@ -127,14 +110,9 @@ const memory = new Memory({
|
|
|
127
110
|
Observations are shared across all threads for a resource (typically a user). Enables cross-conversation memory.
|
|
128
111
|
|
|
129
112
|
```typescript
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
model: "google/gemini-2.5-flash",
|
|
134
|
-
scope: "resource",
|
|
135
|
-
},
|
|
136
|
-
},
|
|
137
|
-
});
|
|
113
|
+
observationalMemory: {
|
|
114
|
+
scope: "resource",
|
|
115
|
+
}
|
|
138
116
|
```
|
|
139
117
|
|
|
140
118
|
> **Warning:** In resource scope, unobserved messages across _all_ threads are processed together. For users with many existing threads, this can be slow. Use thread scope for existing apps.
|
|
@@ -147,7 +125,6 @@ OM uses token thresholds to decide when to observe and reflect. See [token budge
|
|
|
147
125
|
const memory = new Memory({
|
|
148
126
|
options: {
|
|
149
127
|
observationalMemory: {
|
|
150
|
-
model: "google/gemini-2.5-flash",
|
|
151
128
|
observation: {
|
|
152
129
|
// when to run the Observer (default: 30,000)
|
|
153
130
|
messageTokens: 30_000,
|
|
@@ -157,58 +134,12 @@ const memory = new Memory({
|
|
|
157
134
|
observationTokens: 40_000,
|
|
158
135
|
},
|
|
159
136
|
// let message history borrow from observation budget
|
|
160
|
-
// requires bufferTokens: false (temporary limitation)
|
|
161
137
|
shareTokenBudget: false,
|
|
162
138
|
},
|
|
163
139
|
},
|
|
164
140
|
});
|
|
165
141
|
```
|
|
166
142
|
|
|
167
|
-
## Async Buffering
|
|
168
|
-
|
|
169
|
-
Without async buffering, the Observer runs synchronously when the message threshold is reached — the agent pauses mid-conversation while the Observer LLM call completes. With async buffering (enabled by default), observations are pre-computed in the background as the conversation grows. When the threshold is hit, buffered observations activate instantly with no pause.
|
|
170
|
-
|
|
171
|
-
### How it works
|
|
172
|
-
|
|
173
|
-
As the agent converses, message tokens accumulate. At regular intervals (`bufferTokens`), a background Observer call runs without blocking the agent. Each call produces a "chunk" of observations that's stored in a buffer.
|
|
174
|
-
|
|
175
|
-
When message tokens reach the `messageTokens` threshold, buffered chunks activate: their observations move into the active observation log, and the corresponding raw messages are removed from the context window. The agent never pauses.
|
|
176
|
-
|
|
177
|
-
If the agent produces messages faster than the Observer can process them, a `blockAfter` safety threshold forces a synchronous observation as a last resort.
|
|
178
|
-
|
|
179
|
-
Reflection works similarly — the Reflector runs in the background when observations reach a fraction of the reflection threshold.
|
|
180
|
-
|
|
181
|
-
### Settings
|
|
182
|
-
|
|
183
|
-
| Setting | Default | What it controls |
|
|
184
|
-
| ------------------------------ | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
185
|
-
| `observation.bufferTokens` | `0.2` | How often to buffer. `0.2` means every 20% of `messageTokens` — with the default 30k threshold, that's roughly every 6k tokens. Can also be an absolute token count (e.g. `5000`). |
|
|
186
|
-
| `observation.bufferActivation` | `0.8` | How aggressively to clear the message window on activation. `0.8` means remove enough messages to keep only 20% of `messageTokens` remaining. Lower values keep more message history. |
|
|
187
|
-
| `observation.blockAfter` | `1.2` | Safety threshold as a multiplier of `messageTokens`. At `1.2`, synchronous observation is forced at 36k tokens (1.2 × 30k). Only matters if buffering can't keep up. |
|
|
188
|
-
| `reflection.bufferActivation` | `0.5` | When to start background reflection. `0.5` means reflection begins when observations reach 50% of the `observationTokens` threshold. |
|
|
189
|
-
| `reflection.blockAfter` | `1.2` | Safety threshold for reflection, same logic as observation. |
|
|
190
|
-
|
|
191
|
-
### Disabling
|
|
192
|
-
|
|
193
|
-
To disable async buffering and use synchronous observation/reflection instead:
|
|
194
|
-
|
|
195
|
-
```typescript
|
|
196
|
-
const memory = new Memory({
|
|
197
|
-
options: {
|
|
198
|
-
observationalMemory: {
|
|
199
|
-
model: "google/gemini-2.5-flash",
|
|
200
|
-
observation: {
|
|
201
|
-
bufferTokens: false,
|
|
202
|
-
},
|
|
203
|
-
},
|
|
204
|
-
},
|
|
205
|
-
});
|
|
206
|
-
```
|
|
207
|
-
|
|
208
|
-
Setting `bufferTokens: false` disables both observation and reflection async buffering. See [async buffering configuration](https://mastra.ai/reference/memory/observational-memory) for the full API.
|
|
209
|
-
|
|
210
|
-
> **Note:** Async buffering is not supported with `scope: 'resource'`. It is automatically disabled in resource scope.
|
|
211
|
-
|
|
212
143
|
## Migrating existing threads
|
|
213
144
|
|
|
214
145
|
No manual migration needed. OM reads existing messages and observes them lazily when thresholds are exceeded.
|
|
@@ -24,15 +24,17 @@ export const agent = new Agent({
|
|
|
24
24
|
|
|
25
25
|
## Configuration
|
|
26
26
|
|
|
27
|
-
The `observationalMemory` option accepts `true`,
|
|
27
|
+
The `observationalMemory` option accepts `true`, `false`, or a configuration object.
|
|
28
|
+
|
|
29
|
+
Setting `observationalMemory: true` enables it with all defaults. Setting `observationalMemory: false` or omitting it disables it.
|
|
28
30
|
|
|
29
31
|
**enabled?:** (`boolean`): Enable or disable Observational Memory. When omitted from a config object, defaults to \`true\`. Only \`enabled: false\` explicitly disables it. (Default: `true`)
|
|
30
32
|
|
|
31
|
-
**model?:** (`string | LanguageModel | DynamicModel | ModelWithRetries[]`): Model for both the Observer and Reflector agents. Sets the model for both at once. Cannot be used together with \`observation.model\` or \`reflection.model\` — an error will be thrown if both are set.
|
|
33
|
+
**model?:** (`string | LanguageModel | DynamicModel | ModelWithRetries[]`): Model for both the Observer and Reflector agents. Sets the model for both at once. Cannot be used together with \`observation.model\` or \`reflection.model\` — an error will be thrown if both are set. (Default: `'google/gemini-2.5-flash'`)
|
|
32
34
|
|
|
33
35
|
**scope?:** (`'resource' | 'thread'`): Memory scope for observations. \`'thread'\` keeps observations per-thread. \`'resource'\` shares observations across all threads for a resource, enabling cross-conversation memory. (Default: `'thread'`)
|
|
34
36
|
|
|
35
|
-
**shareTokenBudget?:** (`boolean`): Share the token budget between messages and observations. When enabled, the total budget is \`observation.messageTokens + reflection.observationTokens\`. Messages can use more space when observations are small, and vice versa. This maximizes context usage through flexible allocation.
|
|
37
|
+
**shareTokenBudget?:** (`boolean`): Share the token budget between messages and observations. When enabled, the total budget is \`observation.messageTokens + reflection.observationTokens\`. Messages can use more space when observations are small, and vice versa. This maximizes context usage through flexible allocation. (Default: `false`)
|
|
36
38
|
|
|
37
39
|
**observation?:** (`ObservationalMemoryObservationConfig`): Configuration for the observation step. Controls when the Observer agent runs and how it behaves.
|
|
38
40
|
|
|
@@ -40,7 +42,7 @@ The `observationalMemory` option accepts `true`, a configuration object, or `fal
|
|
|
40
42
|
|
|
41
43
|
### Observation config
|
|
42
44
|
|
|
43
|
-
**model?:** (`string | LanguageModel | DynamicModel | ModelWithRetries[]`): Model for the Observer agent. Cannot be set if a top-level \`model\` is also provided.
|
|
45
|
+
**model?:** (`string | LanguageModel | DynamicModel | ModelWithRetries[]`): Model for the Observer agent. Cannot be set if a top-level \`model\` is also provided. (Default: `'google/gemini-2.5-flash'`)
|
|
44
46
|
|
|
45
47
|
**messageTokens?:** (`number`): Token count of unobserved messages that triggers observation. When unobserved message tokens exceed this threshold, the Observer agent is called. (Default: `30000`)
|
|
46
48
|
|
|
@@ -48,24 +50,14 @@ The `observationalMemory` option accepts `true`, a configuration object, or `fal
|
|
|
48
50
|
|
|
49
51
|
**modelSettings?:** (`ObservationalMemoryModelSettings`): Model settings for the Observer agent. (Default: `{ temperature: 0.3, maxOutputTokens: 100_000 }`)
|
|
50
52
|
|
|
51
|
-
**bufferTokens?:** (`number | false`): Token interval for async background observation buffering. Can be an absolute token count (e.g. \`5000\`) or a fraction of \`messageTokens\` (e.g. \`0.25\` = buffer every 25% of threshold). When set, observations run in the background at this interval, storing results in a buffer. When the main \`messageTokens\` threshold is reached, buffered observations activate instantly without a blocking LLM call. Must resolve to less than \`messageTokens\`. Set to \`false\` to explicitly disable all async buffering (both observation and reflection). (Default: `0.2`)
|
|
52
|
-
|
|
53
|
-
**bufferActivation?:** (`number`): Ratio (0-1) controlling how much of the message window to retain after activation. For example, \`0.8\` means activate enough to keep only 20% of \`messageTokens\` remaining. Higher values remove more message history per activation. (Default: `0.8`)
|
|
54
|
-
|
|
55
|
-
**blockAfter?:** (`number`): Token threshold above which synchronous (blocking) observation is forced. Between \`messageTokens\` and \`blockAfter\`, only async buffering/activation is used. Above \`blockAfter\`, a synchronous observation runs as a last resort. Accepts a multiplier (1 < value < 2, multiplied by \`messageTokens\`) or an absolute token count (≥ 2, must be greater than \`messageTokens\`). Only relevant when \`bufferTokens\` is set. Defaults to \`1.2\` when async buffering is enabled. (Default: `1.2 (when bufferTokens is set)`)
|
|
56
|
-
|
|
57
53
|
### Reflection config
|
|
58
54
|
|
|
59
|
-
**model?:** (`string | LanguageModel | DynamicModel | ModelWithRetries[]`): Model for the Reflector agent. Cannot be set if a top-level \`model\` is also provided.
|
|
55
|
+
**model?:** (`string | LanguageModel | DynamicModel | ModelWithRetries[]`): Model for the Reflector agent. Cannot be set if a top-level \`model\` is also provided. (Default: `'google/gemini-2.5-flash'`)
|
|
60
56
|
|
|
61
57
|
**observationTokens?:** (`number`): Token count of observations that triggers reflection. When observation tokens exceed this threshold, the Reflector agent is called to condense them. (Default: `40000`)
|
|
62
58
|
|
|
63
59
|
**modelSettings?:** (`ObservationalMemoryModelSettings`): Model settings for the Reflector agent. (Default: `{ temperature: 0, maxOutputTokens: 100_000 }`)
|
|
64
60
|
|
|
65
|
-
**bufferActivation?:** (`number`): Ratio (0-1) controlling when async reflection buffering starts. When observation tokens reach \`observationTokens \* bufferActivation\`, reflection runs in the background. On activation at the full threshold, the buffered reflection replaces the observations it covers, preserving any new observations appended after that range. (Default: `0.5`)
|
|
66
|
-
|
|
67
|
-
**blockAfter?:** (`number`): Token threshold above which synchronous (blocking) reflection is forced. Between \`observationTokens\` and \`blockAfter\`, only async buffering/activation is used. Above \`blockAfter\`, a synchronous reflection runs as a last resort. Accepts a multiplier (1 < value < 2, multiplied by \`observationTokens\`) or an absolute token count (≥ 2, must be greater than \`observationTokens\`). Only relevant when \`bufferActivation\` is set. Defaults to \`1.2\` when async reflection is enabled. (Default: `1.2 (when bufferActivation is set)`)
|
|
68
|
-
|
|
69
61
|
### Model settings
|
|
70
62
|
|
|
71
63
|
**temperature?:** (`number`): Temperature for generation. Lower values produce more consistent output. (Default: `0.3`)
|
|
@@ -87,7 +79,6 @@ export const agent = new Agent({
|
|
|
87
79
|
memory: new Memory({
|
|
88
80
|
options: {
|
|
89
81
|
observationalMemory: {
|
|
90
|
-
model: "google/gemini-2.5-flash",
|
|
91
82
|
scope: "resource",
|
|
92
83
|
observation: {
|
|
93
84
|
messageTokens: 20_000,
|
|
@@ -117,7 +108,6 @@ export const agent = new Agent({
|
|
|
117
108
|
shareTokenBudget: true,
|
|
118
109
|
observation: {
|
|
119
110
|
messageTokens: 20_000,
|
|
120
|
-
bufferTokens: false, // required when using shareTokenBudget (temporary limitation)
|
|
121
111
|
},
|
|
122
112
|
reflection: {
|
|
123
113
|
observationTokens: 80_000,
|
|
@@ -175,305 +165,6 @@ export const agent = new Agent({
|
|
|
175
165
|
});
|
|
176
166
|
```
|
|
177
167
|
|
|
178
|
-
### Async buffering
|
|
179
|
-
|
|
180
|
-
Async buffering is **enabled by default**. It pre-computes observations in the background as the conversation grows — when the `messageTokens` threshold is reached, buffered observations activate instantly with no blocking LLM call.
|
|
181
|
-
|
|
182
|
-
The lifecycle is: **buffer → activate → remove messages → repeat**. Background Observer calls run at `bufferTokens` intervals, each producing a chunk of observations. At threshold, chunks activate: observations move into the log, raw messages are removed from context. The `blockAfter` threshold forces a synchronous fallback if buffering can't keep up.
|
|
183
|
-
|
|
184
|
-
Default settings:
|
|
185
|
-
|
|
186
|
-
- `observation.bufferTokens: 0.2` — buffer every 20% of `messageTokens` (e.g. every \~6k tokens with a 30k threshold)
|
|
187
|
-
- `observation.bufferActivation: 0.8` — on activation, remove enough messages to keep only 20% of the threshold remaining
|
|
188
|
-
- `reflection.bufferActivation: 0.5` — start background reflection at 50% of observation threshold
|
|
189
|
-
|
|
190
|
-
To customize:
|
|
191
|
-
|
|
192
|
-
```typescript
|
|
193
|
-
import { Memory } from "@mastra/memory";
|
|
194
|
-
import { Agent } from "@mastra/core/agent";
|
|
195
|
-
|
|
196
|
-
export const agent = new Agent({
|
|
197
|
-
name: "my-agent",
|
|
198
|
-
instructions: "You are a helpful assistant.",
|
|
199
|
-
model: "openai/gpt-5-mini",
|
|
200
|
-
memory: new Memory({
|
|
201
|
-
options: {
|
|
202
|
-
observationalMemory: {
|
|
203
|
-
model: "google/gemini-2.5-flash",
|
|
204
|
-
observation: {
|
|
205
|
-
messageTokens: 30_000,
|
|
206
|
-
// Buffer every 5k tokens (runs in background)
|
|
207
|
-
bufferTokens: 5_000,
|
|
208
|
-
// Activate to retain 30% of threshold
|
|
209
|
-
bufferActivation: 0.7,
|
|
210
|
-
// Force synchronous observation at 1.5x threshold
|
|
211
|
-
blockAfter: 1.5,
|
|
212
|
-
},
|
|
213
|
-
reflection: {
|
|
214
|
-
observationTokens: 60_000,
|
|
215
|
-
// Start background reflection at 50% of threshold
|
|
216
|
-
bufferActivation: 0.5,
|
|
217
|
-
// Force synchronous reflection at 1.2x threshold
|
|
218
|
-
blockAfter: 1.2,
|
|
219
|
-
},
|
|
220
|
-
},
|
|
221
|
-
},
|
|
222
|
-
}),
|
|
223
|
-
});
|
|
224
|
-
```
|
|
225
|
-
|
|
226
|
-
To disable async buffering entirely:
|
|
227
|
-
|
|
228
|
-
```typescript
|
|
229
|
-
observationalMemory: {
|
|
230
|
-
model: "google/gemini-2.5-flash",
|
|
231
|
-
observation: {
|
|
232
|
-
bufferTokens: false,
|
|
233
|
-
},
|
|
234
|
-
}
|
|
235
|
-
```
|
|
236
|
-
|
|
237
|
-
Setting `bufferTokens: false` disables both observation and reflection async buffering. Observations and reflections will run synchronously when their thresholds are reached.
|
|
238
|
-
|
|
239
|
-
> **Note:** Async buffering is not supported with `scope: 'resource'` and is automatically disabled in resource scope.
|
|
240
|
-
|
|
241
|
-
## Streaming data parts
|
|
242
|
-
|
|
243
|
-
Observational Memory emits typed data parts during agent execution that clients can use for real-time UI feedback. These are streamed alongside the agent's response.
|
|
244
|
-
|
|
245
|
-
### `data-om-status`
|
|
246
|
-
|
|
247
|
-
Emitted once per agent loop step, before model generation. Provides a snapshot of the current memory state, including token usage for both context windows and the state of any async buffered content.
|
|
248
|
-
|
|
249
|
-
```typescript
|
|
250
|
-
interface DataOmStatusPart {
|
|
251
|
-
type: 'data-om-status';
|
|
252
|
-
data: {
|
|
253
|
-
windows: {
|
|
254
|
-
active: {
|
|
255
|
-
/** Unobserved message tokens and the threshold that triggers observation */
|
|
256
|
-
messages: { tokens: number; threshold: number };
|
|
257
|
-
/** Observation tokens and the threshold that triggers reflection */
|
|
258
|
-
observations: { tokens: number; threshold: number };
|
|
259
|
-
};
|
|
260
|
-
buffered: {
|
|
261
|
-
observations: {
|
|
262
|
-
/** Number of buffered chunks staged for activation */
|
|
263
|
-
chunks: number;
|
|
264
|
-
/** Total message tokens across all buffered chunks */
|
|
265
|
-
messageTokens: number;
|
|
266
|
-
/** Projected message tokens that would be removed if activation happened now (based on bufferActivation ratio and chunk boundaries) */
|
|
267
|
-
projectedMessageRemoval: number;
|
|
268
|
-
/** Observation tokens that will be added on activation */
|
|
269
|
-
observationTokens: number;
|
|
270
|
-
/** idle: no buffering in progress. running: background observer is working. complete: chunks are ready for activation. */
|
|
271
|
-
status: 'idle' | 'running' | 'complete';
|
|
272
|
-
};
|
|
273
|
-
reflection: {
|
|
274
|
-
/** Observation tokens that were fed into the reflector (pre-compression size) */
|
|
275
|
-
inputObservationTokens: number;
|
|
276
|
-
/** Observation tokens the reflection will produce on activation (post-compression size) */
|
|
277
|
-
observationTokens: number;
|
|
278
|
-
/** idle: no reflection buffered. running: background reflector is working. complete: reflection is ready for activation. */
|
|
279
|
-
status: 'idle' | 'running' | 'complete';
|
|
280
|
-
};
|
|
281
|
-
};
|
|
282
|
-
};
|
|
283
|
-
recordId: string;
|
|
284
|
-
threadId: string;
|
|
285
|
-
stepNumber: number;
|
|
286
|
-
/** Increments each time the Reflector creates a new generation */
|
|
287
|
-
generationCount: number;
|
|
288
|
-
};
|
|
289
|
-
}
|
|
290
|
-
```
|
|
291
|
-
|
|
292
|
-
`buffered.reflection.inputObservationTokens` is the size of the observations that were sent to the Reflector. `buffered.reflection.observationTokens` is the compressed result — the size of what will replace those observations when the reflection activates. A client can use these two values to show a compression ratio.
|
|
293
|
-
|
|
294
|
-
Clients can derive percentages and post-activation estimates from the raw values:
|
|
295
|
-
|
|
296
|
-
```typescript
|
|
297
|
-
// Message window usage %
|
|
298
|
-
const msgPercent = status.windows.active.messages.tokens
|
|
299
|
-
/ status.windows.active.messages.threshold;
|
|
300
|
-
|
|
301
|
-
// Observation window usage %
|
|
302
|
-
const obsPercent = status.windows.active.observations.tokens
|
|
303
|
-
/ status.windows.active.observations.threshold;
|
|
304
|
-
|
|
305
|
-
// Projected message tokens after buffered observations activate
|
|
306
|
-
// Uses projectedMessageRemoval which accounts for bufferActivation ratio and chunk boundaries
|
|
307
|
-
const postActivation = status.windows.active.messages.tokens
|
|
308
|
-
- status.windows.buffered.observations.projectedMessageRemoval;
|
|
309
|
-
|
|
310
|
-
// Reflection compression ratio (when buffered reflection exists)
|
|
311
|
-
const { inputObservationTokens, observationTokens } = status.windows.buffered.reflection;
|
|
312
|
-
if (inputObservationTokens > 0) {
|
|
313
|
-
const compressionRatio = observationTokens / inputObservationTokens;
|
|
314
|
-
}
|
|
315
|
-
```
|
|
316
|
-
|
|
317
|
-
### `data-om-observation-start`
|
|
318
|
-
|
|
319
|
-
Emitted when the Observer or Reflector agent begins processing.
|
|
320
|
-
|
|
321
|
-
**cycleId:** (`string`): Unique ID for this cycle — shared between start/end/failed markers.
|
|
322
|
-
|
|
323
|
-
**operationType:** (`'observation' | 'reflection'`): Whether this is an observation or reflection operation.
|
|
324
|
-
|
|
325
|
-
**startedAt:** (`string`): ISO timestamp when processing started.
|
|
326
|
-
|
|
327
|
-
**tokensToObserve:** (`number`): Message tokens (input) being processed in this batch.
|
|
328
|
-
|
|
329
|
-
**recordId:** (`string`): The OM record ID.
|
|
330
|
-
|
|
331
|
-
**threadId:** (`string`): This thread's ID.
|
|
332
|
-
|
|
333
|
-
**threadIds:** (`string[]`): All thread IDs in this batch (for resource-scoped).
|
|
334
|
-
|
|
335
|
-
**config:** (`ObservationMarkerConfig`): Snapshot of \`messageTokens\`, \`observationTokens\`, and \`scope\` at observation time.
|
|
336
|
-
|
|
337
|
-
### `data-om-observation-end`
|
|
338
|
-
|
|
339
|
-
Emitted when observation or reflection completes successfully.
|
|
340
|
-
|
|
341
|
-
**cycleId:** (`string`): Matches the corresponding \`start\` marker.
|
|
342
|
-
|
|
343
|
-
**operationType:** (`'observation' | 'reflection'`): Type of operation that completed.
|
|
344
|
-
|
|
345
|
-
**completedAt:** (`string`): ISO timestamp when processing completed.
|
|
346
|
-
|
|
347
|
-
**durationMs:** (`number`): Duration in milliseconds.
|
|
348
|
-
|
|
349
|
-
**tokensObserved:** (`number`): Message tokens (input) that were processed.
|
|
350
|
-
|
|
351
|
-
**observationTokens:** (`number`): Resulting observation tokens (output) after the Observer compressed them.
|
|
352
|
-
|
|
353
|
-
**observations?:** (`string`): The generated observations text.
|
|
354
|
-
|
|
355
|
-
**currentTask?:** (`string`): Current task extracted by the Observer.
|
|
356
|
-
|
|
357
|
-
**suggestedResponse?:** (`string`): Suggested response extracted by the Observer.
|
|
358
|
-
|
|
359
|
-
**recordId:** (`string`): The OM record ID.
|
|
360
|
-
|
|
361
|
-
**threadId:** (`string`): This thread's ID.
|
|
362
|
-
|
|
363
|
-
### `data-om-observation-failed`
|
|
364
|
-
|
|
365
|
-
Emitted when observation or reflection fails. The system falls back to synchronous processing.
|
|
366
|
-
|
|
367
|
-
**cycleId:** (`string`): Matches the corresponding \`start\` marker.
|
|
368
|
-
|
|
369
|
-
**operationType:** (`'observation' | 'reflection'`): Type of operation that failed.
|
|
370
|
-
|
|
371
|
-
**failedAt:** (`string`): ISO timestamp when the failure occurred.
|
|
372
|
-
|
|
373
|
-
**durationMs:** (`number`): Duration until failure in milliseconds.
|
|
374
|
-
|
|
375
|
-
**tokensAttempted:** (`number`): Message tokens (input) that were attempted.
|
|
376
|
-
|
|
377
|
-
**error:** (`string`): Error message.
|
|
378
|
-
|
|
379
|
-
**observations?:** (`string`): Any partial content available for display.
|
|
380
|
-
|
|
381
|
-
**recordId:** (`string`): The OM record ID.
|
|
382
|
-
|
|
383
|
-
**threadId:** (`string`): This thread's ID.
|
|
384
|
-
|
|
385
|
-
### `data-om-buffering-start`
|
|
386
|
-
|
|
387
|
-
Emitted when async buffering begins in the background. Buffering pre-computes observations or reflections before the main threshold is reached.
|
|
388
|
-
|
|
389
|
-
**cycleId:** (`string`): Unique ID for this buffering cycle.
|
|
390
|
-
|
|
391
|
-
**operationType:** (`'observation' | 'reflection'`): Type of operation being buffered.
|
|
392
|
-
|
|
393
|
-
**startedAt:** (`string`): ISO timestamp when buffering started.
|
|
394
|
-
|
|
395
|
-
**tokensToBuffer:** (`number`): Message tokens (input) being buffered in this cycle.
|
|
396
|
-
|
|
397
|
-
**recordId:** (`string`): The OM record ID.
|
|
398
|
-
|
|
399
|
-
**threadId:** (`string`): This thread's ID.
|
|
400
|
-
|
|
401
|
-
**threadIds:** (`string[]`): All thread IDs being buffered (for resource-scoped).
|
|
402
|
-
|
|
403
|
-
**config:** (`ObservationMarkerConfig`): Snapshot of config at buffering time.
|
|
404
|
-
|
|
405
|
-
### `data-om-buffering-end`
|
|
406
|
-
|
|
407
|
-
Emitted when async buffering completes. The content is stored but not yet activated in the main context.
|
|
408
|
-
|
|
409
|
-
**cycleId:** (`string`): Matches the corresponding \`buffering-start\` marker.
|
|
410
|
-
|
|
411
|
-
**operationType:** (`'observation' | 'reflection'`): Type of operation that was buffered.
|
|
412
|
-
|
|
413
|
-
**completedAt:** (`string`): ISO timestamp when buffering completed.
|
|
414
|
-
|
|
415
|
-
**durationMs:** (`number`): Duration in milliseconds.
|
|
416
|
-
|
|
417
|
-
**tokensBuffered:** (`number`): Message tokens (input) that were buffered.
|
|
418
|
-
|
|
419
|
-
**bufferedTokens:** (`number`): Observation tokens (output) after the Observer compressed them.
|
|
420
|
-
|
|
421
|
-
**observations?:** (`string`): The buffered content.
|
|
422
|
-
|
|
423
|
-
**recordId:** (`string`): The OM record ID.
|
|
424
|
-
|
|
425
|
-
**threadId:** (`string`): This thread's ID.
|
|
426
|
-
|
|
427
|
-
### `data-om-buffering-failed`
|
|
428
|
-
|
|
429
|
-
Emitted when async buffering fails. The system falls back to synchronous processing when the threshold is reached.
|
|
430
|
-
|
|
431
|
-
**cycleId:** (`string`): Matches the corresponding \`buffering-start\` marker.
|
|
432
|
-
|
|
433
|
-
**operationType:** (`'observation' | 'reflection'`): Type of operation that failed.
|
|
434
|
-
|
|
435
|
-
**failedAt:** (`string`): ISO timestamp when the failure occurred.
|
|
436
|
-
|
|
437
|
-
**durationMs:** (`number`): Duration until failure in milliseconds.
|
|
438
|
-
|
|
439
|
-
**tokensAttempted:** (`number`): Message tokens (input) that were attempted to buffer.
|
|
440
|
-
|
|
441
|
-
**error:** (`string`): Error message.
|
|
442
|
-
|
|
443
|
-
**observations?:** (`string`): Any partial content.
|
|
444
|
-
|
|
445
|
-
**recordId:** (`string`): The OM record ID.
|
|
446
|
-
|
|
447
|
-
**threadId:** (`string`): This thread's ID.
|
|
448
|
-
|
|
449
|
-
### `data-om-activation`
|
|
450
|
-
|
|
451
|
-
Emitted when buffered observations or reflections are activated (moved into the active context window). This is an instant operation — no LLM call is involved.
|
|
452
|
-
|
|
453
|
-
**cycleId:** (`string`): Unique ID for this activation event.
|
|
454
|
-
|
|
455
|
-
**operationType:** (`'observation' | 'reflection'`): Type of content activated.
|
|
456
|
-
|
|
457
|
-
**activatedAt:** (`string`): ISO timestamp when activation occurred.
|
|
458
|
-
|
|
459
|
-
**chunksActivated:** (`number`): Number of buffered chunks activated.
|
|
460
|
-
|
|
461
|
-
**tokensActivated:** (`number`): Message tokens (input) from activated chunks. For observation activation, these are removed from the message window. For reflection activation, this is the observation tokens that were compressed.
|
|
462
|
-
|
|
463
|
-
**observationTokens:** (`number`): Resulting observation tokens after activation.
|
|
464
|
-
|
|
465
|
-
**messagesActivated:** (`number`): Number of messages that were observed via activation.
|
|
466
|
-
|
|
467
|
-
**generationCount:** (`number`): Current reflection generation count.
|
|
468
|
-
|
|
469
|
-
**observations?:** (`string`): The activated observations text.
|
|
470
|
-
|
|
471
|
-
**recordId:** (`string`): The OM record ID.
|
|
472
|
-
|
|
473
|
-
**threadId:** (`string`): This thread's ID.
|
|
474
|
-
|
|
475
|
-
**config:** (`ObservationMarkerConfig`): Snapshot of config at activation time.
|
|
476
|
-
|
|
477
168
|
## Standalone usage
|
|
478
169
|
|
|
479
170
|
Most users should use the `Memory` class above. Using `ObservationalMemory` directly is mainly useful for benchmarking, experimentation, or when you need to control processor ordering with other processors (like [guardrails](https://mastra.ai/docs/agents/guardrails)).
|
package/dist/evals/index.cjs
CHANGED
|
@@ -1,78 +1,78 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
3
|
+
var chunkEUG4AON3_cjs = require('../chunk-EUG4AON3.cjs');
|
|
4
|
+
var chunkYNXIGRQE_cjs = require('../chunk-YNXIGRQE.cjs');
|
|
5
|
+
var chunkC3XU7ZDC_cjs = require('../chunk-C3XU7ZDC.cjs');
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
Object.defineProperty(exports, "runEvals", {
|
|
10
10
|
enumerable: true,
|
|
11
|
-
get: function () { return
|
|
11
|
+
get: function () { return chunkEUG4AON3_cjs.runEvals; }
|
|
12
12
|
});
|
|
13
13
|
Object.defineProperty(exports, "MastraScorer", {
|
|
14
14
|
enumerable: true,
|
|
15
|
-
get: function () { return
|
|
15
|
+
get: function () { return chunkYNXIGRQE_cjs.MastraScorer; }
|
|
16
16
|
});
|
|
17
17
|
Object.defineProperty(exports, "createScorer", {
|
|
18
18
|
enumerable: true,
|
|
19
|
-
get: function () { return
|
|
19
|
+
get: function () { return chunkYNXIGRQE_cjs.createScorer; }
|
|
20
20
|
});
|
|
21
21
|
Object.defineProperty(exports, "listScoresResponseSchema", {
|
|
22
22
|
enumerable: true,
|
|
23
|
-
get: function () { return
|
|
23
|
+
get: function () { return chunkC3XU7ZDC_cjs.listScoresResponseSchema; }
|
|
24
24
|
});
|
|
25
25
|
Object.defineProperty(exports, "saveScorePayloadSchema", {
|
|
26
26
|
enumerable: true,
|
|
27
|
-
get: function () { return
|
|
27
|
+
get: function () { return chunkC3XU7ZDC_cjs.saveScorePayloadSchema; }
|
|
28
28
|
});
|
|
29
29
|
Object.defineProperty(exports, "scoreResultSchema", {
|
|
30
30
|
enumerable: true,
|
|
31
|
-
get: function () { return
|
|
31
|
+
get: function () { return chunkC3XU7ZDC_cjs.scoreResultSchema; }
|
|
32
32
|
});
|
|
33
33
|
Object.defineProperty(exports, "scoreRowDataSchema", {
|
|
34
34
|
enumerable: true,
|
|
35
|
-
get: function () { return
|
|
35
|
+
get: function () { return chunkC3XU7ZDC_cjs.scoreRowDataSchema; }
|
|
36
36
|
});
|
|
37
37
|
Object.defineProperty(exports, "scoringEntityTypeSchema", {
|
|
38
38
|
enumerable: true,
|
|
39
|
-
get: function () { return
|
|
39
|
+
get: function () { return chunkC3XU7ZDC_cjs.scoringEntityTypeSchema; }
|
|
40
40
|
});
|
|
41
41
|
Object.defineProperty(exports, "scoringExtractStepResultSchema", {
|
|
42
42
|
enumerable: true,
|
|
43
|
-
get: function () { return
|
|
43
|
+
get: function () { return chunkC3XU7ZDC_cjs.scoringExtractStepResultSchema; }
|
|
44
44
|
});
|
|
45
45
|
Object.defineProperty(exports, "scoringHookInputSchema", {
|
|
46
46
|
enumerable: true,
|
|
47
|
-
get: function () { return
|
|
47
|
+
get: function () { return chunkC3XU7ZDC_cjs.scoringHookInputSchema; }
|
|
48
48
|
});
|
|
49
49
|
Object.defineProperty(exports, "scoringInputSchema", {
|
|
50
50
|
enumerable: true,
|
|
51
|
-
get: function () { return
|
|
51
|
+
get: function () { return chunkC3XU7ZDC_cjs.scoringInputSchema; }
|
|
52
52
|
});
|
|
53
53
|
Object.defineProperty(exports, "scoringInputWithExtractStepResultAndAnalyzeStepResultSchema", {
|
|
54
54
|
enumerable: true,
|
|
55
|
-
get: function () { return
|
|
55
|
+
get: function () { return chunkC3XU7ZDC_cjs.scoringInputWithExtractStepResultAndAnalyzeStepResultSchema; }
|
|
56
56
|
});
|
|
57
57
|
Object.defineProperty(exports, "scoringInputWithExtractStepResultAndScoreAndReasonSchema", {
|
|
58
58
|
enumerable: true,
|
|
59
|
-
get: function () { return
|
|
59
|
+
get: function () { return chunkC3XU7ZDC_cjs.scoringInputWithExtractStepResultAndScoreAndReasonSchema; }
|
|
60
60
|
});
|
|
61
61
|
Object.defineProperty(exports, "scoringInputWithExtractStepResultSchema", {
|
|
62
62
|
enumerable: true,
|
|
63
|
-
get: function () { return
|
|
63
|
+
get: function () { return chunkC3XU7ZDC_cjs.scoringInputWithExtractStepResultSchema; }
|
|
64
64
|
});
|
|
65
65
|
Object.defineProperty(exports, "scoringPromptsSchema", {
|
|
66
66
|
enumerable: true,
|
|
67
|
-
get: function () { return
|
|
67
|
+
get: function () { return chunkC3XU7ZDC_cjs.scoringPromptsSchema; }
|
|
68
68
|
});
|
|
69
69
|
Object.defineProperty(exports, "scoringSourceSchema", {
|
|
70
70
|
enumerable: true,
|
|
71
|
-
get: function () { return
|
|
71
|
+
get: function () { return chunkC3XU7ZDC_cjs.scoringSourceSchema; }
|
|
72
72
|
});
|
|
73
73
|
Object.defineProperty(exports, "scoringValueSchema", {
|
|
74
74
|
enumerable: true,
|
|
75
|
-
get: function () { return
|
|
75
|
+
get: function () { return chunkC3XU7ZDC_cjs.scoringValueSchema; }
|
|
76
76
|
});
|
|
77
77
|
//# sourceMappingURL=index.cjs.map
|
|
78
78
|
//# sourceMappingURL=index.cjs.map
|
package/dist/evals/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { runEvals } from '../chunk-
|
|
2
|
-
export { MastraScorer, createScorer } from '../chunk-
|
|
3
|
-
export { listScoresResponseSchema, saveScorePayloadSchema, scoreResultSchema, scoreRowDataSchema, scoringEntityTypeSchema, scoringExtractStepResultSchema, scoringHookInputSchema, scoringInputSchema, scoringInputWithExtractStepResultAndAnalyzeStepResultSchema, scoringInputWithExtractStepResultAndScoreAndReasonSchema, scoringInputWithExtractStepResultSchema, scoringPromptsSchema, scoringSourceSchema, scoringValueSchema } from '../chunk-
|
|
1
|
+
export { runEvals } from '../chunk-KUTU2YZF.js';
|
|
2
|
+
export { MastraScorer, createScorer } from '../chunk-SIZEIYNH.js';
|
|
3
|
+
export { listScoresResponseSchema, saveScorePayloadSchema, scoreResultSchema, scoreRowDataSchema, scoringEntityTypeSchema, scoringExtractStepResultSchema, scoringHookInputSchema, scoringInputSchema, scoringInputWithExtractStepResultAndAnalyzeStepResultSchema, scoringInputWithExtractStepResultAndScoreAndReasonSchema, scoringInputWithExtractStepResultSchema, scoringPromptsSchema, scoringSourceSchema, scoringValueSchema } from '../chunk-44SUGDBR.js';
|
|
4
4
|
//# sourceMappingURL=index.js.map
|
|
5
5
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var chunkEH6SAGEO_cjs = require('../../chunk-EH6SAGEO.cjs');
|
|
4
|
+
var chunkC3XU7ZDC_cjs = require('../../chunk-C3XU7ZDC.cjs');
|
|
5
5
|
var chunk4U7ZLI36_cjs = require('../../chunk-4U7ZLI36.cjs');
|
|
6
6
|
var pMap = require('p-map');
|
|
7
7
|
var z = require('zod');
|
|
@@ -235,7 +235,7 @@ function transformTraceToScorerInputAndOutput(trace) {
|
|
|
235
235
|
}
|
|
236
236
|
|
|
237
237
|
// src/evals/scoreTraces/scoreTracesWorkflow.ts
|
|
238
|
-
var getTraceStep =
|
|
238
|
+
var getTraceStep = chunkEH6SAGEO_cjs.createStep({
|
|
239
239
|
id: "__process-trace-scoring",
|
|
240
240
|
inputSchema: z__default.default.object({
|
|
241
241
|
targets: z__default.default.array(
|
|
@@ -381,7 +381,7 @@ async function validateAndSaveScore({ storage, scorerResult }) {
|
|
|
381
381
|
text: "Scores storage domain is not available"
|
|
382
382
|
});
|
|
383
383
|
}
|
|
384
|
-
const payloadToSave =
|
|
384
|
+
const payloadToSave = chunkC3XU7ZDC_cjs.saveScorePayloadSchema.parse(scorerResult);
|
|
385
385
|
const result = await scoresStore.saveScore(payloadToSave);
|
|
386
386
|
return result.score;
|
|
387
387
|
}
|
|
@@ -432,7 +432,7 @@ async function attachScoreToSpan({
|
|
|
432
432
|
updates: { links: [...existingLinks, link] }
|
|
433
433
|
});
|
|
434
434
|
}
|
|
435
|
-
var scoreTracesWorkflow =
|
|
435
|
+
var scoreTracesWorkflow = chunkEH6SAGEO_cjs.createWorkflow({
|
|
436
436
|
id: "__batch-scoring-traces",
|
|
437
437
|
inputSchema: z__default.default.object({
|
|
438
438
|
targets: z__default.default.array(
|