Skip to content

fix: keep streaming message ids consistent with memory by emitting `m…#1022

Open
omeraplak wants to merge 1 commit intomainfrom
fix/message-id-streaming
Open

fix: keep streaming message ids consistent with memory by emitting `m…#1022
omeraplak wants to merge 1 commit intomainfrom
fix/message-id-streaming

Conversation

@omeraplak
Copy link
Member

@omeraplak omeraplak commented Feb 5, 2026

…essageId`

PR Checklist

Please check if your PR fulfills the following requirements:

Bugs / Features

What is the current behavior?

What is the new behavior?

fixes (issue)

Notes for reviewers


Summary by cubic

Ensures streaming message IDs stay consistent with memory by emitting messageId on start/start-step parts and using it for UI stream mapping. Fixes #1021 to prevent mismatched messages during live updates.

  • Bug Fixes
    • Core agent adds response messageId to start/start-step stream parts (text-part ids unchanged).
    • AG UI tracks current messageId and applies it to text-delta events for correct message mapping.
    • Workflow stream includes messageId in metadata; types, docs, and tests updated.

Written for commit 259d207. Summary will update on new commits.

Summary by CodeRabbit

  • Bug Fixes

    • Enhanced message ID propagation in streaming responses; messageId now properly emitted on start/step chunks to enable improved UI stream mapping while maintaining text element IDs intact.
  • Documentation

    • Updated API documentation and type definitions to reflect new messageId field support in streaming types.

@changeset-bot
Copy link

changeset-bot bot commented Feb 5, 2026

🦋 Changeset detected

Latest commit: 259d207

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@voltagent/ag-ui Patch
@voltagent/core Patch

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

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 5, 2026

📝 Walkthrough

Walkthrough

This PR introduces messageId propagation through the streaming response pipeline. It adds an optional messageId field to stream parts, creates a helper to inject messageId into start/start-step chunks, applies this in the agent's streamText path, and updates the UI adapter to use this ID for text-delta mapping while preserving text-part IDs.

Changes

Cohort / File(s) Summary
Streaming type and metadata infrastructure
packages/core/src/agent/subagent/types.ts, packages/core/src/workflow/stream.ts
Adds optional messageId field to VoltAgentTextStreamPart type and propagates messageId from stream parts into metadata alongside existing fields.
Agent streaming logic
packages/core/src/agent/agent.ts
Introduces applyResponseMessageIdToStream helper that wraps streams to inject responseMessageId into start/start-step parts and applies this transformation in the streamText path.
UI adapter
packages/ag-ui/src/voltagent-agent.ts
Updates to track currentMessageId from start/start-step chunks and derive messageId for text-delta parts using part.messageId ?? fallbackMessageId.
Tests and changelog
.changeset/quiet-rockets-work.md, packages/core/src/agent/agent.spec.ts
Adds changeset documenting patch bumps for @voltagent/ag-ui and @voltagent/core and updates stream test to yield initial start event with messageId validation.
Documentation
website/docs/agents/message-types.md, website/docs/api/streaming.md
Documents optional messageId field in VoltAgentTextStreamPart type and updates streaming comment to include start event type.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Poem

🐰 Hops through the stream with pride,
A messageId along for the ride,
From start to text, the ID flows true,
Mapping UI chunks, old and new! 🎯

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: ensuring streaming message IDs are consistent by emitting messageId, which aligns with the changeset and code modifications across multiple packages.
Description check ✅ Passed The description includes all required sections from the template with substantive content: checklist completion, related issue linkage, test and documentation updates, changeset creation, and a detailed technical summary of the fix.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/message-id-streaming

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@joggrbot

This comment has been minimized.

@cloudflare-workers-and-pages
Copy link

Deploying voltagent with  Cloudflare Pages  Cloudflare Pages

Latest commit: 259d207
Status: ✅  Deploy successful!
Preview URL: https://c6db6119.voltagent.pages.dev
Branch Preview URL: https://fix-message-id-streaming.voltagent.pages.dev

View logs

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 8 files

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant