Skip to content

Commit 8c2cedb

Browse files
cliffhallclaude
andcommitted
fix(everything): keep an elicitation task's status message from creation
trigger-elicitation-request-async had the same flaw as #4987 in the sampling tool: the status message was only read from polls, so a client task already failed when created was reported as "No message". It now starts from the CreateTaskResult's statusMessage. A test mirroring the #4987 one covers it, and the changeset mentions it. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: cliffhall <[email protected]>
1 parent 7d82461 commit 8c2cedb

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
@@ -153,7 +153,9 @@ export const registerTriggerElicitationRequestAsyncTool = (
153153
// Poll for task completion
154154
let attempts = 0;
155155
let taskStatus = elicitResponse.task.status;
156-
let taskStatusMessage: string | undefined;
156+
// A task that is already finished when created is never polled, so
157+
// its status message has to come from the CreateTaskResult
158+
let taskStatusMessage = elicitResponse.task.statusMessage;
157159
let timedOut = false;
158160

159161
while (

0 commit comments

Comments
 (0)