@@ -224,7 +224,7 @@ public override async Task<ChatResponse> GetResponseAsync(
224
224
List < ChatMessage > ? responseMessages = null ; // tracked list of messages, across multiple turns, to be used for the final response
225
225
UsageDetails ? totalUsage = null ; // tracked usage across all turns, to be used for the final response
226
226
List < FunctionCallContent > ? functionCallContents = null ; // function call contents that need responding to in the current turn
227
- bool lastIterationHadThreadId = false ; // whether the last iteration's response had a ChatThreadId set
227
+ bool lastIterationHadConversationId = false ; // whether the last iteration's response had a ConversationId set
228
228
int consecutiveErrorCount = 0 ;
229
229
230
230
for ( int iteration = 0 ; ; iteration ++ )
@@ -274,7 +274,7 @@ public override async Task<ChatResponse> GetResponseAsync(
274
274
}
275
275
276
276
// Prepare the history for the next iteration.
277
- FixupHistories ( originalMessages , ref messages , ref augmentedHistory , response , responseMessages , ref lastIterationHadThreadId ) ;
277
+ FixupHistories ( originalMessages , ref messages , ref augmentedHistory , response , responseMessages , ref lastIterationHadConversationId ) ;
278
278
279
279
// Add the responses from the function calls into the augmented history and also into the tracked
280
280
// list of response messages.
@@ -287,7 +287,7 @@ public override async Task<ChatResponse> GetResponseAsync(
287
287
break ;
288
288
}
289
289
290
- UpdateOptionsForNextIteration ( ref options ! , response . ChatThreadId ) ;
290
+ UpdateOptionsForNextIteration ( ref options ! , response . ConversationId ) ;
291
291
}
292
292
293
293
Debug . Assert ( responseMessages is not null , "Expected to only be here if we have response messages." ) ;
@@ -318,7 +318,7 @@ public override async IAsyncEnumerable<ChatResponseUpdate> GetStreamingResponseA
318
318
List < ChatMessage > ? augmentedHistory = null ; // the actual history of messages sent on turns other than the first
319
319
List < FunctionCallContent > ? functionCallContents = null ; // function call contents that need responding to in the current turn
320
320
List < ChatMessage > ? responseMessages = null ; // tracked list of messages, across multiple turns, to be used in fallback cases to reconstitute history
321
- bool lastIterationHadThreadId = false ; // whether the last iteration's response had a ChatThreadId set
321
+ bool lastIterationHadConversationId = false ; // whether the last iteration's response had a ConversationId set
322
322
List < ChatResponseUpdate > updates = [ ] ; // updates from the current response
323
323
int consecutiveErrorCount = 0 ;
324
324
@@ -368,7 +368,7 @@ public override async IAsyncEnumerable<ChatResponseUpdate> GetStreamingResponseA
368
368
( responseMessages ??= [ ] ) . AddRange ( response . Messages ) ;
369
369
370
370
// Prepare the history for the next iteration.
371
- FixupHistories ( originalMessages , ref messages , ref augmentedHistory , response , responseMessages , ref lastIterationHadThreadId ) ;
371
+ FixupHistories ( originalMessages , ref messages , ref augmentedHistory , response , responseMessages , ref lastIterationHadConversationId ) ;
372
372
373
373
// Process all of the functions, adding their results into the history.
374
374
var modeAndMessages = await ProcessFunctionCallsAsync ( augmentedHistory , options , functionCallContents , iteration , consecutiveErrorCount , cancellationToken ) ;
@@ -390,7 +390,7 @@ public override async IAsyncEnumerable<ChatResponseUpdate> GetStreamingResponseA
390
390
{
391
391
AdditionalProperties = message . AdditionalProperties ,
392
392
AuthorName = message . AuthorName ,
393
- ChatThreadId = response . ChatThreadId ,
393
+ ConversationId = response . ConversationId ,
394
394
CreatedAt = DateTimeOffset . UtcNow ,
395
395
Contents = message . Contents ,
396
396
RawRepresentation = message . RawRepresentation ,
@@ -408,7 +408,7 @@ public override async IAsyncEnumerable<ChatResponseUpdate> GetStreamingResponseA
408
408
break ;
409
409
}
410
410
411
- UpdateOptionsForNextIteration ( ref options , response . ChatThreadId ) ;
411
+ UpdateOptionsForNextIteration ( ref options , response . ConversationId ) ;
412
412
}
413
413
414
414
AddUsageTags ( activity , totalUsage ) ;
@@ -437,18 +437,18 @@ private static void AddUsageTags(Activity? activity, UsageDetails? usage)
437
437
/// <param name="augmentedHistory">The augmented history containing all the messages to be sent.</param>
438
438
/// <param name="response">The most recent response being handled.</param>
439
439
/// <param name="allTurnsResponseMessages">A list of all response messages received up until this point.</param>
440
- /// <param name="lastIterationHadThreadId ">Whether the previous iteration's response had a thread id.</param>
440
+ /// <param name="lastIterationHadConversationId ">Whether the previous iteration's response had a conversation id.</param>
441
441
private static void FixupHistories (
442
442
IEnumerable < ChatMessage > originalMessages ,
443
443
ref IEnumerable < ChatMessage > messages ,
444
444
[ NotNull ] ref List < ChatMessage > ? augmentedHistory ,
445
445
ChatResponse response ,
446
446
List < ChatMessage > allTurnsResponseMessages ,
447
- ref bool lastIterationHadThreadId )
447
+ ref bool lastIterationHadConversationId )
448
448
{
449
449
// We're now going to need to augment the history with function result contents.
450
450
// That means we need a separate list to store the augmented history.
451
- if ( response . ChatThreadId is not null )
451
+ if ( response . ConversationId is not null )
452
452
{
453
453
// The response indicates the inner client is tracking the history, so we don't want to send
454
454
// anything we've already sent or received.
@@ -461,9 +461,9 @@ private static void FixupHistories(
461
461
augmentedHistory = [ ] ;
462
462
}
463
463
464
- lastIterationHadThreadId = true ;
464
+ lastIterationHadConversationId = true ;
465
465
}
466
- else if ( lastIterationHadThreadId )
466
+ else if ( lastIterationHadConversationId )
467
467
{
468
468
// In the very rare case where the inner client returned a response with a thread ID but then
469
469
// returned a subsequent response without one, we want to reconstitue the full history. To do that,
@@ -474,7 +474,7 @@ private static void FixupHistories(
474
474
augmentedHistory . AddRange ( originalMessages ) ;
475
475
augmentedHistory . AddRange ( allTurnsResponseMessages ) ;
476
476
477
- lastIterationHadThreadId = false ;
477
+ lastIterationHadConversationId = false ;
478
478
}
479
479
else
480
480
{
@@ -486,7 +486,7 @@ private static void FixupHistories(
486
486
// Now add the most recent response messages.
487
487
augmentedHistory . AddMessages ( response ) ;
488
488
489
- lastIterationHadThreadId = false ;
489
+ lastIterationHadConversationId = false ;
490
490
}
491
491
492
492
// Use the augmented history as the new set of messages to send.
@@ -525,22 +525,22 @@ private static bool CopyFunctionCalls(
525
525
return any ;
526
526
}
527
527
528
- private static void UpdateOptionsForNextIteration ( ref ChatOptions options , string ? chatThreadId )
528
+ private static void UpdateOptionsForNextIteration ( ref ChatOptions options , string ? conversationId )
529
529
{
530
530
if ( options . ToolMode is RequiredChatToolMode )
531
531
{
532
532
// We have to reset the tool mode to be non-required after the first iteration,
533
533
// as otherwise we'll be in an infinite loop.
534
534
options = options . Clone ( ) ;
535
535
options . ToolMode = null ;
536
- options . ChatThreadId = chatThreadId ;
536
+ options . ConversationId = conversationId ;
537
537
}
538
- else if ( options . ChatThreadId != chatThreadId )
538
+ else if ( options . ConversationId != conversationId )
539
539
{
540
540
// As with the other modes, ensure we've propagated the chat thread ID to the options.
541
541
// We only need to clone the options if we're actually mutating it.
542
542
options = options . Clone ( ) ;
543
- options . ChatThreadId = chatThreadId ;
543
+ options . ConversationId = conversationId ;
544
544
}
545
545
}
546
546
0 commit comments