Skip to content

Conversation

@galkleinman
Copy link
Contributor

@galkleinman galkleinman commented Dec 17, 2025

…input, output)


Important

Add support for AI SDK v5 renamed attributes while maintaining backward compatibility with v4.

  • Behavior:
    • Update transformResponseToolCalls and transformTools in ai-sdk-transformations.ts to support AI SDK v5 attributes inputSchema, input, and output.
    • Prefer v5 attributes (inputSchema, input, output) over v4 (parameters, args, result) when both exist.
  • Tests:
    • Add tests in ai-sdk-transformations.test.ts for v5 compatibility, including tool definitions, tool calls, and prompt transformations.
    • Ensure backward compatibility with v4 is maintained in tests.
  • Misc:
    • No changes to existing v4 functionality; v5 support is additive.

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


Summary by CodeRabbit

  • New Features

    • Added support for AI SDK v5 while preserving v4 compatibility; unified tool/schema handling and normalized tool call semantics across formats.
  • Bug Fixes

    • Improved resilience to malformed inputs with safer parsing and legacy-key cleanup to prevent duplicate attributes.
  • Tests

    • Added comprehensive v5 compatibility tests covering tool definitions, tool calls, mixed-format scenarios, mappings, and telemetry — note: the v5 test suite was unintentionally duplicated.

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

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 17, 2025

Walkthrough

Extends AI SDK transformation logic to support both v4 (parameters/args/result) and v5 (inputSchema/input/output) tool formats, preferring v5 when present, normalizing fields into OpenTelemetry and TRACELOOP attributes, and adding tests for v5 and mixed-format scenarios.

Changes

Cohort / File(s) Summary
AI SDK transformation updates
packages/traceloop-sdk/src/lib/tracing/ai-sdk-transformations.ts
Adds dual-format handling: prefers v5 (inputSchema/input/output) over v4 (parameters/args/result) across tool/schema processing, span/attribute extraction, telemetry metadata, and tool call normalization. Serializes/parsess stringified tools, removes legacy keys after mapping, and wraps JSON parsing in try/catch for robustness.
V5 compatibility tests (added, duplicated)
packages/traceloop-sdk/test/ai-sdk-transformations.test.ts
Introduces an extensive "AI SDK v5 Compatibility" test suite covering tool definition transformation, stringified tools, precedence rules (inputSchema over parameters; input over args), mixed v4/v5 cases, tool call and span mappings, end-to-end scenarios (provider/model/usage/finish reasons), and OpenTelemetry/TRACELOOP attribute assertions. Note: the entire v5 compatibility suite appears inserted twice (duplicate block).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Areas needing extra attention:
    • Precedence logic (ensure inputSchema > parameters, input > args, output > result) is consistently applied everywhere.
    • Correct removal of legacy keys to avoid duplicate attributes.
    • Robustness of JSON parsing/error handling paths.
    • Duplicate test suite entry in ai-sdk-transformations.test.ts — confirm whether duplication is intentional.

Poem

A rabbit hops through formats old and new,
From v4 pathways to v5's clearer view,
It parses strings and tidies every key,
Prefers the fresh, yet keeps the history free,
Hopping onward—transformations, squeak and glee! 🐇✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically summarizes the main change: adding support for AI SDK v5 renamed tool attributes while maintaining backward compatibility with v4.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch gk/fix-ai-sdk-tools

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

@galkleinman galkleinman marked this pull request as ready for review December 17, 2025 19:32
Copy link
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 0f521ea in 1 minute and 45 seconds. Click for details.
  • Reviewed 626 lines of code in 2 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/src/lib/tracing/ai-sdk-transformations.ts:267
  • Draft comment:
    Good job handling the v5 renaming (inputSchema over parameters, input over args, output over result). One minor suggestion: Consider adding explicit type checks and clear comments in these transformation blocks so that future developers immediately recognize that if both v4 and v5 properties are present, the newer one is preferred.
  • Reason this comment was not posted:
    Comment looked like it was already resolved.
2. packages/traceloop-sdk/src/lib/tracing/ai-sdk-transformations.ts:2540
  • Draft comment:
    The transformation for tool calls using the new v5 properties (input vs args, and output vs result) is clear and well tested. Ensure that in scenarios where one of the properties might be an empty string or null, you have a defined contract – currently the code uses a simple truthy check which appears acceptable, but an explicit check could prevent unexpected behavior.
  • 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.
