mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
Merge branch 'main' into dev/dotnet_workflow/add_handoff_composability_test
This commit is contained in:
+8
@@ -483,6 +483,14 @@ public sealed class AnthropicBetaServiceExtensionsTests
|
||||
|
||||
public IBetaMessageService Messages => new Mock<IBetaMessageService>().Object;
|
||||
|
||||
public global::Anthropic.Services.Beta.IAgentService Agents => throw new NotImplementedException();
|
||||
|
||||
public global::Anthropic.Services.Beta.IEnvironmentService Environments => throw new NotImplementedException();
|
||||
|
||||
public global::Anthropic.Services.Beta.ISessionService Sessions => throw new NotImplementedException();
|
||||
|
||||
public global::Anthropic.Services.Beta.IVaultService Vaults => throw new NotImplementedException();
|
||||
|
||||
public IBetaService WithOptions(Func<ClientOptions, ClientOptions> modifier)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
|
||||
@@ -279,6 +279,48 @@ public class CheckpointResumeTests
|
||||
"the workflow should be able to continue after the runtime restore replay");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that restoring a live run clears any queued external responses from the
|
||||
/// superseded timeline before importing checkpoint state.
|
||||
/// </summary>
|
||||
[Fact]
|
||||
internal async Task Checkpoint_Restore_ClearsQueuedExternalResponsesBeforeImportAsync()
|
||||
{
|
||||
Workflow workflow = CreateSimpleRequestWorkflow();
|
||||
CheckpointManager checkpointManager = CheckpointManager.CreateInMemory();
|
||||
InProcessExecutionEnvironment env = ExecutionEnvironment.InProcess_Lockstep.ToWorkflowExecutionEnvironment();
|
||||
|
||||
await using StreamingRun run = await env.WithCheckpointing(checkpointManager)
|
||||
.RunStreamingAsync(workflow, "Hello");
|
||||
|
||||
(ExternalRequest pendingRequest, CheckpointInfo checkpoint) = await CapturePendingRequestAndCheckpointAsync(run);
|
||||
|
||||
await run.SendResponseAsync(pendingRequest.CreateResponse("World"));
|
||||
await run.RestoreCheckpointAsync(checkpoint);
|
||||
|
||||
List<WorkflowEvent> restoredEvents = await ReadToHaltAsync(run);
|
||||
ExternalRequest replayedRequest = restoredEvents.OfType<RequestInfoEvent>()
|
||||
.Select(evt => evt.Request)
|
||||
.Should()
|
||||
.ContainSingle("the restored run should still be waiting for the checkpointed request")
|
||||
.Subject;
|
||||
|
||||
restoredEvents.OfType<WorkflowErrorEvent>().Should().BeEmpty(
|
||||
"a queued response from the superseded timeline should not be processed after restore");
|
||||
RunStatus statusAfterRestore = await run.GetStatusAsync();
|
||||
statusAfterRestore.Should().Be(RunStatus.PendingRequests,
|
||||
"the restored run should remain pending until a post-restore response is sent");
|
||||
|
||||
await run.SendResponseAsync(replayedRequest.CreateResponse("Again"));
|
||||
|
||||
List<WorkflowEvent> completionEvents = await ReadToHaltAsync(run);
|
||||
completionEvents.OfType<WorkflowErrorEvent>().Should().BeEmpty(
|
||||
"the restored request should complete cleanly once a new response is provided");
|
||||
RunStatus finalStatus = await run.GetStatusAsync();
|
||||
finalStatus.Should().Be(RunStatus.Idle,
|
||||
"the workflow should finish once the replayed request receives a fresh response");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies that a resumed parent workflow re-emits pending requests that originated in a subworkflow.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user