fix(mastra): use Mastra span id as Braintrust row id for logFeedback#2211
Draft
Cedric / ViaDézo1er (viadezo1er) wants to merge 1 commit into
Draft
fix(mastra): use Mastra span id as Braintrust row id for logFeedback#2211Cedric / ViaDézo1er (viadezo1er) wants to merge 1 commit into
Cedric / ViaDézo1er (viadezo1er) wants to merge 1 commit into
Conversation
a032440 to
0d1a642
Compare
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
0d1a642 to
a27ebf6
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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