Agent-Logs-Url: https://github.com/microsoft/agent-framework/sessions/ed87670a-bf4d-4ba5-a2f3-395a2eead9de Co-authored-by: lokitoth <6936551+lokitoth@users.noreply.github.com>
14 KiB
Magentic E2E Implementation Review
Review Scope
This document reviews the current Magentic E2E implementation against the original plan in
MagenticE2E_TestPlan.md.
Reviewed files:
dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/MagenticE2E_TestPlan.mddotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/MagenticOrchestrationTests.csdotnet/src/Microsoft.Agents.AI.Workflows/Specialized/Magentic/MagenticOrchestrator.csdotnet/src/Microsoft.Agents.AI.Workflows/Specialized/Magentic/MagenticManager.csdotnet/src/Microsoft.Agents.AI.Workflows/Specialized/Magentic/MagenticTaskContext.csdotnet/src/Microsoft.Agents.AI.Workflows/MagenticPlanReviewRequest.cs
Executive Summary
The current implementation contains 21 Magentic end-to-end tests in
MagenticOrchestrationTests.cs. The suite builds real workflows through
MagenticWorkflowBuilder.Build() and exercises the orchestrator through streaming workflow
execution, pending plan-review requests, checkpoint/resume, event collection, participant routing,
reset/replan flows, and yielded final outputs.
The implementation is substantially aligned with the original plan. The major planned orchestration paths are covered, and the plan/review documentation has been updated for the current stall semantics:
MagenticTaskContext.IsStalledusesStallCount > MaxStallCount.MaxStallCountshould be read as the number of stalls tolerated before reset.- Direct checkpoint payload inspection is intentionally skipped because the serialized checkpoint shape is an internal implementation detail.
- Checkpoint/resume is covered behaviorally by plan-review tests that pause and resume across checkpoint boundaries.
The remaining gaps are optional edge-case hardening rather than blockers for the current plan:
zero-participant behavior, explicit post-termination input rejection, and stronger direct assertion
that instruction_or_question is delivered to the selected participant.
Production Implementation Findings
Output protocol declaration
MagenticOrchestrator.ConfigureProtocol() declares .YieldsOutput<List<ChatMessage>>(), matching
the final answer output emitted by the orchestrator.
Assessment: Complete. Every final-answer E2E test depends on this protocol being declared correctly for fully built workflow execution.
Normal participant return resumes coordination without replanning
MagenticOrchestrator.TakeTurnAsync() now distinguishes the initial turn from subsequent
participant returns:
- Initial user turn initializes
MagenticTaskContextand calls the plan/update path. - Participant returns go directly back into
RunCoordinationRoundAsync().
Assessment: Complete. This matches the Python Magentic loop and is covered by the multi-round, progress decrement, consecutive stall, and empty next-speaker fallback tests. These tests no longer expect facts/plan manager calls after normal participant responses.
Stall threshold uses > semantics
MagenticTaskContext.IsStalled evaluates StallCount > MaxStallCount.
Assessment: Complete. This matches Python behavior. Tests that must reset on the first stalled
ledger use WithMaxStalls(0), and tests that tolerate one stall before reset use
WithMaxStalls(1). The original test plan and comments now describe the same > behavior.
Stall-triggered plan review preserves IsStalled
ResetAndReplanAsync() captures whether reset was caused by a stall before counters are reset and
passes that value through the replan/signoff path.
Assessment: Complete. PlanReview_On_Stall_Replan verifies that the initial review is not
stalled and the replanned review request has IsStalled=true.
Progress-ledger parse retry and reset behavior
Invalid progress-ledger responses are retried, warnings are emitted, and exhausted retries trigger reset/replan.
Assessment: Complete. Covered by ProgressLedger_Retry_On_Parse_Failure and
ProgressLedger_Max_Retries_Triggers_Reset.
Implemented Test Inventory
| Test | Original Plan Area | Current Assessment |
|---|---|---|
Task_Completes_When_RequestSatisfied |
Happy path | Complete. Immediate satisfaction yields final output. |
PlanReview_Approved_Proceeds |
Plan review / checkpoint-resume | Complete. Review pauses, approval resumes, workflow completes. |
Initial_Plan_Emits_PlanCreatedEvent |
Event emission | Complete. Verifies initial plan event. |
NextSpeaker_Invalid_Triggers_FinalAnswer |
Next speaker validation / warnings | Complete. Invalid participant warning and final-answer fallback. |
ProgressLedger_Updated_Event_Emitted |
Progress ledger / events | Complete. Verifies progress-ledger event. |
PlanSignoff_Disabled_Proceeds_Immediately |
Happy path | Complete. No pending review request when signoff is disabled. |
NextSpeaker_Empty_Falls_Back_To_First |
Next speaker validation / warnings | Complete. Empty speaker warns, falls back to first participant, and completes without stale replan responses. |
Task_Completes_After_Multiple_Rounds |
Happy path / coordination loop | Complete. Multiple coordination rounds complete without normal-return replan. |
PlanReview_Revised_Triggers_Replan |
Plan review | Complete. One revision triggers replan and a second review. |
MaxRoundLimit_Terminates_Workflow |
Limits | Complete. Round limit yields termination message. |
MaxStallCount_Triggers_Reset |
Limits / stall detection | Complete. First stalled ledger resets with WithMaxStalls(0). |
Instruction_Message_Sent_When_Present |
Edge case / instruction delivery | Partial. Flow completes with an instruction present, but exact participant-delivered instruction is not directly observed. |
PlanReview_On_Stall_Replan |
Plan review / stall reset | Complete. Stall-triggered replan review has IsStalled=true. |
MaxResetLimit_Terminates_Workflow |
Limits | Complete. Reset limit yields termination message. |
ProgressLedger_Retry_On_Parse_Failure |
Progress ledger validation | Complete. Warning is emitted, retry succeeds, workflow completes. |
ProgressLedger_Max_Retries_Triggers_Reset |
Progress ledger validation | Complete. Exhausted retries warn, reset/replan occurs, workflow completes. |
Stall_NoProgress_Increments_StallCount |
Stall detection | Behaviorally covered. No-progress ledger causes reset/replan under configured threshold. |
Task_Delegates_To_Correct_Agent |
Happy path / routing | Complete. Selected participant responds; non-selected participant does not. |
Progress_Made_Decrements_StallCount |
Stall detection | Complete. Progress after a stall decrements/clears stall pressure and avoids reset. |
Consecutive_Stalls_Trigger_Reset |
Stall detection | Complete. Consecutive stalls exceed MaxStallCount and reset/replan. |
PlanReview_Multiple_Revisions |
Plan review | Complete. Multiple revisions are handled before approval and completion. |
Coverage Against Original Plan
1. Happy Path Tests
| Planned Test | Current Status | Notes |
|---|---|---|
Task_Completes_When_RequestSatisfied |
Complete | Covered directly. |
Task_Delegates_To_Correct_Agent |
Complete | Covered with direct selected/non-selected participant assertions. |
Task_Completes_After_Multiple_Rounds |
Complete | Covered with the corrected no-replan-on-return behavior. |
PlanSignoff_Disabled_Proceeds_Immediately |
Complete | Covered directly. |
Summary: 4 complete / 4 planned.
2. Plan Review Tests
| Planned Test | Current Status | Notes |
|---|---|---|
PlanReview_Approved_Proceeds |
Complete | Covered with checkpoint/resume. |
PlanReview_Revised_Triggers_Replan |
Complete | Covered with one revision. |
PlanReview_Multiple_Revisions |
Complete | Covered with two revisions. |
PlanReview_On_Stall_Replan |
Complete | Covered, including IsStalled=true on the replanned request. |
Summary: 4 complete / 4 planned.
3. Limit Enforcement Tests
| Planned Test | Current Status | Notes |
|---|---|---|
MaxRoundLimit_Terminates_Workflow |
Complete | Covered directly. |
MaxResetLimit_Terminates_Workflow |
Complete | Covered directly. |
MaxStallCount_Triggers_Reset |
Complete | Covered with updated StallCount > MaxStallCount semantics. |
Summary: 3 complete / 3 planned.
4. Stall Detection Tests
| Planned Test | Current Status | Notes |
|---|---|---|
Stall_IsInLoop_Increments_StallCount |
Behaviorally covered | Covered by reset behavior when IsInLoop=true; direct counter inspection is intentionally avoided. |
Stall_NoProgress_Increments_StallCount |
Behaviorally covered | Covered by reset behavior when IsProgressBeingMade=false; direct counter inspection is intentionally avoided. |
Progress_Made_Decrements_StallCount |
Complete | Covered by avoiding reset after later progress. |
Consecutive_Stalls_Trigger_Reset |
Complete | Covered with two stalls exceeding MaxStallCount under > semantics. |
Summary: 2 complete, 2 behaviorally covered / 4 planned.
5. Progress Ledger Validation Tests
| Planned Test | Current Status | Notes |
|---|---|---|
ProgressLedger_Retry_On_Parse_Failure |
Complete | Covered directly. |
ProgressLedger_Max_Retries_Triggers_Reset |
Complete | Covered directly. |
ProgressLedger_Updated_Event_Emitted |
Complete | Covered directly. |
Summary: 3 complete / 3 planned.
6. Next Speaker Validation Tests
| Planned Test | Current Status | Notes |
|---|---|---|
NextSpeaker_Empty_Falls_Back_To_First |
Complete | Warning, fallback, and completion are covered with current no-replan flow. |
NextSpeaker_Invalid_Triggers_FinalAnswer |
Complete | Covered directly. |
NextSpeaker_Valid_Delegates_Correctly |
Complete | Covered by Task_Delegates_To_Correct_Agent. |
Summary: 3 complete / 3 planned.
7. Event Emission Tests
| Planned Test | Current Status | Notes |
|---|---|---|
Initial_Plan_Emits_PlanCreatedEvent |
Complete | Covered directly. |
Replan_Emits_ReplannedEvent |
Complete | Covered by revision, multiple revisions, stall reset, no-progress reset, and max-retry reset paths. |
Warning_Events_On_Errors |
Mostly complete | Warnings are asserted across empty/invalid next-speaker and progress-ledger failure tests; there is no single dedicated warning matrix test. |
Summary: 2 complete, 1 mostly complete / 3 planned.
8. Checkpoint/Resume Tests
| Planned Test | Current Status | Notes |
|---|---|---|
Checkpoint_Saves_TaskContext |
Intentionally skipped | Direct checkpoint payload inspection is skipped because the serialized checkpoint shape is internal. |
Checkpoint_Resume_Continues_Correctly |
Behaviorally covered | Approval, revision, multiple-revision, and stall-with-signoff tests all pause and resume through checkpoints. |
Checkpoint_Preserves_ProgressLedger |
Intentionally skipped | Direct checkpoint payload inspection is skipped because the serialized checkpoint shape is internal. |
Summary: 1 behaviorally covered, 2 intentionally skipped / 3 planned.
9. Edge Cases
| Planned Test | Current Status | Notes |
|---|---|---|
Empty_Team_Handling |
Not implemented | No zero-participant test. |
Single_Agent_Team |
Behaviorally covered | Most tests run with one participant, but there is no dedicated single-agent edge-case test. |
Instruction_Message_Sent_When_Present |
Partial | Workflow completes with an instruction present; exact participant-delivered instruction is not directly asserted. |
Terminated_Context_Rejects_New_Messages |
Not implemented | No post-termination input test. |
Summary: 1 behaviorally covered, 1 partial, 2 not implemented / 4 planned.
Success Criteria Assessment
| Success Criterion | Assessment |
|---|---|
All logical forks in MagenticOrchestrator are covered by at least one test |
Substantially met. User-visible branches are strongly covered. Remaining uncovered areas are edge cases, not core orchestration paths. |
Tests use the same patterns as HandoffOrchestrationTests |
Met. Tests use fully built workflows, streaming execution, checkpoint managers, pending requests, event collection, and output assertions. |
| Tests run against fully-built workflows | Met. Tests build through MagenticWorkflowBuilder(...).Build(). |
| Each test verifies specific event emissions and state changes | Mostly met. Event/output assertions are strong; direct internal counter and checkpoint payload inspection are intentionally avoided. |
Tests cover both requirePlanSignoff=true and false paths |
Met. Signoff and no-signoff flows are both exercised. |
| Checkpoint/resume functionality is verified | Behaviorally met. Resume is exercised through plan-review workflows; direct checkpoint-state checking is intentionally skipped. |
Remaining Recommended Follow-Up
-
Strengthen instruction-delivery verification. Add or enhance a test so the selected participant's received messages can be inspected directly for
instruction_or_questioncontent. -
Consider a zero-participant edge-case test. The original plan included empty-team behavior, but the current suite does not include a dedicated test for that case.
-
Consider a post-termination rejection test. The original plan included rejected input after termination, but the current suite does not directly cover it.
-
Do not add direct checkpoint payload assertions unless the checkpoint contract becomes public. Current coverage intentionally verifies resume behavior instead of relying on serialized internal implementation details.
Overall Conclusion
The Magentic E2E suite is a strong implementation of the original plan. It contains 21 fully built
workflow tests and covers the important production behavior: planning, plan review, checkpointed
resume, participant routing, progress-ledger retries, warning paths, final-answer generation,
reset/replan behavior, and the updated StallCount > MaxStallCount stall threshold.
The current implementation is ready from the perspective of the original plan's core orchestration coverage. Remaining items are optional hardening tests and should be prioritized only if those edge cases need explicit contract coverage.