Skip to content

Commit ca6cdd1

Browse files
authored
.NET: Fixes for durable agents integration tests (microsoft#4952)
* Fixing for durable agents integration tests * Add further fixes
1 parent 6b47cdb commit ca6cdd1

4 files changed

Lines changed: 14 additions & 11 deletions

File tree

dotnet/samples/04-hosting/DurableAgents/AzureFunctions/06_LongRunningTools/FunctionTriggers.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,15 @@ public static async Task<object> RunOrchestrationAsync(
3535
int iterationCount = 0;
3636
while (iterationCount++ < input.MaxReviewAttempts)
3737
{
38+
// NOTE: CustomStatus has a 16 KB UTF-16 limit in Durable Functions.
39+
// Only include short metadata here - the full content is passed via activity inputs/outputs.
3840
context.SetCustomStatus(
3941
new
4042
{
4143
message = "Requesting human feedback.",
4244
approvalTimeoutHours = input.ApprovalTimeoutHours,
4345
iterationCount,
44-
content
46+
contentTitle = content.Title,
4547
});
4648

4749
// Step 2: Notify user to review the content
@@ -63,7 +65,6 @@ public static async Task<object> RunOrchestrationAsync(
6365
{
6466
message = $"Human approval timed out after {input.ApprovalTimeoutHours} hour(s). Treating as rejection.",
6567
iterationCount,
66-
content
6768
});
6869
throw new TimeoutException($"Human approval timed out after {input.ApprovalTimeoutHours} hour(s).");
6970
}
@@ -73,7 +74,7 @@ public static async Task<object> RunOrchestrationAsync(
7374
context.SetCustomStatus(new
7475
{
7576
message = "Content approved by human reviewer. Publishing content...",
76-
content
77+
contentTitle = content.Title,
7778
});
7879

7980
// Step 4: Publish the approved content
@@ -83,7 +84,7 @@ public static async Task<object> RunOrchestrationAsync(
8384
{
8485
message = $"Content published successfully at {context.CurrentUtcDateTime:s}",
8586
humanFeedback = humanResponse,
86-
content
87+
contentTitle = content.Title,
8788
});
8889
return new { content = content.Content };
8990
}
@@ -92,7 +93,7 @@ public static async Task<object> RunOrchestrationAsync(
9293
{
9394
message = "Content rejected by human reviewer. Incorporating feedback and regenerating...",
9495
humanFeedback = humanResponse,
95-
content
96+
contentTitle = content.Title,
9697
});
9798

9899
// Incorporate human feedback and regenerate

dotnet/samples/04-hosting/DurableAgents/ConsoleApps/06_LongRunningTools/Program.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,15 @@ static async Task<object> RunOrchestratorAsync(TaskOrchestrationContext context,
7777
int iterationCount = 0;
7878
while (iterationCount++ < input.MaxReviewAttempts)
7979
{
80+
// NOTE: CustomStatus has a 16 KB UTF-16 limit in Durable Functions.
81+
// Only include short metadata here - the full content is passed via activity inputs/outputs.
8082
context.SetCustomStatus(
8183
new
8284
{
8385
message = "Requesting human feedback.",
8486
approvalTimeoutHours = input.ApprovalTimeoutHours,
8587
iterationCount,
86-
content
88+
contentTitle = content.Title,
8789
});
8890

8991
// Step 2: Notify user to review the content
@@ -105,7 +107,6 @@ static async Task<object> RunOrchestratorAsync(TaskOrchestrationContext context,
105107
{
106108
message = $"Human approval timed out after {input.ApprovalTimeoutHours} hour(s). Treating as rejection.",
107109
iterationCount,
108-
content
109110
});
110111
throw new TimeoutException($"Human approval timed out after {input.ApprovalTimeoutHours} hour(s).");
111112
}
@@ -115,7 +116,7 @@ static async Task<object> RunOrchestratorAsync(TaskOrchestrationContext context,
115116
context.SetCustomStatus(new
116117
{
117118
message = "Content approved by human reviewer. Publishing content...",
118-
content
119+
contentTitle = content.Title,
119120
});
120121

121122
// Step 4: Publish the approved content
@@ -125,7 +126,7 @@ static async Task<object> RunOrchestratorAsync(TaskOrchestrationContext context,
125126
{
126127
message = $"Content published successfully at {context.CurrentUtcDateTime:s}",
127128
humanFeedback = humanResponse,
128-
content
129+
contentTitle = content.Title,
129130
});
130131
return new { content = content.Content };
131132
}
@@ -134,7 +135,7 @@ static async Task<object> RunOrchestratorAsync(TaskOrchestrationContext context,
134135
{
135136
message = "Content rejected by human reviewer. Incorporating feedback and regenerating...",
136137
humanFeedback = humanResponse,
137-
content
138+
contentTitle = content.Title,
138139
});
139140

140141
// Incorporate human feedback and regenerate

dotnet/samples/04-hosting/DurableAgents/ConsoleApps/07_ReliableStreaming/Program.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,7 @@ async Task ReadStreamTask(string conversationId, string? cursor, CancellationTok
285285
if (chunk.Text != null)
286286
{
287287
Console.Write(chunk.Text);
288+
Console.Out.Flush();
288289
}
289290

290291
// Always update lastCursor to track the latest entry ID, even if text is null

dotnet/tests/Microsoft.Agents.AI.Hosting.AzureFunctions.IntegrationTests/SamplesValidation.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public sealed class SamplesValidation(ITestOutputHelper outputHelper) : IAsyncLi
3535
.Build();
3636

3737
private static bool s_infrastructureStarted;
38-
private static readonly TimeSpan s_orchestrationTimeout = TimeSpan.FromMinutes(1);
38+
private static readonly TimeSpan s_orchestrationTimeout = TimeSpan.FromMinutes(2);
3939

4040
// In CI, `dotnet run` builds the Functions project from scratch before the host starts, so 60s is not enough.
4141
private static readonly TimeSpan s_functionsReadyTimeout = TimeSpan.FromSeconds(180);

0 commit comments

Comments
 (0)