fix(core): disambiguate task result responses - #913
Open
jstar0 wants to merge 1 commit into
Open
Conversation
devcrocod
force-pushed
the
fix/task-result-deserialization
branch
from
July 27, 2026 12:53
e29d74b to
2b11a43
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix task response deserialization so
tasks/resultpreserves the original result object even when its shape overlaps another known result type, whiletasks/getandtasks/cancelcontinue to return typed task state.Root Cause
JSON-RPC responses contain an ID and result but not the original request method. The response serializer therefore classifies
RequestResultfrom JSON shape alone. That is insufficient for task APIs:tasks/resultreturns the original request's result object, so a valid payload can look likeGetTaskResult,CallToolResult, or an extension-defined result.The payload could consequently be decoded into the wrong runtime subtype or rejected before
Protocol.request()correlated it with the request method.Changes
tasks/get,tasks/cancel, andtasks/resultusing the correlated request method before completing the request.JSONRPCResponseserializer unchanged.Scope and Risk
The change is limited to task response result selection. Existing non-task methods keep their current content-based result type. Unknown object-shaped responses can now reach request correlation as raw task payloads; the original result is returned unchanged only for
tasks/result.GetTaskPayloadResultis currently object-backed, so array and scalar task payloads remain outside this change.The existing request API erases
T, so its final internal completion cast remains. This change makes the task result's runtime subtype correct before that boundary. Removing the cast itself would require changing the public request contract, which was the breaking approach rejected in #717.Verification
Closes #601