@@ -50,14 +50,8 @@ private static JsonSerializerOptions CombineJsonSerializerOptions(JsonSerializer
5050 return AGUIJsonSerializerContext . Default . Options ;
5151 }
5252
53- // Create a new JsonSerializerOptions based on the provided one
5453 var combinedOptions = new JsonSerializerOptions ( jsonSerializerOptions ) ;
55-
56- // Add the AGUI context to the type info resolver chain if not already present
57- if ( ! combinedOptions . TypeInfoResolverChain . Any ( r => r == AGUIJsonSerializerContext . Default ) )
58- {
59- combinedOptions . TypeInfoResolverChain . Insert ( 0 , AGUIJsonSerializerContext . Default ) ;
60- }
54+ combinedOptions . TypeInfoResolverChain . Add ( AGUIJsonSerializerContext . Default ) ;
6155
6256 return combinedOptions ;
6357 }
@@ -107,7 +101,7 @@ public async override IAsyncEnumerable<ChatResponseUpdate> GetStreamingResponseA
107101 if ( conversationId == null && firstUpdate == null )
108102 {
109103 firstUpdate = update ;
110- if ( firstUpdate . AdditionalProperties != null && firstUpdate . AdditionalProperties . TryGetValue ( "agui_thread_id" , out var threadIdObj ) && threadIdObj is string threadId )
104+ if ( firstUpdate . AdditionalProperties ? . TryGetValue ( "agui_thread_id" , out string ? threadId ) is true )
111105 {
112106 // Capture the thread id from the first update to use as conversation id if none was provided
113107 conversationId = threadId ;
@@ -170,7 +164,7 @@ public AGUIChatClientHandler(
170164 Uri metadataUri = string . IsNullOrEmpty ( endpoint ) && httpClient . BaseAddress is not null
171165 ? httpClient . BaseAddress
172166 : new Uri ( endpoint , UriKind . RelativeOrAbsolute ) ;
173- this . Metadata = new ChatClientMetadata ( "AGUI " , metadataUri , null ) ;
167+ this . Metadata = new ChatClientMetadata ( "ag-ui " , metadataUri , null ) ;
174168 }
175169
176170 public ChatClientMetadata Metadata { get ; }
@@ -194,10 +188,10 @@ public async IAsyncEnumerable<ChatResponseUpdate> GetStreamingResponseAsync(
194188 throw new ArgumentNullException ( nameof ( messages ) ) ;
195189 }
196190
197- var runId = $ "run_{ Guid . NewGuid ( ) } ";
191+ var runId = $ "run_{ Guid . NewGuid ( ) : N } ";
198192 var messagesList = messages . ToList ( ) ; // Avoid triggering the enumerator multiple times.
199193 var threadId = ExtractTemporaryThreadId ( messagesList ) ??
200- ExtractThreadIdFromOptions ( options ) ?? $ "thread_{ Guid . NewGuid ( ) } ";
194+ ExtractThreadIdFromOptions ( options ) ?? $ "thread_{ Guid . NewGuid ( ) : N } ";
201195
202196 // Create the input for the AGUI service
203197 var input = new RunAgentInput
@@ -291,9 +285,7 @@ threadIdObj is not string threadId ||
291285 return null ;
292286 }
293287
294- if ( content . AdditionalProperties == null ||
295- ! content . AdditionalProperties . TryGetValue ( "agui_thread_id" , out var threadIdObj ) ||
296- threadIdObj is not string threadId ||
288+ if ( content . AdditionalProperties ? . TryGetValue ( "agui_thread_id" , out string ? threadId ) is not true ||
297289 string . IsNullOrEmpty ( threadId ) )
298290 {
299291 return null ;
0 commit comments