@tanstack/ai 0.47.1 → 0.47.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/ai",
3
- "version": "0.47.1",
3
+ "version": "0.47.2",
4
4
  "description": "Type-safe TypeScript AI SDK for streaming chat, tool calling, agents, structured outputs, and multimodal generation.",
5
5
  "author": "Tanner Linsley",
6
6
  "license": "MIT",
@@ -80,8 +80,8 @@
80
80
  "@ag-ui/core": "0.1.1-canary.beta.0",
81
81
  "@standard-schema/spec": "^1.1.0",
82
82
  "partial-json": "^0.1.7",
83
- "@tanstack/ai-event-client": "^0.9.0",
84
- "@tanstack/ai-utils": "^0.4.0"
83
+ "@tanstack/ai-utils": "^0.4.0",
84
+ "@tanstack/ai-event-client": "^0.9.0"
85
85
  },
86
86
  "peerDependencies": {
87
87
  "@opentelemetry/api": ">=1.9.0"
@@ -1183,9 +1183,8 @@ class TextEngine<
1183
1183
 
1184
1184
  if (!skipAgentLoop) {
1185
1185
  do {
1186
- if (this.earlyTermination || this.isCancelled()) {
1187
- return
1188
- }
1186
+ if (this.earlyTermination) break
1187
+ if (this.isCancelled()) return
1189
1188
 
1190
1189
  this.logger.agentLoop(`iteration=${this.middlewareCtx.iteration}`, {
1191
1190
  iteration: this.middlewareCtx.iteration,
@@ -1217,6 +1216,8 @@ class TextEngine<
1217
1216
 
1218
1217
  yield* this.streamModelResponse()
1219
1218
 
1219
+ if (this.earlyTermination) break
1220
+
1220
1221
  if (
1221
1222
  yield* this.emitBoundaryInterrupts(
1222
1223
  'afterModel',
@@ -1783,11 +1784,8 @@ class TextEngine<
1783
1784
  chunk: Extract<StreamChunk, { type: 'RUN_ERROR' }>,
1784
1785
  ): void {
1785
1786
  this.earlyTermination = true
1786
- if (this.finalStructuredOutput && this.finalizationError === null) {
1787
- const message =
1788
- chunk.message ||
1789
- chunk.error?.message ||
1790
- 'Run failed before structured output completed'
1787
+ if (this.finalizationError === null) {
1788
+ const message = chunk.message || chunk.error?.message || 'Run failed'
1791
1789
  this.finalizationError = {
1792
1790
  message,
1793
1791
  ...(chunk.code !== undefined