Skip to content

Commit 3dbcec8

Browse files
committed
Harden Windows runtime cancellation test
1 parent a4ff9e9 commit 3dbcec8

2 files changed

Lines changed: 15 additions & 7 deletions

File tree

docs/testing/test-run-report.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Agent Testing Run Report
22

3-
Generated: `2026-05-10T05:54:06.6070430+00:00`
3+
Generated: `2026-05-10T05:59:56.0495010+00:00`
44
Gate status: **PASS**
55

66
## Gates
@@ -17,10 +17,10 @@ Gate status: **PASS**
1717

1818
| Scenario | Risk | Status | Trace |
1919
|----------|------|--------|-------|
20-
| approval-required | High | PASS | ../../artifacts/testing/traces/approval-required-5b3e9dfbd49b4aa38248e18a53fe2bdc.trace.json |
21-
| basic-tool-call | Low | PASS | ../../artifacts/testing/traces/basic-tool-call-839642e81d57494b929e919342f7336e.trace.json |
22-
| timeout-retry-placeholder | Medium | PASS | ../../artifacts/testing/traces/timeout-retry-placeholder-ff5d2c5d3f51486eb1d91c7c2839c9de.trace.json |
23-
| unsafe-tool-blocked | Critical | PASS | ../../artifacts/testing/traces/unsafe-tool-blocked-e9bab80b1fdb4c0186e48168dbae8c23.trace.json |
20+
| approval-required | High | PASS | ../../artifacts/testing/traces/approval-required-090deedfc1c04db4abda800f84f29bf2.trace.json |
21+
| basic-tool-call | Low | PASS | ../../artifacts/testing/traces/basic-tool-call-bcb5823a36b24b4ea6d0f665b3707164.trace.json |
22+
| timeout-retry-placeholder | Medium | PASS | ../../artifacts/testing/traces/timeout-retry-placeholder-b0404d48e66a4a32b5d1aa13eb9517d1.trace.json |
23+
| unsafe-tool-blocked | Critical | PASS | ../../artifacts/testing/traces/unsafe-tool-blocked-3bd2cf6dda5d4d0a855d8acf7f83738a.trace.json |
2424

2525
## Oracle Results
2626

tests/SharpClaw.Code.IntegrationTests/Runtime/ConversationRuntimeFlowTests.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,18 +191,26 @@ private static async Task RunPromptWithCancelAfterTurnStartAsync(
191191
{
192192
using var cts = new CancellationTokenSource();
193193
var runTask = runtime.RunPromptAsync(request, cts.Token);
194-
await WaitForActiveTurnAsync(runtime, workspacePath, CancellationToken.None).ConfigureAwait(false);
194+
await WaitForActiveTurnAsync(runtime, runTask, workspacePath, CancellationToken.None).ConfigureAwait(false);
195195
cts.CancelAfter(cancelAfter);
196196
await runTask.ConfigureAwait(false);
197197
}
198198

199199
private static async Task WaitForActiveTurnAsync(
200200
IConversationRuntime runtime,
201+
Task runTask,
201202
string workspacePath,
202203
CancellationToken cancellationToken)
203204
{
204-
for (var attempt = 0; attempt < 400; attempt++)
205+
var maxAttempts = OperatingSystem.IsWindows() ? 1800 : 400;
206+
for (var attempt = 0; attempt < maxAttempts; attempt++)
205207
{
208+
if (runTask.IsCompleted)
209+
{
210+
await runTask.ConfigureAwait(false);
211+
throw new TimeoutException("The runtime completed before an active turn could be observed.");
212+
}
213+
206214
var latestSession = await runtime.GetLatestSessionAsync(workspacePath, cancellationToken).ConfigureAwait(false);
207215
if (!string.IsNullOrWhiteSpace(latestSession?.ActiveTurnId))
208216
{

0 commit comments

Comments
 (0)