Skip to content

Commit bc05e90

Browse files
committed
Merge branch 'v2/fix/4986-everything-async-task-tools' into v2/fix/5004-everything-wave1-rollup
2 parents 6f10afa + 8c2cedb commit bc05e90

3 files changed

Lines changed: 18 additions & 2 deletions

File tree

‎.changeset/everything-async-task-tools.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
"@modelcontextprotocol/server-everything": patch
33
---
44

5-
Fix the async task tools: `trigger-elicitation-request-async` now stops polling before the 10-minute TTL it requests for the client's task runs out, instead of polling past it and failing on a task the client has expired (#4986); and `trigger-sampling-request-async` reports the status message of a client task that is already finished when it is created, instead of "No message" (#4987).
5+
Fix the async task tools: `trigger-elicitation-request-async` now stops polling before the 10-minute TTL it requests for the client's task runs out, instead of polling past it and failing on a task the client has expired (#4986); and `trigger-sampling-request-async` reports the status message of a client task that is already finished when it is created, instead of "No message" (#4987). `trigger-elicitation-request-async` had the same flaw and gets the same fix.

‎src/everything/__tests__/tasks.test.ts‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -568,6 +568,20 @@ describe("trigger-elicitation-request-async", () => {
568568
expect(polls).toHaveLength(4);
569569
});
570570

571+
it("reports the status message of a client task that is already finished when it is created", async () => {
572+
// A task that fails before it is returned is never polled, so its status
573+
// message comes from the CreateTaskResult.
574+
const { taskStore } = await connectTaskClient((_m, taskId) => {
575+
void taskStore.updateTaskStatus(taskId!, "failed", "instant failure");
576+
});
577+
const texts = await callAsync("trigger-elicitation-request-async");
578+
expect(texts).toEqual([
579+
expect.stringMatching(
580+
/^\[FAILED\] instant failure\n\nProgress:\nTask created: \S+$/,
581+
),
582+
]);
583+
});
584+
571585
it("reports a failed client task", async () => {
572586
const { taskStore } = await connectTaskClient((_m, taskId) => {
573587
later(() => taskStore.updateTaskStatus(taskId!, "failed"));

‎src/everything/tools/trigger-elicitation-request-async.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,9 @@ export const registerTriggerElicitationRequestAsyncTool = (
157157
// Poll for task completion
158158
let attempts = 0;
159159
let taskStatus = elicitResponse.task.status;
160-
let taskStatusMessage: string | undefined;
160+
// A task that is already finished when created is never polled, so
161+
// its status message has to come from the CreateTaskResult
162+
let taskStatusMessage = elicitResponse.task.statusMessage;
161163
let timedOut = false;
162164

163165
while (

0 commit comments

Comments
 (0)