Skip to content

Commit cf042a2

Browse files
committed
Change EndConversation() to be a regular method
1 parent 3e35765 commit cf042a2

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

shell/agents/Microsoft.Azure.Agent/ChatSession.cs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ internal async Task<string> RefreshAsync(IStatusContext context, bool force, Can
7171
{
7272
// End the existing conversation.
7373
context.Status("End current chat ...");
74-
await EndConversation();
74+
EndConversation();
7575
Reset();
7676
}
7777
else
@@ -280,18 +280,19 @@ private async Task<string> SendQueryToCopilot(string input, CancellationToken ca
280280
return contentObj["id"].ToString();
281281
}
282282

283-
private async Task EndConversation()
283+
private void EndConversation()
284284
{
285-
if (CheckDLTokenHealth() is TokenHealth.Expired)
285+
if (_token is null || CheckDLTokenHealth() is TokenHealth.Expired)
286286
{
287287
// Chat session already expired, no need to send request to end the conversation.
288288
return;
289289
}
290290

291291
var content = new StringContent("{\"type\":\"endOfConversation\",\"from\":{\"id\":\"user\"}}", Encoding.UTF8, Utils.JsonContentType);
292292
var request = new HttpRequestMessage(HttpMethod.Post, _conversationUrl) { Content = content };
293+
293294
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", _token);
294-
await _httpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead, CancellationToken.None);
295+
_httpClient.Send(request, HttpCompletionOption.ResponseHeadersRead, CancellationToken.None);
295296
}
296297

297298
internal async Task<CopilotResponse> GetChatResponseAsync(string input, IStatusContext context, CancellationToken cancellationToken)
@@ -350,13 +351,9 @@ internal async Task<CopilotResponse> GetChatResponseAsync(string input, IStatusC
350351
}
351352
}
352353

353-
public async void Dispose()
354+
public void Dispose()
354355
{
355-
if (_token is not null)
356-
{
357-
await EndConversation();
358-
}
359-
356+
EndConversation();
360357
_copilotReceiver?.Dispose();
361358
}
362359
}

0 commit comments

Comments
 (0)