fix(mcp): keep wait_for_task_change waiting through a planning-chain block
This commit is contained in:
@@ -198,23 +198,21 @@ public sealed class TaskWaitMcpToolsTests : IDisposable
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task WaitForTaskChange_QueuedWithBlockedByTaskId_ReportsBlockedImmediately()
|
||||
public async Task WaitForTaskChange_QueuedWithBlockedByTaskId_KeepsWaiting_BecauseTheChainResolvesItself()
|
||||
{
|
||||
// A planning-chain link clears automatically once the predecessor goes terminal, so it
|
||||
// must NOT short-circuit the wait -- otherwise waiting on a queued fan-out returns
|
||||
// instantly for every chained child and the caller burns a turn per poll.
|
||||
var predecessor = await SeedTaskAsync(TaskStatus.Queued);
|
||||
var task = await SeedTaskAsync(TaskStatus.Queued);
|
||||
task.BlockedByTaskId = predecessor.Id;
|
||||
await _tasks.UpdateAsync(task);
|
||||
var sut = BuildSut();
|
||||
var sw = Stopwatch.StartNew();
|
||||
|
||||
var result = await sut.WaitForTaskChange([task.Id], timeoutSeconds: 30, cancellationToken: CancellationToken.None);
|
||||
var result = await sut.WaitForTaskChange([task.Id], timeoutSeconds: 1, cancellationToken: CancellationToken.None);
|
||||
|
||||
sw.Stop();
|
||||
Assert.False(result.TimedOut);
|
||||
var change = Assert.Single(result.Changed);
|
||||
Assert.Equal("Blocked", change.Status);
|
||||
Assert.Contains(predecessor.Id, change.BlockedReason);
|
||||
Assert.True(sw.Elapsed < TimeSpan.FromSeconds(2), $"took {sw.Elapsed}");
|
||||
Assert.True(result.TimedOut);
|
||||
Assert.Empty(result.Changed);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
||||
Reference in New Issue
Block a user