Changelog
Release history
7.1.1
Fixed
AiError.causeis now the raw SDK error (the same value asreason.cause), so code that walks.causechains findsstatusCodeandresponseBodyagain.
7.1.0
This release has breaking changes to AiError and the streamText result, even though it's a minor version. Read Breaking changes before you upgrade.
Breaking
AiErrornow has a typedreason. Themessageandcausefields are replaced by:method:'generateText' | 'streamText'reason: one ofRateLimitError,AuthenticationError,InvalidRequestError,ProviderError,InvalidOutputError,AbortedErrororUnknownError. Each tag has anai-effect/prefix (for exampleai-effect/RateLimitError), so it doesn't collide witheffect/aireason tags. The raw SDK error is onreason.cause.
messageis still there, now derived from the reason. A newisRetryablegetter is available. To handle a single reason, useEffect.catchReason('ai-effect/AiError', 'ai-effect/RateLimitError', ...).Aborts now fail with
AbortedError. Before, an abort from yourabortSignalfailed withUnknownError. That covers SDK abort errors, timeout errors and streamabortparts. If you matchedUnknownErrorto detect aborts, matchAbortedErrorinstead. Fiber interruption works the same as before.streamTextreturns Effect types instead of the raw SDK result.stream,fullStream,textStream,partialOutputStreamandelementStreamareStream<_, AiError>.text,usage,outputand the other promise fields areEffect<_, AiError>.textStream,partialOutputStreamandelementStreamnow fail on error and abort parts. The SDK drops those parts silently.- Interrupting a fiber that consumes any of these streams or fields aborts the call.
- The SDK result is still available as
raw.
ToolLoopAgent.streamreturns the same Effect-typed result.
Added
ToolLoopAgent.makewraps AI SDK 7'sToolLoopAgent. The constructor and per-call callbacks accept Effects.generateandstreamreturn Effects that requireAi. The SDK agent is available asToolLoopAgent.raw.UI message streams:
createUIMessageStreamwraps the SDK function of the same name.executeis an Effect, andwriter.mergetakes an EffectStream.createAgentUIStreambuilds a UI message stream from aToolLoopAgentand clientUIMessages. If the messages are invalid, the outer Effect fails before streaming starts.- The
streamTextresult has a newtoUIMessageStream()method. - Response helpers aren't wrapped. Use
Stream.toReadableStreamEffectto convert.
embed,embedManyandreranknow have Effect wrappers.Tracing: every wrapper emits Effect spans with OpenTelemetry GenAI attributes, so calls show up in any Effect tracer. This covers
generateText,streamText,ToolLoopAgent,createAgentUIStream,createUIMessageStream,embed,embedManyandrerank, plus anexecute_toolspan for each tool call.@ai-sdk/otelspans are nested under the wrapper's span.onStepErroringenerateTextandstreamTextaccepts an Effect.
Fixed
When a call is aborted or interrupted, its tool
executeeffects are now interrupted too. Before, they kept running until theAilayer closed.Free-form records like
Schema.Record(Schema.String, Schema.Unknown)now stay open in the generated tool and output JSON Schema. They used to getadditionalProperties: false.
7.0.0
Breaking
Initial release: Effect wrappers for AI SDK 7's
generateText,streamTextandtool, backed by a singleAiservice whose layer owns callback fibers and stream lifetimes.