From 0a992a00259aea0049803ded10297aa1e7584bd3 Mon Sep 17 00:00:00 2001 From: Jacob Alber Date: Tue, 5 May 2026 07:11:52 -0400 Subject: [PATCH] fix: Updates for PR feedback --- .../Specialized/Magentic/MagenticOrchestrator.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/dotnet/src/Microsoft.Agents.AI.Workflows/Specialized/Magentic/MagenticOrchestrator.cs b/dotnet/src/Microsoft.Agents.AI.Workflows/Specialized/Magentic/MagenticOrchestrator.cs index b78183b039..b272ed102d 100644 --- a/dotnet/src/Microsoft.Agents.AI.Workflows/Specialized/Magentic/MagenticOrchestrator.cs +++ b/dotnet/src/Microsoft.Agents.AI.Workflows/Specialized/Magentic/MagenticOrchestrator.cs @@ -160,7 +160,7 @@ internal class MagenticOrchestrator(AIAgent managerAgent, List team, Ta taskContext.TaskLedger = await this._manager.UpdatePlanAsync(taskContext, context, cancellationToken) .ConfigureAwait(false); - this._fullTaskLedgerMessage ??= new(ChatRole.User, taskContext.ToTaskLedgerFullPrompt()); + this._fullTaskLedgerMessage = new(ChatRole.User, taskContext.ToTaskLedgerFullPrompt()); taskContext.ChatHistory.Add(this._fullTaskLedgerMessage); await context.AddEventAsync(isReplan @@ -215,7 +215,8 @@ internal class MagenticOrchestrator(AIAgent managerAgent, List team, Ta await context.AddEventAsync(new MagenticProgressLedgerUpdatedEvent(taskContext.ProgressLedger), cancellationToken) .ConfigureAwait(false); } - catch (Exception ex) + // Retry on exception to max retry count, unless it is OperationCancelledException - in that case exit the loop right away + catch (Exception ex) when (ex is not OperationCanceledException) { await context.AddEventAsync(new WorkflowWarningEvent($"Magentic Orchestrator: Progress ledger creation failed, triggering reset: {ex}"), cancellationToken) .ConfigureAwait(false);