File tree Expand file tree Collapse file tree 3 files changed +16
-16
lines changed Expand file tree Collapse file tree 3 files changed +16
-16
lines changed Original file line number Diff line number Diff line change @@ -128,14 +128,6 @@ export async function createChatStreamResponse(
128
128
searchMode
129
129
} )
130
130
131
- // Write metadata including traceId at the start of streaming
132
- if ( parentTraceId ) {
133
- writer . write ( {
134
- type : 'message-metadata' ,
135
- messageMetadata : { traceId : parentTraceId }
136
- } )
137
- }
138
-
139
131
// Filter out reasoning parts from messages before converting to model messages
140
132
// OpenAI API requires reasoning messages to be followed by assistant messages
141
133
const filteredMessages = filterReasoningParts ( messagesToModel )
@@ -215,7 +207,9 @@ export async function createChatStreamResponse(
215
207
chatId ,
216
208
userId ,
217
209
titlePromise ,
218
- parentTraceId
210
+ parentTraceId ,
211
+ searchMode ,
212
+ context . modelId
219
213
)
220
214
}
221
215
} )
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ import { UIMessage } from 'ai'
2
2
3
3
import { upsertMessage } from '@/lib/actions/chat'
4
4
import { updateChatTitle } from '@/lib/db/actions'
5
+ import { SearchMode } from '@/lib/types/search'
5
6
import { perfTime } from '@/lib/utils/perf-logging'
6
7
import { retryDatabaseOperation } from '@/lib/utils/retry'
7
8
@@ -12,14 +13,16 @@ export async function persistStreamResults(
12
13
chatId : string ,
13
14
userId : string ,
14
15
titlePromise ?: Promise < string > ,
15
- parentTraceId ?: string
16
+ parentTraceId ?: string ,
17
+ searchMode ?: SearchMode ,
18
+ modelId ?: string
16
19
) {
17
- // Attach metadata to the response message if we have a traceId
18
- if ( parentTraceId ) {
19
- responseMessage . metadata = {
20
- ...( responseMessage . metadata || { } ) ,
21
- traceId : parentTraceId
22
- }
20
+ // Attach metadata to the response message
21
+ responseMessage . metadata = {
22
+ ... ( responseMessage . metadata || { } ) ,
23
+ ...( parentTraceId && { traceId : parentTraceId } ) ,
24
+ ... ( searchMode && { searchMode } ) ,
25
+ ... ( modelId && { modelId } )
23
26
}
24
27
25
28
// Wait for title generation if it was started
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ import { fetchTool } from '@/lib/tools/fetch'
5
5
import { askQuestionTool } from '@/lib/tools/question'
6
6
import { searchTool } from '@/lib/tools/search'
7
7
import { createTodoTools , type TodoItem } from '@/lib/tools/todo'
8
+ import type { SearchMode } from '@/lib/types/search'
8
9
9
10
// Re-export TodoItem for external use
10
11
export type { TodoItem }
@@ -13,6 +14,8 @@ export type { TodoItem }
13
14
export interface UIMessageMetadata {
14
15
traceId ?: string
15
16
feedbackScore ?: number | null
17
+ searchMode ?: SearchMode
18
+ modelId ?: string
16
19
[ key : string ] : any
17
20
}
18
21
You can’t perform that action at this time.
0 commit comments