Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .changeset/mastra-thread-view-llm-io.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
"braintrust": patch
---

fix(mastra): Transform LLM input/output for the Braintrust Thread view

`MODEL_GENERATION` spans from the Mastra observability exporter now log input
as a bare chat-message array (unwrapping Mastra's `{ messages: [...] }`
container, or wrapping a single `{ role, content }` object) and output as an
`{ role: 'assistant', content }` message (unwrapping Mastra's `{ text, ... }`),
so Braintrust's Thread view renders the conversation correctly. Non-model spans
are unchanged.

Ports mastra-ai/mastra#10794 (fixes #9848).
Original file line number Diff line number Diff line change
Expand Up @@ -31,28 +31,26 @@
"type": "task"
},
{
"input": {
"messages": [
{
"content": "Answer weather questions with the provided mock forecast.",
"role": "system"
},
{
"content": [
{
"providerOptions": {
"mastra": {
"createdAt": 0
}
},
"text": "What is the weather in Paris?",
"type": "text"
}
],
"role": "user"
}
]
},
"input": [
{
"content": "Answer weather questions with the provided mock forecast.",
"role": "system"
},
{
"content": [
{
"providerOptions": {
"mastra": {
"createdAt": 0
}
},
"text": "What is the weather in Paris?",
"type": "text"
}
],
"role": "user"
}
],
"metadata": {
"entity_id": "weather-agent",
"entity_name": "Weather Agent",
Expand All @@ -67,10 +65,11 @@
],
"name": "llm: 'mock-model-id'",
"output": {
"content": "The forecast is sunny.",
"files": [],
"reasoning": [],
"role": "assistant",
"sources": [],
"text": "The forecast is sunny.",
"warnings": []
},
"type": "llm"
Expand Down Expand Up @@ -131,28 +130,26 @@
"type": "task"
},
{
"input": {
"messages": [
{
"content": "Answer weather questions with the provided mock forecast.",
"role": "system"
},
{
"content": [
{
"providerOptions": {
"mastra": {
"createdAt": 0
}
},
"text": "Stream the Paris forecast.",
"type": "text"
}
],
"role": "user"
}
]
},
"input": [
{
"content": "Answer weather questions with the provided mock forecast.",
"role": "system"
},
{
"content": [
{
"providerOptions": {
"mastra": {
"createdAt": 0
}
},
"text": "Stream the Paris forecast.",
"type": "text"
}
],
"role": "user"
}
],
"metadata": {
"entity_id": "weather-agent",
"entity_name": "Weather Agent",
Expand All @@ -167,10 +164,11 @@
],
"name": "llm: 'mock-model-id'",
"output": {
"content": "The forecast is sunny.",
"files": [],
"reasoning": [],
"role": "assistant",
"sources": [],
"text": "The forecast is sunny.",
"warnings": []
},
"type": "llm"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,33 +49,32 @@
]
}
],
"input": {
"messages": [
{
"content": "Answer weather questions with the provided mock forecast.",
"role": "system"
},
{
"content": [
{
"providerOptions": {
"mastra": {
"createdAt": 0
}
},
"text": "What is the weather in Paris?",
"type": "text"
}
],
"role": "user"
}
]
},
"input": [
{
"content": "Answer weather questions with the provided mock forecast.",
"role": "system"
},
{
"content": [
{
"providerOptions": {
"mastra": {
"createdAt": 0
}
},
"text": "What is the weather in Paris?",
"type": "text"
}
],
"role": "user"
}
],
"output": {
"content": "The forecast is sunny.",
"files": [],
"reasoning": [],
"role": "assistant",
"sources": [],
"text": "The forecast is sunny.",
"warnings": []
},
"metadata": {
Expand Down Expand Up @@ -145,33 +144,32 @@
]
}
],
"input": {
"messages": [
{
"content": "Answer weather questions with the provided mock forecast.",
"role": "system"
},
{
"content": [
{
"providerOptions": {
"mastra": {
"createdAt": 0
}
},
"text": "Stream the Paris forecast.",
"type": "text"
}
],
"role": "user"
}
]
},
"input": [
{
"content": "Answer weather questions with the provided mock forecast.",
"role": "system"
},
{
"content": [
{
"providerOptions": {
"mastra": {
"createdAt": 0
}
},
"text": "Stream the Paris forecast.",
"type": "text"
}
],
"role": "user"
}
],
"output": {
"content": "The forecast is sunny.",
"files": [],
"reasoning": [],
"role": "assistant",
"sources": [],
"text": "The forecast is sunny.",
"warnings": []
},
"metadata": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,33 +19,32 @@ span_tree:
│ │ "entity_type": "agent"
│ │ }
│ │ └── llm: 'mock-model-id' [llm]
│ │ input: {
│ │ "messages": [
│ │ {
│ │ "content": "Answer weather questions with the provided mock forecast.",
│ │ "role": "system"
│ │ },
│ │ {
│ │ "content": [
│ │ {
│ │ "providerOptions": {
│ │ "mastra": {
│ │ "createdAt": 0
│ │ }
│ │ },
│ │ "text": "What is the weather in Paris?",
│ │ "type": "text"
│ │ }
│ │ ],
│ │ "role": "user"
│ │ }
│ │ ]
│ │ }
│ │ input: [
│ │ {
│ │ "content": "Answer weather questions with the provided mock forecast.",
│ │ "role": "system"
│ │ },
│ │ {
│ │ "content": [
│ │ {
│ │ "providerOptions": {
│ │ "mastra": {
│ │ "createdAt": 0
│ │ }
│ │ },
│ │ "text": "What is the weather in Paris?",
│ │ "type": "text"
│ │ }
│ │ ],
│ │ "role": "user"
│ │ }
│ │ ]
│ │ output: {
│ │ "content": "The forecast is sunny.",
│ │ "files": [],
│ │ "reasoning": [],
│ │ "role": "assistant",
│ │ "sources": [],
│ │ "text": "The forecast is sunny.",
│ │ "warnings": []
│ │ }
│ │ metadata: {
Expand Down Expand Up @@ -96,33 +95,32 @@ span_tree:
│ │ "entity_type": "agent"
│ │ }
│ │ └── llm: 'mock-model-id' [llm]
│ │ input: {
│ │ "messages": [
│ │ {
│ │ "content": "Answer weather questions with the provided mock forecast.",
│ │ "role": "system"
│ │ },
│ │ {
│ │ "content": [
│ │ {
│ │ "providerOptions": {
│ │ "mastra": {
│ │ "createdAt": 0
│ │ }
│ │ },
│ │ "text": "Stream the Paris forecast.",
│ │ "type": "text"
│ │ }
│ │ ],
│ │ "role": "user"
│ │ }
│ │ ]
│ │ }
│ │ input: [
│ │ {
│ │ "content": "Answer weather questions with the provided mock forecast.",
│ │ "role": "system"
│ │ },
│ │ {
│ │ "content": [
│ │ {
│ │ "providerOptions": {
│ │ "mastra": {
│ │ "createdAt": 0
│ │ }
│ │ },
│ │ "text": "Stream the Paris forecast.",
│ │ "type": "text"
│ │ }
│ │ ],
│ │ "role": "user"
│ │ }
│ │ ]
│ │ output: {
│ │ "content": "The forecast is sunny.",
│ │ "files": [],
│ │ "reasoning": [],
│ │ "role": "assistant",
│ │ "sources": [],
│ │ "text": "The forecast is sunny.",
│ │ "warnings": []
│ │ }
│ │ metadata: {
Expand Down
Loading
Loading