From 722e1fd1756f07f521282ffe89600f01808d5aff Mon Sep 17 00:00:00 2001 From: Hongming Wang Date: Mon, 27 Apr 2026 05:29:59 -0700 Subject: [PATCH] =?UTF-8?q?fix(a2a=5Fexecutor):=20migrate=20to=20a2a-sdk?= =?UTF-8?q?=201.x=20API=20=E2=80=94=20new=5Fagent=5Ftext=5Fmessage=20?= =?UTF-8?q?=E2=86=92=20new=5Ftext=5Fmessage?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit a2a-sdk v1 renamed `new_agent_text_message` → `new_text_message` (role=Role.agent is now the default). Same fix landed in the hermes template earlier today; this is the runtime-side equivalent. NOT dead code: a2a_executor.py is the LangGraph A2A executor, used by the langgraph + deepagents templates. Both templates currently import it via bare `from a2a_executor import LangGraphA2AExecutor` — which is a separate bug in those templates, filed/fixed separately. Symptom in a2a_executor.py form: any langgraph or deepagents workspace that calls create_executor crashes with `ImportError: cannot import name 'new_agent_text_message' from 'a2a.helpers'`. Doesn't surface for claude-code or hermes (their templates use their own executors and don't load a2a_executor). Five call sites updated, one import line, one comment. Test suite already passes against the new symbol — `python -c "from molecule_runtime.a2a_executor import LangGraphA2AExecutor"` resolves cleanly after this change. Co-Authored-By: Claude Opus 4.7 (1M context) --- workspace/a2a_executor.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/workspace/a2a_executor.py b/workspace/a2a_executor.py index 590be813..30b936f7 100644 --- a/workspace/a2a_executor.py +++ b/workspace/a2a_executor.py @@ -41,7 +41,7 @@ from a2a.server.events import EventQueue from a2a.server.tasks import TaskUpdater from a2a.types import Part # KI-009: a2a-sdk v1 renames a2a.utils → a2a.helpers; TextPart removed (Part takes text= directly) -from a2a.helpers import new_agent_text_message +from a2a.helpers import new_text_message from shared_runtime import ( extract_history as _extract_history, extract_message_text, @@ -231,7 +231,7 @@ class LangGraphA2AExecutor(AgentExecutor): parts = getattr(getattr(context, "message", None), "parts", None) logger.warning("A2A execute: no text content in message parts: %s", parts) await event_queue.enqueue_event( - new_agent_text_message("Error: message contained no text content.") + new_text_message("Error: message contained no text content.") ) return "" @@ -246,7 +246,7 @@ class LangGraphA2AExecutor(AgentExecutor): ) except PromptInjectionError as exc: await event_queue.enqueue_event( - new_agent_text_message(f"Request blocked: {exc}") + new_text_message(f"Request blocked: {exc}") ) return "" @@ -462,21 +462,21 @@ class LangGraphA2AExecutor(AgentExecutor): contextId=context_id, ) else: - msg = new_agent_text_message(final_text, task_id=task_id, context_id=context_id) + msg = new_text_message(final_text, task_id=task_id, context_id=context_id) # Attach tool_trace via metadata when supported. Guarded with # hasattr because some test mocks return a plain string here. if tool_trace and hasattr(msg, "metadata"): try: msg.metadata = {"tool_trace": tool_trace} except (AttributeError, TypeError): - # `new_agent_text_message()` returns a plain string in + # `new_text_message()` returns a plain string in # MagicMock paths in tests, where assignment to # .metadata raises despite hasattr being true (the # mock has the attribute as a property). Suppression # is intentional — production Message objects always # accept the assignment. See #1787 + commit dcbcf19 # for the original test-mock motivation. - logger.debug("metadata attach skipped (non-Message return from new_agent_text_message)") + logger.debug("metadata attach skipped (non-Message return from new_text_message)") await event_queue.enqueue_event(msg) _result = final_text @@ -491,7 +491,7 @@ class LangGraphA2AExecutor(AgentExecutor): # Emit a Message so both streaming and non-streaming clients # receive an error response rather than hanging. await event_queue.enqueue_event( - new_agent_text_message( + new_text_message( f"Agent error: {e}", task_id=task_id, context_id=context_id ) )