3. packages/traceloop-sdk/test/ai-sdk-transformations.test.ts:2354
  • Draft comment:
    The added tests for v5 compatibility are comprehensive. They cover transformation from string and object formatted tools (inputSchema) and correctly validate that v5 properties override legacy ones. Excellent job keeping the tests readable and structured.
  • Reason this comment was not posted:
    Comment did not seem useful. Confidence is useful = 0% <= threshold 50% This comment is purely informative, praising the comprehensiveness of the tests. It doesn't provide any actionable feedback or suggestions for improvement.
4. packages/traceloop-sdk/test/ai-sdk-transformations.test.ts:2540
  • Draft comment:
    The tests for tool call inputs (v5 renamed args to input) are clear and verify that the newer properties are preferred. Overall, the tests are well thought out and document intended behavior. Consider adding a comment near the test cases that mention the rationale for preferring v5 values for future maintainers.
  • Reason this comment was not posted:
    Comment did not seem useful. Confidence is useful = 0% <= threshold 50% The comment suggests adding a comment for future maintainers, which is purely informative and not a specific code suggestion or request for a test. It doesn't align with the rules for good comments.

Workflow ID: wflow_ZixS4tm4XmtH54zI

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

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/traceloop-sdk/src/lib/tracing/ai-sdk-transformations.ts (1)

1-1: Fix Prettier formatting issues.

The CI pipeline detected Prettier formatting issues. Run pnpm prettier --write to fix them before merging.

📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 8e05349 and 0f521ea.

📒 Files selected for processing (2)
  • packages/traceloop-sdk/src/lib/tracing/ai-sdk-transformations.ts (4 hunks)
  • packages/traceloop-sdk/test/ai-sdk-transformations.test.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
packages/{instrumentation-*,traceloop-sdk}/**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

Import AI/LLM semantic attribute constants from @traceloop/ai-semantic-conventions rather than hardcoding strings

Files:

  • packages/traceloop-sdk/src/lib/tracing/ai-sdk-transformations.ts
  • packages/traceloop-sdk/test/ai-sdk-transformations.test.ts
packages/traceloop-sdk/**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

packages/traceloop-sdk/**/*.{ts,tsx}: Use the provided decorators (@workflow, @task, @agent) for workflow/task/agent spans instead of re-implementing them
For manual LLM operations, use trace.withLLMSpan from @traceloop/node-server-sdk

Files:

  • packages/traceloop-sdk/src/lib/tracing/ai-sdk-transformations.ts
  • packages/traceloop-sdk/test/ai-sdk-transformations.test.ts
🧠 Learnings (6)
📓 Common learnings
Learnt from: CR
Repo: traceloop/openllmetry-js PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-08-24T22:08:07.023Z
Learning: Applies to packages/{instrumentation-*,traceloop-sdk}/**/*.{ts,tsx} : Import AI/LLM semantic attribute constants from traceloop/ai-semantic-conventions rather than hardcoding strings
📚 Learning: 2025-08-24T22:08:07.023Z
Learnt from: CR
Repo: traceloop/openllmetry-js PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-08-24T22:08:07.023Z
Learning: Applies to packages/{instrumentation-*,traceloop-sdk}/**/*.{ts,tsx} : Import AI/LLM semantic attribute constants from traceloop/ai-semantic-conventions rather than hardcoding strings

Applied to files:

  • packages/traceloop-sdk/src/lib/tracing/ai-sdk-transformations.ts
  • packages/traceloop-sdk/test/ai-sdk-transformations.test.ts
📚 Learning: 2025-08-24T22:08:07.023Z
Learnt from: CR
Repo: traceloop/openllmetry-js PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-08-24T22:08:07.023Z
Learning: Applies to packages/instrumentation-*/**/*.{ts,tsx} : Instrumentations must create spans with appropriate AI/LLM semantic attributes for calls they wrap

Applied to files:

  • packages/traceloop-sdk/src/lib/tracing/ai-sdk-transformations.ts
📚 Learning: 2025-08-24T22:08:07.023Z
Learnt from: CR
Repo: traceloop/openllmetry-js PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-08-24T22:08:07.023Z
Learning: Applies to packages/traceloop-sdk/**/*.{ts,tsx} : Use the provided decorators (workflow, task, agent) for workflow/task/agent spans instead of re-implementing them

Applied to files:

  • packages/traceloop-sdk/src/lib/tracing/ai-sdk-transformations.ts
  • packages/traceloop-sdk/test/ai-sdk-transformations.test.ts
📚 Learning: 2025-08-24T22:08:07.023Z
Learnt from: CR
Repo: traceloop/openllmetry-js PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-08-24T22:08:07.023Z
Learning: Applies to packages/traceloop-sdk/**/*.{ts,tsx} : For manual LLM operations, use trace.withLLMSpan from traceloop/node-server-sdk

Applied to files:

  • packages/traceloop-sdk/src/lib/tracing/ai-sdk-transformations.ts
  • packages/traceloop-sdk/test/ai-sdk-transformations.test.ts
📚 Learning: 2025-08-12T13:57:05.901Z
Learnt from: galzilber
Repo: traceloop/openllmetry-js PR: 643
File: packages/traceloop-sdk/test/datasets-final.test.ts:97-105
Timestamp: 2025-08-12T13:57:05.901Z
Learning: The traceloop-sdk uses a response transformer (`transformApiResponse` in `packages/traceloop-sdk/src/lib/utils/response-transformer.ts`) that converts snake_case API responses to camelCase for SDK interfaces. Raw API responses use snake_case but SDK consumers see camelCase fields.

Applied to files:

  • packages/traceloop-sdk/src/lib/tracing/ai-sdk-transformations.ts
🧬 Code graph analysis (2)
packages/traceloop-sdk/src/lib/tracing/ai-sdk-transformations.ts (2)
packages/traceloop-sdk/src/lib/tracing/decorators.ts (1)
  • tool (287-293)
packages/ai-semantic-conventions/src/SemanticAttributes.ts (1)
  • SpanAttributes (17-58)
packages/traceloop-sdk/test/ai-sdk-transformations.test.ts (2)
packages/traceloop-sdk/src/lib/tracing/ai-sdk-transformations.ts (2)
  • transformLLMSpans (672-693)
  • transformAiSdkSpanAttributes (750-756)
packages/ai-semantic-conventions/src/SemanticAttributes.ts (1)
  • SpanAttributes (17-58)
🪛 GitHub Actions: CI
packages/traceloop-sdk/src/lib/tracing/ai-sdk-transformations.ts

[warning] 1-1: Prettier formatting issues detected. Run 'pnpm prettier --write' to fix.

packages/traceloop-sdk/test/ai-sdk-transformations.test.ts

[warning] 1-1: Prettier formatting issues detected. Run 'pnpm prettier --write' to fix.

🔇 Additional comments (5)
packages/traceloop-sdk/src/lib/tracing/ai-sdk-transformations.ts (4)

149-163: LGTM! Clean v5 compatibility implementation.

The dual-format support correctly prioritizes v5 input over v4 args using nullish coalescing, resolves once, and reuses the value consistently.


267-274: LGTM! Consistent v5 schema handling.

The implementation correctly prefers v5 inputSchema over v4 parameters and properly handles both string and object formats.


550-566: LGTM! Comprehensive tool call attribute transformation.

Both argument and result transformations correctly support dual formats, with v5 (input/output) taking precedence over v4 (args/result). The deferred deletion is appropriate since transformToolCalls handles the cleanup.


696-710: LGTM! Complete cleanup of tool call attributes.

The span transformation correctly resolves v5/v4 formats, sets Traceloop entity attributes, and properly cleans up all original attribute variants (both args/input and result/output).

packages/traceloop-sdk/test/ai-sdk-transformations.test.ts (1)

2353-2864: LGTM! Excellent test coverage for v5 compatibility.

The comprehensive test suite validates all aspects of AI SDK v5 support:

  • Tool definitions with inputSchema (object and string formats)
  • Tool calls with input instead of args
  • Tool call spans with input/output instead of args/result
  • Precedence rules when both v4 and v5 formats exist
  • Mixed v4/v5 scenarios for backward compatibility
  • Complete end-to-end v5 transformation flow

The test structure follows existing patterns and thoroughly validates transformation correctness, attribute cleanup, and OpenTelemetry/Traceloop attribute mappings.

Copy link
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 297a7d8 in 1 minute and 28 seconds. Click for details.
  • Reviewed 37 lines of code in 2 files
  • Skipped 0 files when reviewing.
  • Skipped posting 7 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-transformations.test.ts:2353
  • Draft comment:
    The new tests for AI SDK v5 compatibility (testing inputSchema in tools) are very comprehensive. They correctly check that when an object defines an inputSchema, it is transformed into the standardized parameters property. This is clear and follows best practices.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50% None
2. packages/traceloop-sdk/test/ai-sdk-transformations.test.ts:2433
  • Draft comment:
    In the test "should handle AI SDK v5 string format tools with inputSchema", consider adding a comment that highlights the expectation that JSON strings are parsed correctly – this improves code readability for maintainers.
  • Reason this comment was not posted:
    Confidence changes required: 33% <= threshold 50% None
3. packages/traceloop-sdk/test/ai-sdk-transformations.test.ts:2477
  • Draft comment:
    The test "should prefer inputSchema over parameters when both exist" clearly confirms the precedence of the v5 property. It’s a good safeguard against regressions.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50% None
4. packages/traceloop-sdk/test/ai-sdk-transformations.test.ts:2540
  • Draft comment:
    The tests for tool call transformations using the new 'input' property (v5 format) are thorough. They also check that if both 'args' and 'input' exist, the newer 'input' is preferred. This is an appropriate approach.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50% None
5. packages/traceloop-sdk/test/ai-sdk-transformations.test.ts:2674
  • Draft comment:
    The new suite of tests for span attribute transformation—ensuring that 'ai.toolCall.input' is properly mapped to OpenTelemetry attributes—is very comprehensive. The tests also favor v5 properties over legacy ones, which is ideal.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50% None
6. packages/traceloop-sdk/test/ai-sdk-transformations.test.ts:2761
  • Draft comment:
    The complete v5 scenario test is a solid end‐to‐end integration check. It verifies not only tool definition and tool call transformations but also token calculations, vendor mapping, and operation naming. Excellent coverage.
  • Reason this comment was not posted:
    Confidence changes required: 0% <= threshold 50% None
7. packages/traceloop-sdk/test/ai-sdk-transformations.test.ts:2530
  • Draft comment:
    Overall, the v5-related tests are well structured and descriptive. As a minor improvement, consider refactoring shared setup (e.g. JSON parsing of tool definitions or common attribute creation) into helper functions to reduce verbosity and improve maintainability.
  • Reason this comment was not posted:
    Confidence changes required: 33% <= threshold 50% None

Workflow ID: wflow_9pG4Im8pxc2oYj7M

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

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/traceloop-sdk/src/lib/tracing/ai-sdk-transformations.ts (1)

643-662: Major issue: Agent spans ignore v5 tool call format.

Lines 645-646 only check v4 attributes (ai.toolCall.args and ai.toolCall.result) when populating entity input/output for agent spans. This means agent spans using v5 format (ai.toolCall.input and ai.toolCall.output) won't have their entity input/output set correctly.

Apply this diff to support both v4 and v5 formats:

     const inputMessages = attributes[ATTR_GEN_AI_INPUT_MESSAGES];
     const outputMessages = attributes[ATTR_GEN_AI_OUTPUT_MESSAGES];
