Skip to content

fix(mastra): use Mastra span id as Braintrust row id for logFeedback#2211

Merged
Cedric / ViaDézo1er (viadezo1er) merged 1 commit into
mainfrom
cedric/logfeedback-row-id
Jul 9, 2026
Merged

fix(mastra): use Mastra span id as Braintrust row id for logFeedback#2211
Cedric / ViaDézo1er (viadezo1er) merged 1 commit into
mainfrom
cedric/logfeedback-row-id

Conversation

@viadezo1er

Copy link
Copy Markdown
Contributor

BraintrustObservabilityExporter.onStart let SpanImpl auto-generate the
row id (this._id = eventId ?? idGenerator.getSpanId()), so the id was
unknowable to anyone outside the exporter. A Mastra user calling
logger.logFeedback({ id: }) — or Mastra's score-event
bus forwarding score.spanId — targeted a row that didn't exist, and the
feedback landed as a stray row instead of merging into the generation
it was meant to score.

Pass event: { id: exported.id } on startSpan so the Mastra span id is
used as the Braintrust row id, matching the upstream @mastra/braintrust
fix (mastra-ai/mastra#11927, fixes #11899). The Braintrust span_id is
left auto-generated so W3C trace-context propagation still works for
subspans; only the row id (which logFeedback/mergeRowBatch key on) is
aliased to the Mastra span id.

Adds js/src/wrappers/mastra.test.ts covering both the row-id aliasing
and a subsequent logFeedback merge.

Refs: mastra-ai/mastra#11927

BraintrustObservabilityExporter.onStart let SpanImpl auto-generate the
row id (this._id = eventId ?? idGenerator.getSpanId()), so the id was
unknowable to anyone outside the exporter. A Mastra user calling
logger.logFeedback({ id: <mastra span id> }) — or Mastra's score-event
bus forwarding score.spanId — targeted a row that didn't exist, and the
feedback landed as a stray row instead of merging into the generation
it was meant to score.

Pass event: { id: exported.id } on startSpan so the Mastra span id is
used as the Braintrust row id, matching the upstream @mastra/braintrust
fix (mastra-ai/mastra#11927, fixes #11899). The Braintrust span_id is
left auto-generated so W3C trace-context propagation still works for
subspans; only the row id (which logFeedback/mergeRowBatch key on) is
aliased to the Mastra span id.

Adds js/src/wrappers/mastra.test.ts covering both the row-id aliasing
and a subsequent logFeedback merge.

Refs: mastra-ai/mastra#11927
@viadezo1er Cedric / ViaDézo1er (viadezo1er) marked this pull request as ready for review July 9, 2026 05:04
@viadezo1er Cedric / ViaDézo1er (viadezo1er) merged commit 0762033 into main Jul 9, 2026
48 checks passed
@viadezo1er Cedric / ViaDézo1er (viadezo1er) deleted the cedric/logfeedback-row-id branch July 9, 2026 17:53
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