fix: validate UI/response messages and keep streaming response messag…#1016
fix: validate UI/response messages and keep streaming response messag…#1016
Conversation
…e IDs consistent across streams
🦋 Changeset detectedLatest commit: 12235df The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 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 |
|
Caution Review failedThe pull request is closed. 📝 WalkthroughWalkthroughAdds pre-created streaming UI message IDs in the core agent and validates incoming UI messages; updates Postgres and Supabase memory adapters to upsert messages by (conversation_id, message_id); and adds tests asserting placeholder message persistence and ID forwarding to UI streams. Changes
Sequence Diagram(s)sequenceDiagram
actor Client
participant Agent as Core Agent
participant Memory as Memory Adapter
participant DB as Database
participant UI as UI Stream
Client->>Agent: generateText / streamText(input)
Agent->>Agent: validateIncomingUIMessages(input)
Agent->>Agent: ensureStreamingResponseMessageId()
Agent->>Memory: saveMessage(placeholder streaming message)
Memory->>DB: upsert (conversation_id, message_id)
DB-->>Memory: persisted
Memory-->>Agent: return messageId
Agent->>UI: streamText with applied messageId
UI-->>Client: streamed response messages (with stable message_id)
Estimated Code Review Effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@packages/core/src/agent/agent.ts`:
- Line 1467: ensureStreamingResponseMessageId currently returns null when
memory/user/conversation is missing, causing unstable UI stream IDs; change it
to always generate and return a stable responseMessageId and cache it in the
in-memory buffer, but only persist to the conversation/memory store when those
are present. Update the implementation in ensureStreamingResponseMessageId (and
the similar logic in the block referenced at lines ~3289-3318) to: 1) generate a
deterministic/new UUID for the streaming response when none exists, 2) store it
in the provided buffer/session cache so subsequent calls return the same ID, and
3) conditionally call the persistence path (saving to conversation or memory)
only if user/conversation/memory are available.
Deploying voltagent with
|
| Latest commit: |
a9584b6
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://0506b713.voltagent.pages.dev |
| Branch Preview URL: | https://fix-stream-persist.voltagent.pages.dev |
…e IDs consistent across streams
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 responses use a stable message ID across UI streams and validates UI messages to prevent malformed data. Also prevents duplicate message insert errors in Postgres and Supabase. Resolves #1010.
Written for commit 12235df. Summary will update on new commits.
Summary by CodeRabbit
Bug Fixes
Tests
Chores