fixup: Update for review comments

This commit is contained in:
Jacob Alber
2026-05-04 14:19:29 -04:00
Unverified
parent 1c0c6483e8
commit 7f36646177
7 changed files with 17 additions and 14 deletions
@@ -6,9 +6,12 @@ using Microsoft.Extensions.AI;
namespace Microsoft.Agents.AI.Workflows;
/// <summary>
/// .
/// Review feedback for a proposed plan, including any revisions if the plan is not approved as-is. An
/// empty list of review messages indicates approval of the proposed plan without any revisions.
/// </summary>
/// <param name="Review"></param>
/// <param name="Review">
/// Review feedback for a generated plan. Empty if the plan is approved as-is and changes are requested.
/// </param>
public record MagenticPlanReviewResponse(List<ChatMessage> Review)
{
internal bool IsApproved => this.Review.Count == 0;
@@ -154,8 +154,8 @@ public class MagenticProgressLedger
questionBuilder.AppendLine(slot.FormattedQuestion);
schemaBuilder.AppendLine($"\"{slot.Key}\": {{")
.AppendLine($" \"{ProgressLedgerSlot.ValueKey}\": string,")
.AppendLine($" \"{ProgressLedgerSlot.ReasonKey}\": {slot.SchemaType}{slot.SuffixString}")
.AppendLine($" \"{ProgressLedgerSlot.ValueKey}\": {slot.SchemaType}{slot.SuffixString},")
.AppendLine($" \"{ProgressLedgerSlot.ReasonKey}\": string")
.AppendLine("}");
}
schemaBuilder.AppendLine("}");
@@ -105,10 +105,10 @@ internal class MagenticManager(AIAgent managerAgent)
lastException?.Throw();
}
public async ValueTask<ChatMessage> PrepareFinalAnswerAsync(MagenticTaskContext taskContext, IWorkflowContext context, CancellationToken canclleationToken)
public async ValueTask<ChatMessage> PrepareFinalAnswerAsync(MagenticTaskContext taskContext, IWorkflowContext context, CancellationToken cancellationToken)
{
ChatMessage finalAnswerRequest = new(ChatRole.User, taskContext.ToFinalAnswerPrompt());
ChatMessage finalAnswer = await this.InvokeAgentAsync([.. taskContext.ChatHistory, finalAnswerRequest], context, canclleationToken)
ChatMessage finalAnswer = await this.InvokeAgentAsync([.. taskContext.ChatHistory, finalAnswerRequest], context, cancellationToken)
.ConfigureAwait(false);
return new(ChatRole.Assistant, finalAnswer.Text)
@@ -198,7 +198,7 @@ internal class MagenticOrchestrator(AIAgent managerAgent, List<AIAgent> team, Ta
{
string limitType = hitRoundLimit ? "round" : "reset";
List<ChatMessage> messages = [new(ChatRole.Assistant, $"Task execution stopped due to hitting the maximim {limitType} count limit.")];
List<ChatMessage> messages = [new(ChatRole.Assistant, $"Task execution stopped due to hitting the maximum {limitType} count limit.")];
await context.YieldOutputAsync(messages, cancellationToken).ConfigureAwait(false);
taskContext.IsTerminated = true;
@@ -232,7 +232,7 @@ internal class MagenticOrchestrator(AIAgent managerAgent, List<AIAgent> team, Ta
}
// Check and handle stalls
if (taskContext.ProgressLedger.IsInLoop || taskContext.ProgressLedger.IsProgressBeingMade)
if (taskContext.ProgressLedger.IsInLoop || !taskContext.ProgressLedger.IsProgressBeingMade)
{
taskContext.TaskCounters.StallCount++;
}
@@ -57,7 +57,7 @@ internal sealed class StreamingToolCallResultPairMatcher
private bool TryResolve(CallType callType, string callId, [NotNullWhen(true)] out string? name)
{
CallSummaryKey key = new(CallType.Function, callId);
CallSummaryKey key = new(callType, callId);
bool hasMatchingCall = this._callSummaries.TryGetValue(key, out ToolCallSummary callSummary);
if (hasMatchingCall)
@@ -29,7 +29,7 @@ public record TestProgressLedgerState(Slot<bool?>? is_request_satisfied = null,
private static readonly JsonSerializerOptions s_options = new()
{
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull | JsonIgnoreCondition.WhenReading
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull
};
public JsonElement ToJson() => JsonSerializer.SerializeToElement(this, s_options);
@@ -96,7 +96,7 @@ public class TestReplayAgent(List<List<ChatMessage>> messages, string? id = null
private static List<List<ChatMessage>>? Validate(List<List<ChatMessage>>? candidateMessages)
{
string? currentMessageId = null;
string? lastMessageId = null;
if (candidateMessages != null)
{
@@ -104,11 +104,11 @@ public class TestReplayAgent(List<List<ChatMessage>> messages, string? id = null
{
foreach (ChatMessage message in candidateMessagesTurn)
{
if (currentMessageId is null)
if (lastMessageId is null || lastMessageId != message.MessageId)
{
currentMessageId = message.MessageId;
lastMessageId = message.MessageId;
}
else if (currentMessageId == message.MessageId)
else if (lastMessageId == message.MessageId)
{
throw new ArgumentException("Duplicate consecutive message ids");
}