fix(auto-instrumentation): Fix AI SDK streaming version handling for v3/v4+/v5#1739
Open
Stephen Belanger (Qard) wants to merge 1 commit intomainfrom
Open
fix(auto-instrumentation): Fix AI SDK streaming version handling for v3/v4+/v5#1739Stephen Belanger (Qard) wants to merge 1 commit intomainfrom
Stephen Belanger (Qard) wants to merge 1 commit intomainfrom
Conversation
…nt.stream version handling Split ESM streamText/streamObject instrumentation configs by version range: - v3 (>=3.0.0 <4.0.0): keep kind: "Async" since both functions are declared async in v3; asyncEnd fires with the resolved stream result - v4+ (>=4.0.0): use kind: "Sync" + streamTextSync/streamObjectSync channels since these functions are sync in v4+ and return the stream object directly Add agentStreamSync channel (kind: "sync-stream") for auto-hook path on v5: - v5 Agent.stream() is a sync method, so wrapPromise never fires asyncEnd - The existing agentStream channel (kind: "async") is kept for wrapAISDK's tracePromise path; the new agentStreamSync channel handles auto-hook via traceSyncStreamChannel with patchAISDKStreamingResult Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
async, so they needkind: "Async"(asyncEnd fires with the resolved stream result). In v4+ they are sync functions returning the stream directly, so they usekind: "Sync"with the existing sync-stream channels.stream()method in v5 is sync (not async), sowrapPromise'sasyncEndnever fires under auto-hook instrumentation. Added a newagentStreamSyncchannel (kind: "sync-stream") for the auto-hook path. The existingagentStreamchannel is kept for thewrapAISDKwrapper path which usestracePromise.These gaps were exposed by the
@apm-js-collab/code-transformerv0.11.0 upgrade (PR #1708), which tightenedwrapPromiseto only fireasyncEndwhen the return value is actually thenable.Test plan
pnpm run buildsucceeds with no type errors🤖 Generated with Claude Code