Skip to content

fix(traceloop-sdk): ai-sdk fixes#865

Merged
nina-kollman merged 5 commits intomainfrom
nk/ai_sdk_v5
Jan 18, 2026
Merged

fix(traceloop-sdk): ai-sdk fixes#865
nina-kollman merged 5 commits intomainfrom
nk/ai_sdk_v5

Conversation

@nina-kollman
Copy link
Copy Markdown
Contributor

@nina-kollman nina-kollman commented Jan 18, 2026

Fixes: TLP-1439

  1. Add test for ai-sdk v5
  2. Add ai.sdk.version field
  3. Add scope version to the @traceloop/node-server-sdk
image

Important

Enhance Traceloop SDK with AI SDK v5 compatibility, version tracking, and updated scope version for node-server-sdk, including new tests.

  • Behavior:
    • Adds getAiSdkVersion() in ai-sdk-transformations.ts to retrieve AI SDK version and adds it to span attributes.
    • Updates getTracer() in tracing.ts to include TRACER_VERSION.
  • Tests:
    • Adds ai-sdk-v5-compatibility.test.ts to test AI SDK v5 compatibility, including tool schema and tool call transformations.
    • Renames test files to ai-sdk/ai-sdk-agent-integration.test.ts, ai-sdk/ai-sdk-integration.test.ts, and ai-sdk/ai-sdk-transformations.test.ts for better organization.
  • Misc:
    • Adds ai.sdk.version field to span attributes in transformAiSdkSpanAttributes() in ai-sdk-transformations.ts.

This description was created by Ellipsis for d76fb6e. You can customize this summary. It will automatically update as commits are pushed.

Summary by CodeRabbit

  • New Features
    • AI SDK and tracer version information now included in trace spans for improved observability and debugging.
    • Enhanced support for AI SDK v5 compatibility with improved tool definition and call transformation.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Jan 18, 2026

📝 Walkthrough

Walkthrough

The changes introduce AI SDK version tracking by reading the version from the AI SDK package and injecting it as a span attribute during transformation. The tracer is also initialized with the SDK version. Additionally, test import paths are corrected, and comprehensive AI SDK v5 compatibility tests are added.

Changes

Cohort / File(s) Summary
Version Tracking
packages/traceloop-sdk/src/lib/tracing/ai-sdk-transformations.ts, packages/traceloop-sdk/src/lib/tracing/tracing.ts
Adds helper to read AI SDK version from ai/package.json and conditionally injects ai.sdk.version attribute into spans. Tracer initialization now includes version metadata.
Test Import Path Corrections
packages/traceloop-sdk/test/ai-sdk/ai-sdk-agent-integration.test.ts, packages/traceloop-sdk/test/ai-sdk/ai-sdk-integration.test.ts, packages/traceloop-sdk/test/ai-sdk/ai-sdk-transformations.test.ts
Updates module import paths to resolve from correct directories (../../src and ../test-setup).
AI SDK V5 Compatibility Test Suite
packages/traceloop-sdk/test/ai-sdk/ai-sdk-v5-compatibility.test.ts
New comprehensive test file validating AI SDK v5 compatibility, including version injection, tool definition transformations (v4/v5 formats), tool call representations, span attribute population, and integration testing with Polly for record/replay.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 Hoppity-hop, versions now trace!
Each span gets the SDK's place,
V5 tools dance in transformation's way,
Tests verify they work and play! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'fix(traceloop-sdk): ai-sdk fixes' is generic and vague, using broad terms like 'fixes' without conveying specific details about what was changed or fixed. Consider a more specific title that describes the main changes, such as 'fix(traceloop-sdk): add ai.sdk.version support and v5 compatibility tests' to clarify the primary focus.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed The pull request addresses all primary objectives from TLP-1439: implements ai.sdk.version field, adds comprehensive ai-sdk v5 compatibility tests, and updates tracer initialization with version metadata.
Out of Scope Changes check ✅ Passed All changes are directly related to ai-sdk v5 alignment and instrumentation improvements outlined in TLP-1439; no unrelated modifications detected beyond the stated objectives.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Comment @coderabbitai help to get the list of available commands and usage tips.

@nina-kollman nina-kollman changed the title add v5 test fix(traceloop-sdk): ai-sdk fixes Jan 18, 2026
@nina-kollman nina-kollman marked this pull request as ready for review January 18, 2026 11:47
Copy link
Copy Markdown
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important

Looks good to me! 👍

Reviewed everything up to d76fb6e in 1 minute and 46 seconds. Click for details.
  • Reviewed 714 lines of code in 6 files
  • Skipped 0 files when reviewing.
  • Skipped posting 4 draft comments. View those below.
  • Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.
