fix: return TaskNotFoundError when SendMessage references non-existent taskId#788
Open
yyy9942 wants to merge 1 commit intoa2aproject:mainfrom
Open
fix: return TaskNotFoundError when SendMessage references non-existent taskId#788yyy9942 wants to merge 1 commit intoa2aproject:mainfrom
yyy9942 wants to merge 1 commit intoa2aproject:mainfrom
Conversation
…t taskId Per A2A spec section 3.4.2, when a client includes a taskId in a Message, it MUST reference an existing task. Previously, the SDK silently created a new task using the client-provided taskId, which the spec explicitly forbids. Applies to all three transports (JSON-RPC, gRPC, HTTP+JSON) via the common DefaultRequestHandler.initMessageSend() code path. Existing tests that relied on the buggy behaviour have been updated to either pre-populate the task store (when testing follow-up messages) or omit the client-provided taskId on the initial message (letting the server generate it, matching the spec-correct flow). This fixes a2aproject#766
Contributor
There was a problem hiding this comment.
Code Review
This pull request enforces A2A spec section 3.4.2 by prohibiting client-provided taskId values for new task creation. The DefaultRequestHandler now validates that any provided taskId references an existing task, throwing a TaskNotFoundError otherwise. It also ensures that follow-up messages maintain the original contextId of a task. Correspondingly, integration and unit tests across multiple modules have been updated to rely on server-generated IDs and content-based routing for test scenarios. I have no feedback to provide.
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.
Per A2A spec section 3.4.2, when a client includes a taskId in a Message, it MUST reference an existing task. The SDK was creating a new task with that id instead.
Added a guard in DefaultRequestHandler.initMessageSend() that throws TaskNotFoundError when the provided taskId does not reference an existing task.
This fixes the issue on all three transports (JSON-RPC, gRPC, HTTP+JSON) since they all use the same DefaultRequestHandler code path.
Also fixes a related contextId bug: when a follow-up message had a taskId but no contextId, RequestContext.Builder.build() was generating a fresh UUID, so the agent executor saw the wrong contextId. The rebuild now seeds contextId from the stored task.
Existing tests that relied on the old taskId behavior have been updated.
Fixes #766