Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 19 additions & 10 deletions shell/agents/Microsoft.Azure.Agent/AzureAgent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -183,20 +183,29 @@ public async Task<bool> ChatAsync(string input, IShell shell)
{
ResetArgumentPlaceholder();

// Process CLI handler response specially to support parameter injection.
ResponseData data = null;
if (_copilotResponse.TopicName == CopilotActivity.CLIHandlerTopic)
if (_copilotResponse.IsError)
{
data = ParseCLIHandlerResponse(shell);
host.WriteErrorLine()
.WriteErrorLine(_copilotResponse.Text)
.WriteErrorLine();
}

if (data?.PlaceholderSet is not null)
else
{
ArgPlaceholder = new ArgumentPlaceholder(input, data, _httpClient);
}
// Process CLI handler response specially to support parameter injection.
ResponseData data = null;
if (_copilotResponse.TopicName == CopilotActivity.CLIHandlerTopic)
{
data = ParseCLIHandlerResponse(shell);
}

string answer = data is null ? _copilotResponse.Text : GenerateAnswer(data);
host.RenderFullResponse(answer);
if (data?.PlaceholderSet is not null)
{
ArgPlaceholder = new ArgumentPlaceholder(input, data, _httpClient);
}

string answer = data is null ? _copilotResponse.Text : GenerateAnswer(data);
host.RenderFullResponse(answer);
}
}
else
{
Expand Down
4 changes: 2 additions & 2 deletions shell/agents/Microsoft.Azure.Agent/ChatSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ internal class ChatSession : IDisposable
private readonly HttpClient _httpClient;
private readonly Dictionary<string, object> _flights;

internal string ConversationId => _conversationId;

internal ChatSession(HttpClient httpClient)
{
_httpClient = httpClient;
Expand Down Expand Up @@ -328,6 +326,7 @@ internal async Task<CopilotResponse> GetChatResponseAsync(string input, IStatusC
{
"typing" => new CopilotResponse(activity, new ChunkReader(_copilotReceiver, activity)),
"acceptingInput" => new CopilotResponse(activity),
"error" => new CopilotResponse(activity) { IsError = true },
_ => throw CorruptDataException.Create($"The 'inputHint' is {activity.InputHint}.", activity)
};

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

ret.ConversationId = _conversationId;
return ret;
}

Expand Down
3 changes: 3 additions & 0 deletions shell/agents/Microsoft.Azure.Agent/Schema.cs
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,9 @@ internal CopilotResponse(CopilotActivity activity)
internal string Locale { get; }
internal string TopicName { get; }
internal string ReplyToId { get; }

internal bool IsError { get; set; }
internal string ConversationId { get; set; }
internal string[] SuggestedUserResponses { get; set; }
internal ConversationState ConversationState { get; set; }
}
Expand Down