diff --git a/shell/AIShell.Kernel/Shell.cs b/shell/AIShell.Kernel/Shell.cs index 271c19f3..91d57da0 100644 --- a/shell/AIShell.Kernel/Shell.cs +++ b/shell/AIShell.Kernel/Shell.cs @@ -1,4 +1,5 @@ using System.Reflection; +using System.Text; using AIShell.Abstraction; using AIShell.Kernel.Commands; using AIShell.Kernel.Mcp; @@ -686,8 +687,24 @@ internal async Task RunREPLAsync() continue; } + StringBuilder sb = null; + string message = ex.Message; + string stackTrace = ex.StackTrace; + + while (ex.InnerException is { }) + { + sb ??= new(message, capacity: message.Length * 3); + sb.Append($"\n Inner -> {ex.InnerException.Message}"); + ex = ex.InnerException; + } + + if (sb is not null) + { + message = sb.ToString(); + } + Host.WriteErrorLine() - .WriteErrorLine($"Agent failed to generate a response: {ex.Message}\n{ex.StackTrace}") + .WriteErrorLine($"Agent failed to generate a response: {message}\n\n{stackTrace}") .WriteErrorLine(); } } diff --git a/shell/ReadLine/Prediction.cs b/shell/ReadLine/Prediction.cs index 2299a6c9..c434498b 100644 --- a/shell/ReadLine/Prediction.cs +++ b/shell/ReadLine/Prediction.cs @@ -85,7 +85,7 @@ public PredictiveSuggestion(string suggestion, string toolTip) public partial class PSConsoleReadLine { - private const string DefaultName = "PSReadLine"; + private const string DefaultName = "AIShell"; private readonly Prediction _prediction; /// diff --git a/shell/agents/AIShell.OpenAI.Agent/AIShell.OpenAI.Agent.csproj b/shell/agents/AIShell.OpenAI.Agent/AIShell.OpenAI.Agent.csproj index 21a674aa..c9d9a0da 100644 --- a/shell/agents/AIShell.OpenAI.Agent/AIShell.OpenAI.Agent.csproj +++ b/shell/agents/AIShell.OpenAI.Agent/AIShell.OpenAI.Agent.csproj @@ -22,7 +22,7 @@ - + diff --git a/shell/agents/AIShell.OpenAI.Agent/Service.cs b/shell/agents/AIShell.OpenAI.Agent/Service.cs index 1c2d0467..b15594c1 100644 --- a/shell/agents/AIShell.OpenAI.Agent/Service.cs +++ b/shell/agents/AIShell.OpenAI.Agent/Service.cs @@ -101,7 +101,14 @@ private void RefreshOpenAIClient() } else { - var credential = new DefaultAzureCredential(includeInteractiveCredentials: true); + var credential = new DefaultAzureCredential( + new DefaultAzureCredentialOptions + { + ExcludeInteractiveBrowserCredential = false, + ExcludeEnvironmentCredential = true, + ExcludeManagedIdentityCredential = true, + } + ); var aiClient = new AzureOpenAIClient( new Uri(_gptToUse.Endpoint),