Repository navigation
fix(server): forward CancelTaskRequest.metadata to AgentExecutor.cancel - #1416
Open
mykytanetipa wants to merge 1 commit into
Open
mykytanetipa wants to merge 1 commit into
mykytanetipa wants to merge 1 commit into
Conversation
Parse the optional JSON request body in RestDispatcher.on_cancel_task while preserving the URL path task ID and allowing empty bodies, accept CancelTaskRequest in RequestContext so context.metadata exposes cancel metadata without affecting message-only fields, thread CancelTaskRequest through DefaultRequestHandlerV2/ActiveTask.cancel and LegacyRequestHandler, and register the optional CancelTaskRequest body in FastAPI OpenAPI routes. Fixes #1415
🧪 Code Coverage (vs
|
| Base | PR | Delta | |
|---|---|---|---|
| src/a2a/server/agent_execution/context.py | 97.17% | 97.20% | 🟢 +0.03% |
| src/a2a/server/routes/fastapi_routes.py | 91.78% | 91.89% | 🟢 +0.11% |
| src/a2a/server/routes/rest_dispatcher.py | 94.92% | 95.08% | 🟢 +0.17% |
| Total | 93.42% | 93.42% | 🟢 +0.01% |
Generated by coverage-comment.yml
mykytanetipa
marked this pull request as ready for review
November 3, 2026 13:38
This branch has not been deployed
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.
CancelTaskRequest carries a metadata field and all three client transports already send it, but it was dropped on the server before reaching AgentExecutor.cancel. RestDispatcher.on_cancel_task ignored the request body altogether, and both DefaultRequestHandlerV2 (through ActiveTask.cancel) and LegacyRequestHandler built RequestContext without passing the cancel request.
This parses the optional body on POST /tasks/{id}:cancel (keeping empty bodies valid and path id authoritative), updates FastAPI OpenAPI schema accordingly, and passes CancelTaskRequest into RequestContext so context.metadata is available in AgentExecutor.cancel just like in execute.
Fixes #1415