The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(a2a): recover the streamed reply text instead of resolving empty
chelsealong7efacc8f6204
diff --git a/plugins/platforms/a2a/adapter.py b/plugins/platforms/a2a/adapter.pyindex 585c2ad6903..d692045b89a 100644--- a/plugins/platforms/a2a/adapter.py+++ b/plugins/platforms/a2a/adapter.py@@ -843,10 +843,18 @@ class A2AAdapter(BasePlatformAdapter):async def on_processing_complete(self, event: MessageEvent, outcome: ProcessingOutcome) -> None:"""Resolve the task future when processing ends without a reply send (failures,- cancellations, empty runs) so the HTTP thread returns promptly."""+ cancellations, empty runs, or a reply the gateway already streamed to the user) so the+ HTTP thread returns promptly."""task_id = str(getattr(event, "message_id", "") or "")if task_id:+ # A streamed turn never calls send() with notify=True (the gateway suppresses the+ # normal final send once streaming delivered the body), so the SUCCESS default must+ # not resolve with "" — that strands every A2A streaming reply as an empty completed+ # task (#116944). _streamed_final_response is the same stash _final_text_for_post_turn_hooks+ # reads for /goal and /loop.+ _streamed = getattr(event, "_streamed_final_response", "")+ default = (protocol.STATE_COMPLETED, _streamed if isinstance(_streamed, str) else "")self._resolve_task(task_id, *{ProcessingOutcome.FAILURE: (protocol.STATE_FAILED, "[agent processing failed]"),ProcessingOutcome.CANCELLED: (protocol.STATE_CANCELED, ""),- }.get(outcome, (protocol.STATE_COMPLETED, "")))+ }.get(outcome, default))diff --git a/tests/plugins/test_a2a_plugin.py b/tests/plugins/test_a2a_plugin.pyindex 87e903e81f2..3856b71dabc 100644--- a/tests/plugins/test_a2a_plugin.py+++ b/tests/plugins/test_a2a_plugin.py@@ -663,6 +663,26 @@ class TestReplyCapture:finally:adapter._pop_pending("task-ok")+ def test_on_processing_complete_recovers_streamed_reply(self):+ """#116944: when the gateway's normal final send is suppressed because streaming+ already delivered the body, send() is never called with notify=True and the future+ is resolved here instead. It must carry the reply text the gateway stashed on the+ event, not resolve TASK_STATE_COMPLETED with an empty string."""+ from gateway.platforms.event import ProcessingOutcome++ adapter = _bare_adapter()+ fut = adapter._add_pending("task-streamed", "ctx-streamed")+ event = SimpleNamespace(message_id="task-streamed", _streamed_final_response="SSE_OK")++ async def run():+ await adapter.on_processing_complete(event, ProcessingOutcome.SUCCESS)++ try:+ asyncio.run(run())+ assert fut.result(timeout=0) == (protocol.STATE_COMPLETED, "SSE_OK")+ finally:+ adapter._pop_pending("task-streamed")+# --------------------------------------------------------------------------# Adapter RPC handlers (driven directly, no HTTP)