Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions dotnet/src/Microsoft.Agents.AI.DurableTask/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## [Unreleased]

- Fixed `WorkflowOutputEvent` streaming deserialization to read `executorId` instead of the renamed `sourceId` property, with fallback for backward compatibility.
Comment thread
Copilot marked this conversation as resolved.
Outdated
- Fix issue with resuming checkpoint after package version upgrade ([#6670](https://github.com/microsoft/agent-framework/pull/6670))
- Bind MCP threadId to the current agent and guard cross-agent session dispatch ([#6531](https://github.com/microsoft/agent-framework/pull/6531))
- Added support for durable workflows ([#4436](https://github.com/microsoft/agent-framework/pull/4436))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -425,9 +425,13 @@ private static bool TryParseWorkflowResult(string? serializedOutput, [NotNullWhe
}

// WorkflowOutputEvent
string sourceId = root.GetProperty("sourceId").GetString() ?? string.Empty;
string outputExecutorId = root.TryGetProperty("executorId", out JsonElement execIdElem)
? execIdElem.GetString() ?? string.Empty
: root.TryGetProperty("sourceId", out JsonElement srcIdElem)
? srcIdElem.GetString() ?? string.Empty
: string.Empty;
Comment thread
kshyju marked this conversation as resolved.
Outdated
object? outputData = GetDataProperty(root);
return new WorkflowOutputEvent(outputData!, sourceId);
return new WorkflowOutputEvent(outputData!, outputExecutorId);
Comment thread
kshyju marked this conversation as resolved.
}

return JsonSerializer.Deserialize(json, eventType, DurableSerialization.Options) as WorkflowEvent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,35 @@ public async Task WatchStreamAsync_CompletedWithEventsInOutput_YieldsEventsAndCo
Assert.Equal("result", completedResult.Result);
}

[Fact]
public async Task WatchStreamAsync_WorkflowOutputEvent_RoundTripsCorrectlyAsync()
{
// Arrange
WorkflowOutputEvent outputEvent = new("test-data", "executor-1");
string serializedEvent = SerializeEvent(outputEvent);
string serializedOutput = SerializeWorkflowResult("done", [serializedEvent]);

Mock<DurableTaskClient> mockClient = new("test");
mockClient.Setup(c => c.GetInstanceAsync(InstanceId, true, It.IsAny<CancellationToken>()))
.ReturnsAsync(CreateMetadata(OrchestrationRuntimeStatus.Completed, serializedOutput: serializedOutput));

DurableStreamingWorkflowRun run = new(mockClient.Object, InstanceId, CreateTestWorkflow());

// Act
List<WorkflowEvent> events = [];
await foreach (WorkflowEvent evt in run.WatchStreamAsync())
{
events.Add(evt);
}

// Assert
Assert.Equal(2, events.Count);
WorkflowOutputEvent result = Assert.IsType<WorkflowOutputEvent>(events[0]);
Assert.Equal("executor-1", result.ExecutorId);
Assert.Equal("test-data", result.Data?.ToString());
Assert.Empty(result.Tags);
}
Comment thread
kshyju marked this conversation as resolved.

[Fact]
public async Task WatchStreamAsync_CompletedWithoutWrapper_YieldsFailedEventAsync()
{
Expand Down
Loading