1. packages/traceloop-sdk/test/ai-sdk/ai-sdk-v5-compatibility.test.ts:500
  • Draft comment:
    The integration test is currently marked with it.skip. Consider adding a comment explaining why it’s skipped, or enabling it when the external dependencies (e.g. API keys) are available.
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable: usefulness confidence = 20% vs. threshold = 50% This comment is asking the PR author to either add a comment explaining why the test is skipped, or to enable it. This falls into the category of asking the author to explain or confirm their intention. The rules specifically state "Do NOT ask the PR author to confirm their intention, to explain, to double-check things, to ensure the behavior is intended". The comment is also somewhat speculative - it assumes that the test should either have a comment or be enabled, but the author may have intentionally skipped it temporarily during development. Additionally, whether a test is skipped is a decision the author made, and asking them to explain it is not a clear code change requirement. The comment could be seen as helpful for code maintainability - having documentation for why tests are skipped is generally good practice. It's also a relatively minor ask that could improve code quality. The author may have simply forgotten to add a comment or remove the skip. While documenting skipped tests is good practice, this comment is asking the author to explain their decision or confirm their intention, which violates the rules. The comment doesn't point to a definite code issue - it's more of a suggestion about documentation. If the test is skipped, there's likely a reason, and asking the author to document it falls under "asking to explain". This comment should be deleted because it asks the PR author to explain why the test is skipped or to confirm their intention to enable it, which violates the rule against asking authors to confirm intentions or explain their decisions. It's not pointing to a clear code defect.
2. packages/traceloop-sdk/test/ai-sdk/ai-sdk-v5-compatibility.test.ts:115
  • Draft comment:
    Several tests compare transformed tool parameters by checking the JSON.stringify output. This approach may be brittle if key order changes. Consider comparing parsed objects (using deepStrictEqual) to ensure robustness.
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable: usefulness confidence = 20% vs. threshold = 50% This comment is suggesting a refactor to make tests more robust against key ordering issues in JSON. However, this is a code quality suggestion, not a bug fix. The current approach using JSON.stringify comparison is actually intentional - the code appears to be testing that the transformation produces a specific JSON string format, not just that the data structure is correct. If the system stores or transmits these as JSON strings, then string comparison is the right approach. The comment is speculative ("may be brittle") and suggests a refactor without clear evidence that the current approach is wrong. According to the rules, I should only keep comments with STRONG EVIDENCE of correctness, and speculative refactoring suggestions should be deleted unless they are clearly actionable and necessary. The comment could be valid if JSON key ordering actually causes test failures in practice. Also, if the attributes are stored as strings (which they appear to be based on the code), then string comparison might be the correct approach to ensure the exact string format is preserved. Looking at the code more carefully, the attributes appear to be stored as strings (the transformation converts objects to JSON strings). Testing the exact string output is appropriate here. The comment is speculative about brittleness without evidence of actual problems, and the suggested change might actually make the tests less accurate if string format matters. This comment should be deleted. It's a speculative code quality suggestion without strong evidence that the current approach is wrong. The tests are validating that JSON strings are produced correctly, which makes string comparison appropriate. The comment doesn't identify a clear bug or required change.
3. packages/traceloop-sdk/test/ai-sdk/ai-sdk-v5-compatibility.test.ts:240
  • Draft comment:
    The test file is quite large and covers many aspects (version detection, tool schema transformation, tool call transformation, integration). Consider splitting these tests into multiple files or using describe blocks more granularly for maintainability.
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable: usefulness confidence = 20% vs. threshold = 50% This comment is about code quality and maintainability, which can be valuable. However, looking at the rules: 1) The file is already organized with describe blocks, 2) This is a subjective opinion about file size/organization, not a clear bug, 3) The comment uses "Consider" which is a soft suggestion, not a required change, 4) The file structure seems reasonable with clear separation of concerns already in place, 5) The rules state "Do NOT comment unless there is clearly a code change required" - this is more of a suggestion than a requirement, 6) The rules also say "Comments that suggest code quality refactors are good! But only if they are actionable and clear" - but this comment is vague about what specifically should be split and how. The comment could be considered actionable since it suggests splitting the file. The file is indeed quite long at 585 lines. Some teams might have conventions about maximum test file sizes. The comment is about maintainability which is a legitimate concern for long-term code health. While the comment is about maintainability, the file is already well-organized with clear describe blocks. The comment is too vague - it doesn't specify what should be split or why the current organization is problematic. It's a subjective opinion rather than pointing to a clear issue. The rules emphasize not making comments unless there's clearly a code change required, and this is more of a "nice to have" suggestion. The file structure appears logical: version detection, tool schema transformation, tool call transformation, and integration tests - these are related concerns that make sense together in a compatibility test file. This comment should be deleted. It's a subjective suggestion about file organization without clear actionable guidance. The file is already well-organized with appropriate describe blocks, and the comment doesn't point to a specific problem that needs fixing. It violates the rule that comments should only be made when there's clearly a code change required.
4. packages/traceloop-sdk/src/lib/tracing/tracing.ts:10
  • Draft comment:
    Typo: The key name "ASSOCATION_PROPERTIES_KEY" seems to be misspelled. Consider correcting it to "ASSOCIATION_PROPERTIES_KEY".
  • Reason this comment was not posted:
    Comment was not on a location in the diff, so it can't be submitted as a review comment.

Workflow ID: wflow_rCezJ06qAXeUqL3J

You can customize Ellipsis by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.

Comment on lines +726 to +733
const getAiSdkVersion = (): string | undefined => {
try {
return require("ai/package.json").version;
} catch {
return undefined;
}
};

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this work? from the picture you added it doesnt

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@doronkopit5 It does work - it is just not added to the scope.
I added it to the spans_attributes as: ai.sdk.version

@nina-kollman nina-kollman merged commit c6655da into main Jan 18, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants