Skip to content

feat(ai-sdk): Trace code mode - #2637

Merged
Luca Forstner (lforst) merged 5 commits into
mainfrom
lforst/dum-e/seoul-095303b0bb
Oct 20, 2026
Merged

Luca Forstner (lforst) merged 5 commits into
mainfrom
lforst/dum-e/seoul-095303b0bb

Conversation

@lforst

@lforst Luca Forstner (lforst) commented Oct 19, 2026 •

Copy link
Copy Markdown
Member
  • Add tracing for @ai-sdk/code-mode, capturing executed JavaScript and nesting the functions it calls underneath the execution.
  • Extend wrapAISDK to trace direct code-mode calls without a loader hook:
    import * as codeMode from "@ai-sdk/code-mode";
    import { wrapAISDK } from "braintrust";
    
    // Now supports code-mode execution.
    const { experimental_runCodeMode } = wrapAISDK(codeMode);
  • Start tool traces before running the tool so nested calls attach to the correct parent and synchronous errors are captured.
  • Avoid duplicate traces when automatic instrumentation and explicit Braintrust telemetry are both enabled.

Example trace: https://www.braintrust.dev/app/Braintrust%20SDKs/p/tmp-luca/logs?r=586cb08b3efce34c640c3f045f83b40a&sid=22ffb096f6fc1e7e&tvt=trace

Screenshot 2026-10-19 at 12 46 37

@lforst
Luca Forstner (lforst) merged commit 7592e13 into main Oct 20, 2026
57 checks passed
@lforst
Luca Forstner (lforst) deleted the lforst/dum-e/seoul-095303b0bb branch October 20, 2026 09:54
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