Skip to content

Commit 722d774

Browse files
authored
Update the error message when /replace cannot do its work (#289)
1 parent 2671579 commit 722d774

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

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

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,21 @@ private void ReplaceAction()
5353

5454
if (ap is null)
5555
{
56-
host.WriteErrorLine("No argument placeholder to replace.");
56+
CopilotResponse cr = _agent.CopilotResponse;
57+
if (cr is null || cr.IsError)
58+
{
59+
host.WriteErrorLine("No AI response available.");
60+
}
61+
else if (!cr.Text.Contains("```") && !cr.Text.Contains("~~~"))
62+
{
63+
host.WriteErrorLine("The last AI response contains no code in it.");
64+
}
65+
else
66+
{
67+
Telemetry.Trace(AzTrace.Exception($"'/replace' command unavailable. TopicName: {cr.TopicName}"));
68+
host.WriteErrorLine("The '/replace' command is experimental and could not successfully parse the response. This issue may occur intermittently due to specific response conditions.");
69+
}
70+
5771
return;
5872
}
5973

0 commit comments

Comments
 (0)