Skip to content

Commit b65f49e

Browse files
committed
Handle error message from the Azure Orchestrator
1 parent d77bf85 commit b65f49e

File tree

3 files changed

+24
-12
lines changed

3 files changed

+24
-12
lines changed

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

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -183,20 +183,29 @@ public async Task<bool> ChatAsync(string input, IShell shell)
183183
{
184184
ResetArgumentPlaceholder();
185185

186-
// Process CLI handler response specially to support parameter injection.
187-
ResponseData data = null;
188-
if (_copilotResponse.TopicName == CopilotActivity.CLIHandlerTopic)
186+
if (_copilotResponse.IsError)
189187
{
190-
data = ParseCLIHandlerResponse(shell);
188+
host.WriteErrorLine()
189+
.WriteErrorLine(_copilotResponse.Text)
190+
.WriteErrorLine();
191191
}
192-
193-
if (data?.PlaceholderSet is not null)
192+
else
194193
{
195-
ArgPlaceholder = new ArgumentPlaceholder(input, data, _httpClient);
196-
}
194+
// Process CLI handler response specially to support parameter injection.
195+
ResponseData data = null;
196+
if (_copilotResponse.TopicName == CopilotActivity.CLIHandlerTopic)
197+
{
198+
data = ParseCLIHandlerResponse(shell);
199+
}
197200

198-
string answer = data is null ? _copilotResponse.Text : GenerateAnswer(data);
199-
host.RenderFullResponse(answer);
201+
if (data?.PlaceholderSet is not null)
202+
{
203+
ArgPlaceholder = new ArgumentPlaceholder(input, data, _httpClient);
204+
}
205+
206+
string answer = data is null ? _copilotResponse.Text : GenerateAnswer(data);
207+
host.RenderFullResponse(answer);
208+
}
200209
}
201210
else
202211
{

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ internal class ChatSession : IDisposable
2727
private readonly HttpClient _httpClient;
2828
private readonly Dictionary<string, object> _flights;
2929

30-
internal string ConversationId => _conversationId;
31-
3230
internal ChatSession(HttpClient httpClient)
3331
{
3432
_httpClient = httpClient;
@@ -328,6 +326,7 @@ internal async Task<CopilotResponse> GetChatResponseAsync(string input, IStatusC
328326
{
329327
"typing" => new CopilotResponse(activity, new ChunkReader(_copilotReceiver, activity)),
330328
"acceptingInput" => new CopilotResponse(activity),
329+
"error" => new CopilotResponse(activity) { IsError = true },
331330
_ => throw CorruptDataException.Create($"The 'inputHint' is {activity.InputHint}.", activity)
332331
};
333332

@@ -338,6 +337,7 @@ internal async Task<CopilotResponse> GetChatResponseAsync(string input, IStatusC
338337
ret.ConversationState = state;
339338
}
340339

340+
ret.ConversationId = _conversationId;
341341
return ret;
342342
}
343343

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,9 @@ internal CopilotResponse(CopilotActivity activity)
192192
internal string Locale { get; }
193193
internal string TopicName { get; }
194194
internal string ReplyToId { get; }
195+
196+
internal bool IsError { get; set; }
197+
internal string ConversationId { get; set; }
195198
internal string[] SuggestedUserResponses { get; set; }
196199
internal ConversationState ConversationState { get; set; }
197200
}

0 commit comments

Comments
 (0)