Skip to content

fix(server): forward CancelTaskRequest.metadata to AgentExecutor.cancel - #1416

Open
mykytanetipa wants to merge 1 commit into
mainfrom
fix/cancel-task-metadata
Open

mykytanetipa wants to merge 1 commit into
mainfrom
fix/cancel-task-metadata

Conversation

@mykytanetipa

Copy link
Copy Markdown
Collaborator

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

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
@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown

🧪 Code Coverage (vs main)

⬇️ Download Full Report

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
mykytanetipa marked this pull request as ready for review November 3, 2026 13:38
@mykytanetipa
mykytanetipa requested a review from a team as a code owner November 3, 2026 13:39

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: CancelTaskRequest.metadata never reaches AgentExecutor.cancel

1 participant