Fix missing resultType on complete result responses (#1684)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: Tarek Mahmoud Sayed <tarekms@ntdev.microsoft.com>
This commit is contained in:
parent
fd38f51e27
commit
374e76eecd
1 changed files with 118 additions and 4 deletions
|
|
@ -58,6 +58,21 @@ public class McpServerTaskTests : ClientServerTestBase
|
|||
};
|
||||
}
|
||||
|
||||
if (toolName == "async-tool-default-resulttype")
|
||||
{
|
||||
// Intentionally leaves ResultType unset so the server boundary is responsible for
|
||||
// filling in "task" on the wire.
|
||||
var taskId = store.CreateTask();
|
||||
return new CreateTaskResult
|
||||
{
|
||||
TaskId = taskId,
|
||||
Status = McpTaskStatus.Working,
|
||||
CreatedAt = DateTimeOffset.UtcNow,
|
||||
LastUpdatedAt = DateTimeOffset.UtcNow,
|
||||
PollIntervalMs = 50,
|
||||
};
|
||||
}
|
||||
|
||||
if (toolName == "input-required-tool")
|
||||
{
|
||||
var taskId = store.CreateTask(McpTaskStatus.InputRequired);
|
||||
|
|
@ -292,6 +307,19 @@ public class McpServerTaskTests : ClientServerTestBase
|
|||
Assert.Equal("task", augmented.TaskCreated!.ResultType);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task CreateTaskResult_WithoutExplicitResultType_ServerFillsTask()
|
||||
{
|
||||
await using var client = await CreateMcpClientForServer();
|
||||
|
||||
var augmented = await client.CallToolRawAsync(
|
||||
new CallToolRequestParams { Name = "async-tool-default-resulttype" },
|
||||
TestContext.Current.CancellationToken);
|
||||
|
||||
Assert.True(augmented.IsTask);
|
||||
Assert.Equal("task", augmented.TaskCreated!.ResultType);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task GetTaskAsync_ImmediatelyAfterCreate_Resolves()
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue