feat(ai): support vercel ai sdk v7#8949
Conversation
…r/vercel-ai-sdk-7
…r/vercel-ai-sdk-7
🎉 All green!🧪 All tests passed 🎯 Code Coverage (details) 🔗 Commit SHA: c232cae | Docs | Datadog PR Page | Give us feedback! |
Overall package sizeSelf size: 6.65 MB Dependency sizes| name | version | self size | total size | |------|---------|-----------|------------| | import-in-the-middle | 3.3.1 | 122.62 kB | 437.94 kB | | opentracing | 0.14.7 | 194.81 kB | 194.81 kB | | dc-polyfill | 0.1.11 | 25.74 kB | 25.74 kB |🤖 This report was automatically generated by heaviest-objects-in-the-universe |
BenchmarksBenchmark execution time: 2026-07-07 21:08:28 Comparing candidate commit c232cae in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 2312 metrics, 46 unstable metrics.
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #8949 +/- ##
==========================================
- Coverage 96.54% 96.53% -0.01%
==========================================
Files 913 915 +2
Lines 120452 120979 +527
Branches 20874 20642 -232
==========================================
+ Hits 116286 116791 +505
- Misses 4166 4188 +22
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
PR is in a good state now but just needs the official release of the v7 ai sdk for tests to properly run |
Yun-Kim
left a comment
There was a problem hiding this comment.
Small suggestion on handling errors but otherwise LGTM
* initial changes * apm spans for vercel ai sdk v7 * wip - continued * fix system instructions parsing * add embedding support * streamed responses aggregation * stream cleanup * clean up channel names * limit existing test versions * update plugin IDs * add tests * update for official v7 release * remove hack for beta sdk testing * remove testing node oldest as require esm is needed for new tests * re-add forgotten install * try fix for esm issue in node 26 * fix rewriter * add needed cassettes * add skip allowance for missing embedMany telemetry * non-source code approach for fixing rewriter issues * remove unnecessary cancel block * address codex comments * Apply suggestion from @sabrenner * test v7 esm test * source change to guard against double-subscribing * Apply suggestion from @sabrenner * address review comments * address review comments * add additional result safeguards * get rid of patching script
* initial changes * apm spans for vercel ai sdk v7 * wip - continued * fix system instructions parsing * add embedding support * streamed responses aggregation * stream cleanup * clean up channel names * limit existing test versions * update plugin IDs * add tests * update for official v7 release * remove hack for beta sdk testing * remove testing node oldest as require esm is needed for new tests * re-add forgotten install * try fix for esm issue in node 26 * fix rewriter * add needed cassettes * add skip allowance for missing embedMany telemetry * non-source code approach for fixing rewriter issues * remove unnecessary cancel block * address codex comments * Apply suggestion from @sabrenner * test v7 esm test * source change to guard against double-subscribing * Apply suggestion from @sabrenner * address review comments * address review comments * add additional result safeguards * get rid of patching script
* initial changes * apm spans for vercel ai sdk v7 * wip - continued * fix system instructions parsing * add embedding support * streamed responses aggregation * stream cleanup * clean up channel names * limit existing test versions * update plugin IDs * add tests * update for official v7 release * remove hack for beta sdk testing * remove testing node oldest as require esm is needed for new tests * re-add forgotten install * try fix for esm issue in node 26 * fix rewriter * add needed cassettes * add skip allowance for missing embedMany telemetry * non-source code approach for fixing rewriter issues * remove unnecessary cancel block * address codex comments * Apply suggestion from @sabrenner * test v7 esm test * source change to guard against double-subscribing * Apply suggestion from @sabrenner * address review comments * address review comments * add additional result safeguards * get rid of patching script
* initial changes * apm spans for vercel ai sdk v7 * wip - continued * fix system instructions parsing * add embedding support * streamed responses aggregation * stream cleanup * clean up channel names * limit existing test versions * update plugin IDs * add tests * update for official v7 release * remove hack for beta sdk testing * remove testing node oldest as require esm is needed for new tests * re-add forgotten install * try fix for esm issue in node 26 * fix rewriter * add needed cassettes * add skip allowance for missing embedMany telemetry * non-source code approach for fixing rewriter issues * remove unnecessary cancel block * address codex comments * Apply suggestion from @sabrenner * test v7 esm test * source change to guard against double-subscribing * Apply suggestion from @sabrenner * address review comments * address review comments * add additional result safeguards * get rid of patching script
What does this PR do?
Adds support for the latest v7 major release of the Vercel AI SDK. This ships with built-in tracing channel support, which we leverage with tracing plugins for
ai:telemetrychannel publishes.We need one bit of manual instrumentation for handling streams, handled in
packages/datadog-instrumentations/src/ai.js, which could be version gated if aggregation is handled upstream for the AI SDK down the line.Motivation
Provide support for the latest Vercel AI SDK package.
Additional Notes
As noted in a comment, there was something weird with one of our testing dependencies that caused our orchestrion rewriter to do something weird in the v7 SDK (even though for tracing we do not use orchestrion for this version, AI Guard still uses it to properly intercept calls in the promise chain). I think the solution applied is OK.