Skip to content

Commit 44ca105

Browse files
jeffhandleyCopilot
andcommitted
Restore accurate illustrative comments in TasksExtension sample
- Restore the inline-result branch comment on the !raw.IsTask path - Restore the CompletedTaskResult JsonElement deserialization comment - Restore the RunReport sleep-vs-real-work comment Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent b37e901 commit 44ca105

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

samples/TasksExtension/Program.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@
4141
var raw = await client.CallToolAsTaskAsync(new CallToolRequestParams { Name = "run-report" });
4242
if (!raw.IsTask)
4343
{
44+
// Either the server doesn't advertise the tasks extension or it chose to run the call
45+
// synchronously despite the client opt-in. Surface the inline result and stop.
4446
Console.WriteLine($" result (inline): {((TextContentBlock)raw.Result!.Content[0]).Text}");
4547
return;
4648
}
@@ -64,6 +66,7 @@
6466
switch (state)
6567
{
6668
case CompletedTaskResult completed:
69+
// The Result property carries the wrapped CallToolResult as a raw JsonElement.
6770
var callToolResult = completed.Result.Deserialize<CallToolResult>()!;
6871
Console.WriteLine($" task completed after {pollCount} poll(s): {((TextContentBlock)callToolResult.Content[0]).Text}");
6972
return;
@@ -91,6 +94,8 @@ internal static class SlowTools
9194
[Description("Runs a short simulated report and returns when it's done.")]
9295
public static async Task<string> RunReport(CancellationToken cancellationToken)
9396
{
97+
// Real-world workloads would do meaningful work here; we just sleep so the polling
98+
// path is observable in the console output.
9499
await Task.Delay(TimeSpan.FromSeconds(1), cancellationToken);
95100
return "report ready";
96101
}

0 commit comments

Comments
 (0)