@mastra/observability 1.10.2-alpha.0 → 1.10.3-alpha.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 CHANGED
@@ -1,5 +1,124 @@
1
1
  # @mastra/observability
2
2
 
3
+ ## 1.10.3-alpha.0
4
+
5
+ ### Patch Changes
6
+
7
+ - Add durable agents with resumable streams ([#12557](https://github.com/mastra-ai/mastra/pull/12557))
8
+
9
+ Durable agents make agent execution resilient to disconnections, crashes, and long-running operations.
10
+
11
+ ### The Problem
12
+
13
+ Standard agent streaming has two fragility points:
14
+ 1. **Connection drops** - If a client disconnects mid-stream (network blip, browser refresh, mobile app backgrounded), all subsequent events are lost. The client has no way to "catch up" on what they missed.
15
+ 2. **Long-running operations** - Agent loops with tool calls can take minutes. Holding an HTTP connection open that long is unreliable. If the server restarts or the connection times out, the work is lost.
16
+
17
+ ### The Solution
18
+
19
+ **Resumable streams** solve connection drops. Every event is cached with a sequential index. If a client disconnects at event 5, they can reconnect and request events starting from index 6. They receive cached events immediately, then continue with live events as they arrive.
20
+
21
+ **Durable execution** solves long-running operations. Instead of executing the agent loop directly in the HTTP request, execution happens in a workflow engine (built-in evented engine or Inngest). The HTTP request just subscribes to events. If the connection drops, execution continues. The client can reconnect anytime to observe progress.
22
+
23
+ ### Usage
24
+
25
+ Wrap any existing `Agent` with durability using factory functions:
26
+
27
+ ```typescript
28
+ import { Agent } from '@mastra/core/agent';
29
+ import { createDurableAgent } from '@mastra/core/agent/durable';
30
+
31
+ const agent = new Agent({
32
+ id: 'my-agent',
33
+ model: openai('gpt-4'),
34
+ instructions: 'You are helpful',
35
+ });
36
+
37
+ const durableAgent = createDurableAgent({ agent });
38
+ ```
39
+
40
+ **Factory functions for different execution strategies:**
41
+
42
+ | Factory | Execution | Use Case |
43
+ | ---------------------------------------- | ----------------------------------- | ------------------------------- |
44
+ | `createDurableAgent({ agent })` | Local, synchronous | Development, simple deployments |
45
+ | `createEventedAgent({ agent })` | Fire-and-forget via workflow engine | Long-running operations |
46
+ | `createInngestAgent({ agent, inngest })` | Inngest-powered | Production, distributed systems |
47
+
48
+ ### Resumable Streams
49
+
50
+ ```typescript
51
+ // Start streaming
52
+ const { runId, output } = await durableAgent.stream('Analyze this data...');
53
+
54
+ // Client disconnects at event 5...
55
+
56
+ // Reconnect and resume from where we left off
57
+ const { output: resumed } = await durableAgent.observe(runId, { offset: 6 });
58
+ // Receives events 6, 7, 8... from cache, then continues with live events
59
+ ```
60
+
61
+ ### PubSub and Cache
62
+
63
+ Durable agents use two infrastructure components:
64
+
65
+ | Component | Purpose | Default |
66
+ | ---------- | ----------------------------------------- | --------------------- |
67
+ | **PubSub** | Real-time event delivery during streaming | `EventEmitterPubSub` |
68
+ | **Cache** | Stores events for replay on reconnection | `InMemoryServerCache` |
69
+
70
+ When `stream()` is called, events flow through pubsub in real-time. The cache stores each event with a sequential index. When `observe()` is called, missed events replay from cache before continuing with live events.
71
+
72
+ **Configure via Mastra instance (recommended):**
73
+
74
+ ```typescript
75
+ const mastra = new Mastra({
76
+ cache: new RedisServerCache({ url: 'redis://...' }),
77
+ pubsub: new RedisPubSub({ url: 'redis://...' }),
78
+ agents: {
79
+ // Inherits cache and pubsub from Mastra
80
+ myAgent: createDurableAgent({ agent }),
81
+ },
82
+ });
83
+ ```
84
+
85
+ **Configure per-agent (overrides Mastra):**
86
+
87
+ ```typescript
88
+ const durableAgent = createDurableAgent({
89
+ agent,
90
+ cache: new RedisServerCache({ url: 'redis://...' }),
91
+ pubsub: new RedisPubSub({ url: 'redis://...' }),
92
+ });
93
+ ```
94
+
95
+ **Disable caching (streams won't be resumable):**
96
+
97
+ ```typescript
98
+ const durableAgent = createDurableAgent({ agent, cache: false });
99
+ ```
100
+
101
+ For single-instance deployments, the defaults work fine. For multi-instance deployments (load balancer, horizontal scaling), use Redis-backed implementations so any instance can serve reconnection requests.
102
+
103
+ ### Class Hierarchy
104
+ - `DurableAgent` extends `Agent` - base class with resumable streams
105
+ - `EventedAgent` extends `DurableAgent` - fire-and-forget execution
106
+ - `InngestAgent` extends `DurableAgent` - Inngest-powered execution
107
+
108
+ - Reduced default cloud observability volume by filtering model chunk spans from CloudExporter uploads by default and raising the default observability log level to `warn`. ([#15815](https://github.com/mastra-ai/mastra/pull/15815))
109
+
110
+ - Updated dependencies [[`920c757`](https://github.com/mastra-ai/mastra/commit/920c75799c6bd71787d86deaf654a35af4c839ca), [`1fe2533`](https://github.com/mastra-ai/mastra/commit/1fe2533c4382ca6858aac7c4b63e888c2eac6541), [`f8694b6`](https://github.com/mastra-ai/mastra/commit/f8694b6fa0b7a5cde71d794c3bbef4957c55bcb8)]:
111
+ - @mastra/core@1.30.0-alpha.1
112
+
113
+ ## 1.10.2
114
+
115
+ ### Patch Changes
116
+
117
+ - Fixed `inputDetails.cacheWrite` reflecting only the final step's cache-write tokens in multi-step Anthropic prompt-caching runs (e.g. subagent and workflow flows). Trace `inputDetails.cacheWrite` and the derived input-token totals now reflect the full multi-step run, so cost accounting in Langfuse and other exporters matches what Anthropic actually charged. ([#15828](https://github.com/mastra-ai/mastra/pull/15828))
118
+
119
+ - Updated dependencies [[`6db978c`](https://github.com/mastra-ai/mastra/commit/6db978c42e94e75540a504f7230086f0b5cd35f9), [`512a013`](https://github.com/mastra-ai/mastra/commit/512a013f285aa9c0aa8f08a35b2ce09f9938b017), [`e9becde`](https://github.com/mastra-ai/mastra/commit/e9becdeed9176b9f8392e557bde12b933f99cf7a), [`703a443`](https://github.com/mastra-ai/mastra/commit/703a44390c587d9c0b8ae94ec4edd8afb2a74044), [`808df1b`](https://github.com/mastra-ai/mastra/commit/808df1b39358b5f10b7317107e42b1fda7c87185)]:
120
+ - @mastra/core@1.29.1
121
+
3
122
  ## 1.10.2-alpha.0
4
123
 
5
124
  ### Patch Changes
package/dist/config.d.ts CHANGED
@@ -110,7 +110,7 @@ export interface ObservabilityInstanceConfig {
110
110
  logging?: {
111
111
  /** Set to `false` to disable dual-write logging to observability storage. Defaults to `true`. */
112
112
  enabled?: boolean;
113
- /** Minimum log level to write to observability storage. Defaults to `'debug'`. */
113
+ /** Minimum log level to write to observability storage. Defaults to `'warn'`. */
114
114
  level?: LogLevel;
115
115
  };
116
116
  }
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,KAAK,EACV,qBAAqB,EACrB,qBAAqB,EACrB,mBAAmB,EACnB,mBAAmB,EACnB,cAAc,EACd,oBAAoB,EACpB,iBAAiB,EACjB,QAAQ,EACR,eAAe,EAChB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AACtD,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAM3B;;GAEG;AACH,oBAAY,oBAAoB;IAC9B,MAAM,WAAW;IACjB,KAAK,UAAU;IACf,KAAK,UAAU;IACf,MAAM,WAAW;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAChC;AAED;;GAEG;AACH,MAAM,MAAM,gBAAgB,GACxB;IAAE,IAAI,EAAE,oBAAoB,CAAC,MAAM,CAAA;CAAE,GACrC;IAAE,IAAI,EAAE,oBAAoB,CAAC,KAAK,CAAA;CAAE,GACpC;IAAE,IAAI,EAAE,oBAAoB,CAAC,KAAK,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,GACzD;IAAE,IAAI,EAAE,oBAAoB,CAAC,MAAM,CAAC;IAAC,OAAO,EAAE,CAAC,OAAO,CAAC,EAAE,oBAAoB,KAAK,OAAO,CAAA;CAAE,CAAC;AAMhG;;GAEG;AACH,MAAM,WAAW,2B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WAAW;IAQnB,OAAO,CAAC,cAAc;IAOtB,OAAO,CAAC,iBAAiB;IAOzB,OAAO,CAAC,gBAAgB;IAOxB,OAAO,CAAC,mBAAmB;IAO3B,OAAO,CAAC,eAAe;IAMvB,OAAO,CAAC,UAAU;IAelB,OAAO,CAAC,SAAS;IAMjB,OAAO,CAAC,YAAY;IAMpB,OAAO,CAAC,WAAW;IAMnB,OAAO,CAAC,cAAc;YAMR,mBAAmB;IAYjC,OAAO,CAAC,WAAW;IAiBnB,OAAO,CAAC,aAAa;YAoBP,WAAW;IAoDzB;;OAEG;YACW,WAAW;YAuBX,gBAAgB;IA+B9B,OAAO,CAAC,WAAW;IAUnB;;;;OAIG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IA4BtB,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;CAiChC"}
package/dist/index.cjs CHANGED
@@ -15051,6 +15051,7 @@ var SIGNAL_PUBLISH_SUFFIXES = {
15051
15051
  scores: "/scores/publish",
15052
15052
  feedback: "/feedback/publish"
15053
15053
  };
15054
+ var DEFAULT_CLOUD_SPAN_FILTER = (span) => span.type !== observability.SpanType.MODEL_CHUNK;
15054
15055
  var SIGNAL_PUBLISH_SEGMENTS = {
15055
15056
  traces: "spans",
15056
15057
  logs: "logs",
@@ -15224,6 +15225,9 @@ var CloudExporter = class extends BaseExporter {
15224
15225
  if (event.type !== observability.TracingEventType.SPAN_ENDED) {
15225
15226
  return;
15226
15227
  }
15228
+ if (!DEFAULT_CLOUD_SPAN_FILTER(event.exportedSpan)) {
15229
+ return;
15230
+ }
15227
15231
  this.addToBuffer(event);
15228
15232
  await this.handleBufferedEvent();
15229
15233
  }
@@ -17849,7 +17853,7 @@ var LoggerContextImpl = class {
17849
17853
  * Build an ExportedLog, check against the minimum level, and emit it through the bus.
17850
17854
  */
17851
17855
  log(level, message, data) {
17852
- const minLevel = this.config.minLevel ?? "debug";
17856
+ const minLevel = this.config.minLevel ?? "warn";
17853
17857
  if (LOG_LEVEL_PRIORITY[level] < LOG_LEVEL_PRIORITY[minLevel]) {
17854
17858
  return;
17855
17859
  }
@@ -18757,6 +18761,10 @@ var ModelSpanTracker = class {
18757
18761
  #stepIndex = 0;
18758
18762
  #chunkSequence = 0;
18759
18763
  #completionStartTime;
18764
+ /** When true, step-finish chunks don't auto-close the step span (for durable execution) */
18765
+ #deferStepClose = false;
18766
+ /** Stored step-finish payload when defer mode is enabled */
18767
+ #pendingStepFinishPayload;
18760
18768
  constructor(modelSpan) {
18761
18769
  this.#modelSpan = modelSpan;
18762
18770
  }
@@ -18802,6 +18810,41 @@ var ModelSpanTracker = class {
18802
18810
  updateGeneration(options) {
18803
18811
  this.#modelSpan?.update(options);
18804
18812
  }
18813
+ /**
18814
+ * Enable or disable deferred step closing for durable execution.
18815
+ * When enabled, step-finish chunks won't automatically close the step span.
18816
+ * Use exportCurrentStep() to get the span data, then close it manually later.
18817
+ */
18818
+ setDeferStepClose(defer) {
18819
+ this.#deferStepClose = defer;
18820
+ }
18821
+ /**
18822
+ * Export the current step span for later rebuilding (durable execution).
18823
+ * Returns undefined if no step span is active.
18824
+ */
18825
+ exportCurrentStep() {
18826
+ return this.#currentStepSpan?.exportSpan();
18827
+ }
18828
+ /**
18829
+ * Get the pending step finish payload (captured when defer mode is enabled).
18830
+ * This contains usage, finishReason, etc. for closing the step later.
18831
+ */
18832
+ getPendingStepFinishPayload() {
18833
+ return this.#pendingStepFinishPayload;
18834
+ }
18835
+ /**
18836
+ * Set the starting step index for durable execution.
18837
+ * Used when resuming across agentic loop iterations to maintain step continuity.
18838
+ */
18839
+ setStepIndex(index) {
18840
+ this.#stepIndex = index;
18841
+ }
18842
+ /**
18843
+ * Get the current step index.
18844
+ */
18845
+ getStepIndex() {
18846
+ return this.#stepIndex;
18847
+ }
18805
18848
  /**
18806
18849
  * Start a new Model execution step.
18807
18850
  * This should be called at the beginning of LLM execution to capture accurate startTime.
@@ -19105,7 +19148,11 @@ var ModelSpanTracker = class {
19105
19148
  }
19106
19149
  break;
19107
19150
  case "step-finish":
19108
- this.#endStepSpan(chunk.payload);
19151
+ if (this.#deferStepClose) {
19152
+ this.#pendingStepFinishPayload = chunk.payload;
19153
+ } else {
19154
+ this.#endStepSpan(chunk.payload);
19155
+ }
19109
19156
  break;
19110
19157
  // Infrastructure chunks - skip creating spans for these
19111
19158
  // They are either redundant, metadata-only, or error/control flow
@@ -19224,6 +19271,7 @@ var BaseSpan = class {
19224
19271
  endTime;
19225
19272
  isEvent;
19226
19273
  isInternal;
19274
+ tracingPolicy;
19227
19275
  observabilityInstance;
19228
19276
  input;
19229
19277
  output;
@@ -19283,6 +19331,7 @@ var BaseSpan = class {
19283
19331
  this.startTime = options.startTime ?? /* @__PURE__ */ new Date();
19284
19332
  this.observabilityInstance = observabilityInstance;
19285
19333
  this.isEvent = options.isEvent ?? false;
19334
+ this.tracingPolicy = options.tracingPolicy;
19286
19335
  this.traceState = options.traceState;
19287
19336
  this.tags = !options.parent && options.tags?.length ? options.tags : void 0;
19288
19337
  const entityParent = this.getParentSpan(false);