Skip to content

The agent that grows with you

Revert the tasks/cancel half of "fix(a2a): a forwarded task's cancel is refused; retries survive the id LRU"

Teknium8693fa691439
diff --git a/plugins/platforms/a2a/adapter.py b/plugins/platforms/a2a/adapter.py
index c37634972dd..0dd8aa2780a 100644
--- a/plugins/platforms/a2a/adapter.py
+++ b/plugins/platforms/a2a/adapter.py
@@ -753,11 +753,6 @@ class A2AAdapter(BasePlatformAdapter):
return error
if rec["state"] in protocol.TERMINAL_STATES:
return _err(req_id, protocol.ERR_TASK_NOT_CANCELABLE, f"task {task_id} already {rec['state']}")
- if rec.get("input_id"):
- # Forwarded: the owner holds the admission and this adapter cannot stop it, so marking
- # the task canceled would report a cancel while the owner's turn ran to completion.
- return _err(req_id, protocol.ERR_TASK_NOT_CANCELABLE,
- f"task {task_id} was forwarded to its profile owner; accepted work is not cancelled")
self.tasks.complete(task_id, protocol.STATE_CANCELED, "")
self._turns.reset(rec["context_id"])
self._resolve_task(task_id, protocol.STATE_CANCELED, "")
diff --git a/tests/plugins/test_a2a_forwarded_cancel_retry.py b/tests/plugins/test_a2a_forwarded_cancel_retry.py
index 391e3b93cff..8885476d360 100644
--- a/tests/plugins/test_a2a_forwarded_cancel_retry.py
+++ b/tests/plugins/test_a2a_forwarded_cancel_retry.py
@@ -1,5 +1,5 @@
-"""A2A forwarded tasks: tasks/cancel never reports a cancel the owner did not perform, and a
-resend stays a retry after the process-local id memory forgot it (andrexibiza 5480715949 P2c)."""
+"""A2A forwarded tasks: a resend stays a retry after the process-local id memory forgot it
+(andrexibiza 5480715949 P2c)."""
from gateway.config import PlatformConfig
from plugins.platforms.a2a import protocol
from plugins.platforms.a2a.adapter import A2AAdapter
@@ -10,24 +10,6 @@ def _adapter():
return adapter, adapter._agents["dev"]
-def test_cancel_of_a_forwarded_task_is_refused_and_the_owner_reply_still_lands():
- adapter, agent = _adapter()
- answers = []
-
- def forward(agent_arg, peer, context_id, framed_text, *, input_id):
- # A peer cancels while the owner is running the admitted turn.
- task_id = next(iter(adapter._active_tasks))
- answers.append(adapter._rpc_tasks_cancel(7, {"id": task_id, "tenant": "dev"}, agent=agent))
- return "owner reply", protocol.STATE_COMPLETED
-
- adapter._forward_to_profile = forward # type: ignore[method-assign]
- message = protocol.text_message(protocol.ROLE_USER, "work", context_id="ctx-cancel")
- task, _ = adapter._prepare_task({"tenant": "dev", "message": message}, "peer-x", agent=agent)
- assert answers[0]["error"]["code"] == protocol.ERR_TASK_NOT_CANCELABLE
- assert task["status"]["state"] == protocol.STATE_COMPLETED
- assert adapter.tasks.get(task["id"])["state"] == protocol.STATE_COMPLETED
-
-
def test_a_resend_evicted_from_the_process_memory_is_still_a_retry(monkeypatch):
monkeypatch.setenv("A2A_MAX_PINGPONG_TURNS", "2")
adapter, agent = _adapter()