Skip to content

An AI-powered search engine with a generative UI

Fix feedback button not showing after streaming completes

Yoshiki Miura3fd4add56fe6
diff --git a/lib/streaming/create-chat-stream-response.ts b/lib/streaming/create-chat-stream-response.ts
index 670ca214..a32fac41 100644
--- a/lib/streaming/create-chat-stream-response.ts
+++ b/lib/streaming/create-chat-stream-response.ts
@@ -163,8 +163,19 @@ export async function createChatStreamResponse(
const result = researchAgent.stream({ messages: modelMessages })
result.consumeStream()
- // Stream with the research agent
- writer.merge(result.toUIMessageStream())
+ // Stream with the research agent, including metadata
+ writer.merge(result.toUIMessageStream({
+ messageMetadata: ({ part }) => {
+ // Send metadata when streaming starts
+ if (part.type === 'start') {
+ return {
+ traceId: parentTraceId,
+ searchMode,
+ modelId: context.modelId
+ }
+ }
+ }
+ }))
const responseMessages = (await result.response).messages
// Generate related questions