-
-
Notifications
You must be signed in to change notification settings - Fork 585
fix: ag UI feedback metadata stream #1076
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
dd1e62a
fix(ag-ui): preserve feedback metadata in AG-UI streams
omeraplak 81c8de5
refactor(ag-ui): emit custom event for message metadata
omeraplak 588139c
refactor(ag-ui): remove legacy metadata tool-result emit
omeraplak 60cf126
refactor(ag-ui): remove legacy metadata marker filter
omeraplak caf52cb
Merge remote-tracking branch 'origin/main' into fix/ag-ui-feedback-me…
omeraplak a5e7c7b
chore: update docs
omeraplak File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add URL validation to prevent SSRF attacks.
The function makes a POST request to
feedback.urlwithout validating that the URL belongs to a trusted origin. If the metadata stream is compromised or misconfigured, this could allow an attacker to make arbitrary POST requests from the client to any URL (SSRF).🛡️ Proposed fix with origin validation
📝 Committable suggestion
🤖 Prompt for AI Agents
Add error handling for network and parsing failures.
The function lacks try-catch blocks around the
fetchcall andresponse.json()parsing. Network failures, timeouts, or malformed JSON responses would result in unhandled promise rejections. This could lead to silent failures where users believe their feedback was submitted but it actually failed.🛡️ Proposed fix with error handling
async function submitVoltFeedback(input: { message: Message; type: "thumbsUp" | "thumbsDown"; feedbackByMessageId: Record<string, VoltFeedbackMetadata>; setFeedbackByMessageId: Dispatch<SetStateAction<Record<string, VoltFeedbackMetadata>>>; }) { const feedback = input.feedbackByMessageId[input.message.id]; if (!feedback?.url || isProvided(feedback)) return; const score = input.type === "thumbsUp" ? 1 : 0; + try { - const response = await fetch(feedback.url, { + const response = await fetch(feedback.url, { - method: "POST", + method: "POST", - headers: { "Content-Type": "application/json" }, + headers: { "Content-Type": "application/json" }, - body: safeStringify({ + body: safeStringify({ - score, + score, - feedback_source_type: "app", + feedback_source_type: "app", - }), + }), - }); + signal: AbortSignal.timeout(5000), // 5s timeout + }); - if (!response.ok) return; + if (!response.ok) { + console.error('Feedback submission failed:', response.status); + return; + } - const data = (await response.json()) as { id?: string }; - setFeedbackByMessageId((prev) => ({ + const data = (await response.json()) as { id?: string }; + input.setFeedbackByMessageId((prev) => ({ - ...prev, + ...prev, - [input.message.id]: { + [input.message.id]: { - ...feedback, + ...feedback, - provided: true, + provided: true, - feedbackId: data.id, + feedbackId: data.id, - }, + }, - })); + })); + } catch (error) { + console.error('Failed to submit feedback:', error); + // Optionally: show user notification + } }📝 Committable suggestion
🤖 Prompt for AI Agents