Skip to content

fix(mastra): transform LLM input/output for Braintrust Thread view#2213

Draft
Cedric / ViaDézo1er (viadezo1er) wants to merge 1 commit into
mainfrom
cedric/thread-view-llm-io-transform
Draft

fix(mastra): transform LLM input/output for Braintrust Thread view#2213
Cedric / ViaDézo1er (viadezo1er) wants to merge 1 commit into
mainfrom
cedric/thread-view-llm-io-transform

Conversation

@viadezo1er

Copy link
Copy Markdown
Contributor

MODEL_GENERATION spans logged input/output verbatim, so Braintrust's
Thread view could not render them as a conversation. Unwrap input from
{ messages: [...] } into a bare chat-message array (and wrap a single
{ role, content } object), and reshape output { text, ...rest } into
{ role: 'assistant', content: text, ...rest }. Non-model spans are
unchanged.

Ports mastra-ai/mastra#10794 (fixes #9848). Adds js/src/wrappers/
mastra.test.ts and regenerates the mastra-instrumentation e2e snapshots.
The richer per-message AI-SDK->OpenAI conversion (convertAISDKMessage)
is tracked separately as thread-view-tool-call-rendering.

MODEL_GENERATION spans logged input/output verbatim, so Braintrust's
Thread view could not render them as a conversation. Unwrap input from
{ messages: [...] } into a bare chat-message array (and wrap a single
{ role, content } object), and reshape output { text, ...rest } into
{ role: 'assistant', content: text, ...rest }. Non-model spans are
unchanged.

Ports mastra-ai/mastra#10794 (fixes #9848). Adds js/src/wrappers/
mastra.test.ts and regenerates the mastra-instrumentation e2e snapshots.
The richer per-message AI-SDK->OpenAI conversion (convertAISDKMessage)
is tracked separately as thread-view-tool-call-rendering.
@viadezo1er Cedric / ViaDézo1er (viadezo1er) force-pushed the cedric/thread-view-llm-io-transform branch from 5966a4f to ecad03f Compare July 8, 2026 02:40
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.

1 participant