fix(core): keep part timestamps out of message ordering#17598
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🦋 Changeset detectedLatest commit: 50bbcda The changes in this PR will be included in the next version bump. This PR includes changesets to release 23 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (5)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (4)
WalkthroughFixes transcript ordering so only message-level ChangesMessage watermark and merge timestamp semantics
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
PR triageLinked issue check skipped for core contributor @TylerBarnes. PR complexity score
Applied label: Changed test gateChanged tests failed against the base branch as expected. Label: |
Avoid advancing message ordering watermarks from recalled memory part timestamps, and keep merged assistant messages anchored to their original createdAt. This prevents saved memory messages from drifting across reloads and disrupting prompt cache stability. Co-Authored-By: Mastra Code (openai/gpt-5.5) <noreply@mastra.ai>
Use message-level createdAt as the only source for the MessageList ordering watermark so part-level event timestamps cannot advance later transcript messages or signals. This preserves OM observation boundaries while keeping part timestamps as intra-message metadata. Adds regression coverage for a memory-loaded assistant message promoted back to response with a late part timestamp, followed by an active signal. Co-Authored-By: Mastra Code (openai/gpt-5.5) <noreply@mastra.ai>
Update the signal ordering regression test to match the message-level ordering watermark behavior. Signals now advance from the containing message timestamp, not from later part-level event timestamps. Co-Authored-By: Mastra Code (openai/gpt-5.5) <noreply@mastra.ai>
96a9306 to
50bbcda
Compare
This keeps message part timestamps from affecting transcript ordering. Part timestamps are still preserved as event metadata, but only the message-level
createdAtadvances the ordering watermark used for later messages/signals.Before, a late part timestamp could push a later signal forward:
After, later messages/signals are ordered from the message-level timestamp:
Also preserves the existing message-level
createdAtwhen merging response content into a memory-loaded assistant message, since OM uses that timestamp to decide whether a message has already been observed.Verified with the focused message-list regression test,
pnpm build:core, andpnpm --filter ./packages/core check.ELI5
Imagine you're organizing messages by time. This PR fixes a bug where a late timestamp on a piece of a message (a "part") could reorder later messages — now only the main message timestamp controls ordering, while part timestamps are preserved as metadata and no longer affect transcript ordering.
Changes
Changeset Entry (.changeset/old-news-press.md)
@mastra/coredescribing the fix: message-part timestamps no longer advance the transcript ordering watermark.Message Merging (packages/core/src/agent/message-list/merge/MessageMerger.ts)
createdAtwhen merging incoming content; removed logic that would update/advancecreatedAtfrom the incoming message.createdAtmust remain unchanged so previously observed messages are not reprocessed.Message List Ordering (packages/core/src/agent/message-list/message-list.ts)
MessageList.updateLastCreatedAtnow advances the ordering watermark using only message-levelcreatedAt.lastCreatedAtis the message-level ordering timestamp.Tests (packages/core/src/agent/message-list/tests)
createdAt.Verification
pnpm build:core(runs turbo build --filter ./packages/core) andpnpm --filter ./packages/core check(typecheck/check step used in CI).