-    const toolArgs = attributes["ai.toolCall.args"];
-    const toolResult = attributes["ai.toolCall.result"];
+    const toolArgs = attributes["ai.toolCall.input"] ?? attributes["ai.toolCall.args"];
+    const toolResult = attributes["ai.toolCall.output"] ?? attributes["ai.toolCall.result"];

     if (inputMessages || outputMessages) {
🧹 Nitpick comments (1)
packages/traceloop-sdk/test/ai-sdk-transformations.test.ts (1)

2353-2868: Suggest adding test for agent spans with v5 tool call format.

The test suite lacks coverage for agent spans that use v5 tool call attributes (ai.toolCall.input/output) instead of v4 (ai.toolCall.args/result). This scenario is relevant because agent spans may use tool call attributes for entity input/output when messages aren't available (see transformTelemetryMetadata in the implementation).

Consider adding a test like this to validate agent span behavior with v5 format:

it("should set agent entity input/output from v5 tool call attributes", () => {
  const attributes = {
    "ai.telemetry.metadata.agent": "research_assistant",
    "ai.toolCall.input": JSON.stringify({ query: "test" }),
    "ai.toolCall.output": JSON.stringify({ result: "success" }),
  };

  transformLLMSpans(attributes, "research_assistant.agent");

  // Should use v5 attributes for entity input/output
  assert.strictEqual(
    attributes[SpanAttributes.TRACELOOP_ENTITY_INPUT],
    JSON.stringify({ query: "test" }),
  );
  assert.strictEqual(
    attributes[SpanAttributes.TRACELOOP_ENTITY_OUTPUT],
    JSON.stringify({ result: "success" }),
  );
});
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 0f521ea and 297a7d8.

📒 Files selected for processing (2)
  • packages/traceloop-sdk/src/lib/tracing/ai-sdk-transformations.ts (4 hunks)
  • packages/traceloop-sdk/test/ai-sdk-transformations.test.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
packages/{instrumentation-*,traceloop-sdk}/**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

Import AI/LLM semantic attribute constants from @traceloop/ai-semantic-conventions rather than hardcoding strings

Files:

  • packages/traceloop-sdk/src/lib/tracing/ai-sdk-transformations.ts
  • packages/traceloop-sdk/test/ai-sdk-transformations.test.ts
packages/traceloop-sdk/**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

packages/traceloop-sdk/**/*.{ts,tsx}: Use the provided decorators (@workflow, @task, @agent) for workflow/task/agent spans instead of re-implementing them
For manual LLM operations, use trace.withLLMSpan from @traceloop/node-server-sdk

Files:

  • packages/traceloop-sdk/src/lib/tracing/ai-sdk-transformations.ts
  • packages/traceloop-sdk/test/ai-sdk-transformations.test.ts
🧠 Learnings (7)
📓 Common learnings
Learnt from: CR
Repo: traceloop/openllmetry-js PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-08-24T22:08:07.023Z
Learning: Applies to packages/{instrumentation-*,traceloop-sdk}/**/*.{ts,tsx} : Import AI/LLM semantic attribute constants from traceloop/ai-semantic-conventions rather than hardcoding strings
Learnt from: galzilber
Repo: traceloop/openllmetry-js PR: 643
File: packages/traceloop-sdk/test/datasets-final.test.ts:129-143
Timestamp: 2025-08-12T13:57:42.538Z
Learning: The Traceloop SDK includes a response transformer utility (transformApiResponse) that automatically converts snake_case API responses to camelCase for SDK consumers. This means interface definitions and tests should use camelCase field names (like datasetId, datasetSlug, createdAt, updatedAt) rather than the raw API's snake_case format.
📚 Learning: 2025-08-24T22:08:07.023Z
Learnt from: CR
Repo: traceloop/openllmetry-js PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-08-24T22:08:07.023Z
Learning: Applies to packages/{instrumentation-*,traceloop-sdk}/**/*.{ts,tsx} : Import AI/LLM semantic attribute constants from traceloop/ai-semantic-conventions rather than hardcoding strings

Applied to files:

  • packages/traceloop-sdk/src/lib/tracing/ai-sdk-transformations.ts
  • packages/traceloop-sdk/test/ai-sdk-transformations.test.ts
📚 Learning: 2025-08-24T22:08:07.023Z
Learnt from: CR
Repo: traceloop/openllmetry-js PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-08-24T22:08:07.023Z
Learning: Applies to packages/traceloop-sdk/**/*.{ts,tsx} : For manual LLM operations, use trace.withLLMSpan from traceloop/node-server-sdk

Applied to files:

  • packages/traceloop-sdk/src/lib/tracing/ai-sdk-transformations.ts
📚 Learning: 2025-08-24T22:08:07.023Z
Learnt from: CR
Repo: traceloop/openllmetry-js PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-08-24T22:08:07.023Z
Learning: Applies to packages/instrumentation-*/**/*.{ts,tsx} : Instrumentations must create spans with appropriate AI/LLM semantic attributes for calls they wrap

Applied to files:

  • packages/traceloop-sdk/src/lib/tracing/ai-sdk-transformations.ts
📚 Learning: 2025-08-24T22:08:07.023Z
Learnt from: CR
Repo: traceloop/openllmetry-js PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-08-24T22:08:07.023Z
Learning: Applies to packages/traceloop-sdk/**/*.{ts,tsx} : Use the provided decorators (workflow, task, agent) for workflow/task/agent spans instead of re-implementing them

Applied to files:

  • packages/traceloop-sdk/src/lib/tracing/ai-sdk-transformations.ts
📚 Learning: 2025-08-12T13:57:05.901Z
Learnt from: galzilber
Repo: traceloop/openllmetry-js PR: 643
File: packages/traceloop-sdk/test/datasets-final.test.ts:97-105
Timestamp: 2025-08-12T13:57:05.901Z
Learning: The traceloop-sdk uses a response transformer (`transformApiResponse` in `packages/traceloop-sdk/src/lib/utils/response-transformer.ts`) that converts snake_case API responses to camelCase for SDK interfaces. Raw API responses use snake_case but SDK consumers see camelCase fields.

Applied to files:

  • packages/traceloop-sdk/src/lib/tracing/ai-sdk-transformations.ts
📚 Learning: 2025-08-24T22:08:07.023Z
Learnt from: CR
Repo: traceloop/openllmetry-js PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-08-24T22:08:07.023Z
Learning: Applies to packages/ai-semantic-conventions/src/SemanticAttributes.ts : Define all AI/LLM span attribute constants in packages/ai-semantic-conventions/src/SemanticAttributes.ts

Applied to files:

  • packages/traceloop-sdk/src/lib/tracing/ai-sdk-transformations.ts
🧬 Code graph analysis (2)
packages/traceloop-sdk/src/lib/tracing/ai-sdk-transformations.ts (2)
packages/traceloop-sdk/src/lib/tracing/decorators.ts (1)
  • tool (287-293)
packages/ai-semantic-conventions/src/SemanticAttributes.ts (1)
  • SpanAttributes (17-58)
packages/traceloop-sdk/test/ai-sdk-transformations.test.ts (2)
packages/traceloop-sdk/src/lib/tracing/ai-sdk-transformations.ts (2)
  • transformLLMSpans (671-692)
  • transformAiSdkSpanAttributes (749-755)
packages/ai-semantic-conventions/src/SemanticAttributes.ts (1)
  • SpanAttributes (17-58)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Build and test
🔇 Additional comments (5)
packages/traceloop-sdk/src/lib/tracing/ai-sdk-transformations.ts (4)

149-163: LGTM! Correct v5 compatibility for tool call arguments.

The implementation correctly prefers v5 input over v4 args using nullish coalescing and maintains backward compatibility. The extracted toolArgs is consistently used in both attribute assignments and the tool call structure.


267-273: LGTM! Correct v5 compatibility for tool schema.

The implementation correctly prefers v5 inputSchema over v4 parameters using nullish coalescing and maintains backward compatibility. The schema is properly serialized regardless of whether it's already a string.


549-565: LGTM! Correct v5 compatibility for tool call attributes.

The implementation correctly handles both v5 (input/output) and v4 (args/result) formats, preferring v5 when present. The comment explaining deferred deletion is helpful for understanding the transformation flow.


694-719: LGTM! Correct v5 compatibility and cleanup in tool call transformation.

The implementation correctly derives toolInput and toolOutput from either v5 or v4 formats, properly sets the Traceloop entity attributes, and cleanly removes all original attributes (both v4 and v5) to prevent duplication.

packages/traceloop-sdk/test/ai-sdk-transformations.test.ts (1)

2353-2868: Comprehensive v5 compatibility test suite.

The test suite thoroughly covers all v5 renamed attributes (inputSchema, input, output), validates preference for v5 over v4 formats, tests mixed format handling, and includes a complete end-to-end v5 scenario. The tests are well-structured and properly verify attribute transformations and cleanup.

@galkleinman galkleinman merged commit 46d8993 into main Dec 17, 2025
8 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.

3 participants