Agent-Logs-Url: https://github.com/microsoft/agent-framework/sessions/aba19507-7c7e-40dd-850d-d1fabb5dfa65 Co-authored-by: lokitoth <6936551+lokitoth@users.noreply.github.com>
13 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.cs
Executive Summary
The current implementation is a comprehensive partial implementation of the original Magentic E2E plan. It contains 14 end-to-end tests that exercise fully-built workflows created with MagenticWorkflowBuilder.Build() and cover the highest-value branches in MagenticOrchestrator.
The implemented tests cover:
- Initial planning and final-answer completion.
- Explicit no-plan-signoff flow.
- Human plan approval with checkpoint/resume.
- Human plan revision triggering replanning.
- Multi-round delegation through a participant agent.
- Progress ledger event emission.
- Empty next-speaker fallback.
- Invalid next-speaker warning and forced final answer.
- Round-limit termination.
- Reset-limit termination.
- Stall-triggered reset and replan.
- Stall-triggered replan with plan signoff (human-in-the-loop after stall).
- Instruction message sent when present in progress ledger.
- Replanned-event emission.
The implementation also includes one production fix: MagenticOrchestrator.ConfigureProtocol() now declares .YieldsOutput<List<ChatMessage>>(), matching the type yielded by PrepareFinalAnswerAsync.
The original plan estimated roughly 31 tests. The remaining gaps are mostly lower-level granularity and edge cases: progress-ledger retry/failure behavior, direct checkpoint state assertions, explicit valid-speaker routing assertions, multiple plan revisions, and empty/single-team edge cases.
Production Code Review
MagenticOrchestrator.ConfigureProtocol() output declaration
Current implementation:
- The protocol declares
.YieldsOutput<List<ChatMessage>>().
Assessment:
- This change is correct and necessary.
PrepareFinalAnswerAsync()yieldsList<ChatMessage>throughcontext.YieldOutputAsync(...).- Without this declaration, a fully-built workflow can fail at runtime because the output type is not registered in the protocol.
- This is a production bug fix uncovered by the E2E tests, not test-only cleanup.
Implemented Tests
| Test | Original Plan Area | What It Verifies | Assessment |
|---|---|---|---|
Task_Completes_When_RequestSatisfied |
Happy path | First progress ledger says request is satisfied; workflow yields final answer and has no pending review request. | Complete |
PlanReview_Approved_Proceeds |
Plan review / checkpoint-resume | Plan review request is emitted, approval response resumes from checkpoint, and workflow completes. | Complete |
Initial_Plan_Emits_PlanCreatedEvent |
Event emission | Initial plan creation emits MagenticPlanCreatedEvent. |
Complete |
NextSpeaker_Invalid_Triggers_FinalAnswer |
Next speaker validation / warnings | Invalid next_speaker emits warning and causes final answer generation. |
Complete |
ProgressLedger_Updated_Event_Emitted |
Progress ledger / event emission | Successful ledger update emits MagenticProgressLedgerUpdatedEvent. |
Complete |
PlanSignoff_Disabled_Proceeds_Immediately |
Happy path | RequirePlanSignoff(false) skips plan review requests and proceeds directly. |
Complete |
NextSpeaker_Empty_Falls_Back_To_First |
Next speaker validation / warnings | Empty next_speaker emits warning, falls back to first participant, then completes on a later round. |
Complete |
Task_Completes_After_Multiple_Rounds |
Happy path / delegation loop | A non-satisfied first round delegates to a participant; a later round completes. | Complete |
PlanReview_Revised_Triggers_Replan |
Plan review / replanning / checkpoint-resume | Revision response triggers replanning, emits MagenticReplannedEvent, requests review again, then completes after approval. |
Complete |
MaxRoundLimit_Terminates_Workflow |
Limit enforcement | Round limit is checked before the next coordination round and yields the maximum round limit message. | Complete |
MaxStallCount_Triggers_Reset |
Stall detection / replanning | A stalled progress ledger reaches MaxStallCount, resets, replans, emits MagenticReplannedEvent, and then completes. |
Complete |
Instruction_Message_Sent_When_Present |
Edge cases / delegation | Non-empty instruction_or_question in the progress ledger triggers the instruction path; the workflow delegates correctly and completes. |
Complete |
PlanReview_On_Stall_Replan |
Plan review / stall / checkpoint-resume | Stall-triggered replan with requirePlanSignoff=true sends a new plan review request; approval resumes and completes. |
Complete |
MaxResetLimit_Terminates_Workflow |
Limit enforcement | Stall triggers reset; on the next coordination round, the reset limit is detected and the workflow terminates with "maximum reset count limit". | Complete |
Coverage Against Original Plan
1. Happy Path Tests
| Planned Test | Status | Notes |
|---|---|---|
Task_Completes_When_RequestSatisfied |
Implemented | Covered directly. |
Task_Delegates_To_Correct_Agent |
Partially covered | Multi-round tests prove delegation can occur, but no test currently asserts that a specific selected participant receives the turn. |
Task_Completes_After_Multiple_Rounds |
Implemented | Covered directly with a participant response and second manager round. |
PlanSignoff_Disabled_Proceeds_Immediately |
Implemented | Covered directly and asserts no review request is emitted. |
Summary: 3 complete, 1 partial.
2. Plan Review Tests
| Planned Test | Status | Notes |
|---|---|---|
PlanReview_Approved_Proceeds |
Implemented | Covered directly with checkpoint/resume. |
PlanReview_Revised_Triggers_Replan |
Implemented | Covered directly with revision, replan event, second review request, approval, and completion. |
PlanReview_Multiple_Revisions |
Not implemented | Current revision test covers one revision only. |
PlanReview_On_Stall_Replan |
Implemented | Covered directly: stall → reset → replan with plan signoff → new plan review → approval → completion. |
Summary: 3 complete, 1 remaining.
3. Limit Enforcement Tests
| Planned Test | Status | Notes |
|---|---|---|
MaxRoundLimit_Terminates_Workflow |
Implemented | Covered directly. |
MaxResetLimit_Terminates_Workflow |
Implemented | Covered directly: stall → reset → replan → reset limit hit → termination with "maximum reset count limit". |
MaxStallCount_Triggers_Reset |
Implemented | Covered directly as stall-triggered reset/replan. |
Summary: 3 complete — all limit enforcement tests implemented.
4. Stall Detection Tests
| Planned Test | Status | Notes |
|---|---|---|
Stall_IsInLoop_Increments_StallCount |
Partially covered | MaxStallCount_Triggers_Reset uses IsInLoop=true, but asserts reset/replan rather than directly asserting the counter. |
Stall_NoProgress_Increments_StallCount |
Not implemented | No direct coverage for IsProgressBeingMade=false. |
Progress_Made_Decrements_StallCount |
Not implemented | No direct coverage for stall count decrement. |
Consecutive_Stalls_Trigger_Reset |
Implemented in simplified form | Covered with MaxStallCount=1; not covered with multiple consecutive stalls. |
Summary: 1 complete/simplified, 1 partial, 2 remaining.
5. Progress Ledger Validation Tests
| Planned Test | Status | Notes |
|---|---|---|
ProgressLedger_Retry_On_Parse_Failure |
Not implemented | Retry behavior remains uncovered. |
ProgressLedger_Max_Retries_Triggers_Reset |
Not implemented | Failure-after-retries reset path remains uncovered. |
ProgressLedger_Updated_Event_Emitted |
Implemented | Covered directly. |
Summary: 1 complete, 2 remaining.
6. Next Speaker Validation Tests
| Planned Test | Status | Notes |
|---|---|---|
NextSpeaker_Empty_Falls_Back_To_First |
Implemented | Covered directly. |
NextSpeaker_Invalid_Triggers_FinalAnswer |
Implemented | Covered directly. |
NextSpeaker_Valid_Delegates_Correctly |
Partially covered | Valid speaker delegation happens in multi-round tests, but the selected executor is not asserted independently. |
Summary: 2 complete, 1 partial.
7. Event Emission Tests
| Planned Test | Status | Notes |
|---|---|---|
Initial_Plan_Emits_PlanCreatedEvent |
Implemented | Covered directly. |
Replan_Emits_ReplannedEvent |
Implemented | Covered by plan revision, stall reset, and stall-with-plan-review tests. |
Warning_Events_On_Errors |
Partially covered | Empty and invalid next speaker warnings are covered; broader warning paths are not. |
Summary: 2 complete, 1 partial.
8. Checkpoint/Resume Tests
| Planned Test | Status | Notes |
|---|---|---|
Checkpoint_Saves_TaskContext |
Not implemented | No direct assertion on persisted MagenticTaskContext state. |
Checkpoint_Resume_Continues_Correctly |
Partially covered | Plan approval, plan revision, and stall-with-plan-review flows resume successfully from checkpoints. |
Checkpoint_Preserves_ProgressLedger |
Not implemented | No direct progress ledger persistence assertion. |
Summary: 1 partial, 2 remaining.
9. Edge Cases
| Planned Test | Status | Notes |
|---|---|---|
Empty_Team_Handling |
Not implemented | No coverage for zero participants. |
Single_Agent_Team |
Not implemented | Existing tests commonly use one participant, but there is no dedicated single-agent edge-case assertion. |
Instruction_Message_Sent_When_Present |
Implemented | Covered directly: non-empty instruction_or_question triggers the instruction path, delegation succeeds, workflow completes. |
Terminated_Context_Rejects_New_Messages |
Not implemented | No coverage for post-termination message handling. |
Summary: 1 complete, 3 remaining.
Success Criteria Assessment
| Success Criterion | Status | Assessment |
|---|---|---|
All logical forks in MagenticOrchestrator are covered by at least one test |
Mostly met | The major forks are covered: signoff/no-signoff, approved/revised plan review, satisfied completion, empty/invalid speaker, round limit, reset limit, stall reset, stall-with-plan-review, and instruction sending. Remaining branches: progress ledger retry/failure and post-termination behavior. |
Tests use the same patterns as HandoffOrchestrationTests |
Met | Tests use fully-built workflows, StreamingRun, CheckpointManager, pending requests, workflow events, and collected outputs. |
| Tests run against fully-built workflows | Met | All tests build workflows through MagenticWorkflowBuilder(...).Build(). |
| Each test verifies specific event emissions and state changes | Mostly met | Event and output assertions are present. Some planned state transitions, especially internal counters and checkpoint state, are only indirectly covered. |
Tests cover both requirePlanSignoff=true and false paths |
Met | Plan review tests (including stall-triggered plan review) use true; happy path, next speaker, limit, instruction, and stall tests use false. |
| Checkpoint/resume functionality is verified | Partially met | Resume is exercised through plan review flows (including stall-triggered plan review), but direct serialized-state assertions are not implemented. |
Key Observations
- The tests are true E2E tests for the workflow builder path rather than isolated protocol/unit tests.
TestReplayAgentresponse ordering is important because each re-entry intoTakeTurnAsynccan trigger another facts update and plan update before the next coordination round.- The current implementation provides strong coverage for high-risk orchestration behavior, especially human-in-the-loop and replanning flows.
- All three limit enforcement branches (round, reset, and stall) are now fully covered.
- The stall-with-plan-review path is now covered, exercising the checkpoint/resume flow during stall recovery.
- Remaining gaps are mostly about deeper verification (internal counters, checkpoint state) and progress ledger failure handling.
Recommended Next Tests
Continue one test at a time in this order:
ProgressLedger_Retry_On_Parse_Failure— requires aTestReplayAgentthat returns invalid JSON on first attempt, valid on retryProgressLedger_Max_Retries_Triggers_Reset— requires aTestReplayAgentthat returns invalid JSON for all attemptsTask_Delegates_To_Correct_Agent/NextSpeaker_Valid_Delegates_Correctly— assert the specific participant agent receives the turn- Direct checkpoint state preservation tests
PlanReview_Multiple_Revisions— multiple human revision rounds before final approval- Edge cases: empty team, dedicated single-agent team, post-termination rejection
Overall Conclusion
The current implementation covers 14 of the ~31 originally planned tests and should be considered a correct and valuable implementation covering all major orchestrator decision paths. It validates the previously missing output declaration in production code, covers all three limit enforcement branches, and exercises the most complex orchestrator flows including stall-triggered replanning with plan signoff. The remaining work is well-scoped and can continue incrementally, with priority given to progress-ledger failure/retry handling.