From 238b4346c41050068c261153a4869ad74a9a5d04 Mon Sep 17 00:00:00 2001 From: Dongbo Wang Date: Tue, 26 Aug 2025 12:09:26 -0700 Subject: [PATCH 1/3] Update the history file name and exclude the environment/managed-identity credentials from Azure authentication flow --- shell/ReadLine/Prediction.cs | 2 +- shell/agents/AIShell.OpenAI.Agent/Service.cs | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) 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/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), From 63c62d9152f7df80ea203bf2570c398b73f8e993 Mon Sep 17 00:00:00 2001 From: Dongbo Wang Date: Tue, 26 Aug 2025 13:28:20 -0700 Subject: [PATCH 2/3] Print out the messages from inner exceptions --- shell/AIShell.Kernel/Shell.cs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) 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(); } } From 33aa6aaf4166afc517ed9acb2b416ecade050339 Mon Sep 17 00:00:00 2001 From: Dongbo Wang Date: Tue, 26 Aug 2025 13:49:15 -0700 Subject: [PATCH 3/3] Update package version of Azure.Identity --- shell/agents/AIShell.OpenAI.Agent/AIShell.OpenAI.Agent.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 @@ - +