You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
convert_a2a_message_to_event() in to_adk_event.py hard-codes role="model" for all resulting ADK events, regardless of the original A2A Message.role. User messages (Role.user) are incorrectly restored as model events.
The task history fallback (a2a_task.history[-1]) also does not check Message.role, so a trailing user message can be treated as agent output.
Steps to Reproduce
froma2a.typesimportMessage, Part, TextPart, Roleuser_msg=Message(
role=Role.user,
parts=[Part(root=TextPart(text="Hello"))],
metadata={}
)
event=convert_a2a_message_to_event(user_msg, author="user")
# event author is always "model" — should reflect "user"
Expected Behavior
A2A Role.user should map to an ADK event with role="user"
History fallback should only use agent-role messages to avoid misattribution
I'd like to work on this. The fix should map Message.role to the correct ADK event author/role instead of hard-coding "model" in convert_a2a_message_to_event(). Will submit a PR shortly.
@YizukiAme _create_event() in to_adk_event.py hardcodes role="model" and never reads a2a_message.role, which is what's causing the misattribution.
As a quick workaround, try wrapping convert_a2a_message_to_event() and fixing the role post-call via event.model_copy(update={"content": event.content.model_copy(update={"role": "user" if msg.role == Role.user else "model"})}).
It's also worth filtering history[-1] to agent-role only to avoid the second misattribution while you're in there.
Could you give that a try and let us know if it clears both issues on your end?
PR #5224 is already heading in this direction, so your confirmation there before it moves forward would be really helpful!
Thanks @surajksharma07! I reviewed the diff in PR #5224 and the fix looks correct for both issues:
Role hardcoding: a2a_role_to_genai_role() correctly maps Role.user → "user" in both event_converter.py and to_adk_event.py.
History fallback: history[-1] is now filtered to Role.agent only, preventing trailing user messages from being misattributed.
(I originally found this via code audit rather than a live A2A setup, so my verification is code-level. But the root cause was a hardcoded string, and the fix + regression tests clearly address it.)
Thanks for the thorough review @YizukiAme — a code-level LGTM is completely valid here given the root cause was a straightforward hardcode with no ambiguity.
We currently have two PRs open targeting the same fix (#5198 by @enjoykumawat and #5224 by @giulio-leone), so the team will review both and consolidate before merging.
We'll get this closed out once one lands — really appreciate you circling back so quickly!
Activity
enjoykumawat commentedon Apr 7, 2026
I'd like to work on this. The fix should map
Message.roleto the correct ADK event author/role instead of hard-coding"model"inconvert_a2a_message_to_event(). Will submit a PR shortly.fix: map A2A Message.role to correct GenAI content role
anowardear062-svg commentedon Apr 7, 2026
Thanks
fix: respect A2A Message.role in inbound event conversion (google#5186)
fix: respect A2A Message.role in inbound event conversion (google#5186)
fix: respect A2A Message.role in inbound event conversion (google#5186)
fix: map A2A Message.role to correct GenAI content role
surajksharma07 commentedon Apr 9, 2026
@YizukiAme _create_event() in to_adk_event.py hardcodes role="model" and never reads a2a_message.role, which is what's causing the misattribution.
As a quick workaround, try wrapping convert_a2a_message_to_event() and fixing the role post-call via event.model_copy(update={"content": event.content.model_copy(update={"role": "user" if msg.role == Role.user else "model"})}).
It's also worth filtering history[-1] to agent-role only to avoid the second misattribution while you're in there.
Could you give that a try and let us know if it clears both issues on your end?
PR #5224 is already heading in this direction, so your confirmation there before it moves forward would be really helpful!
YizukiAme commentedon Apr 9, 2026
Thanks @surajksharma07! I reviewed the diff in PR #5224 and the fix looks correct for both issues:
(I originally found this via code audit rather than a live A2A setup, so my verification is code-level. But the root cause was a hardcoded string, and the fix + regression tests clearly address it.)
LGTM from the reporter side~ 👍
surajksharma07 commentedon Apr 10, 2026
Thanks for the thorough review @YizukiAme — a code-level LGTM is completely valid here given the root cause was a straightforward hardcode with no ambiguity.
We currently have two PRs open targeting the same fix (#5198 by @enjoykumawat and #5224 by @giulio-leone), so the team will review both and consolidate before merging.
We'll get this closed out once one lands — really appreciate you circling back so quickly!
surajksharma07 commentedon Apr 10, 2026
@Jacksunwei Please have a look into it once.
fix: respect A2A Message.role in inbound event conversion (google#5186)
fix: map A2A Message.role to correct GenAI content role
fix: respect A2A Message.role in inbound event conversion
fix: map A2A Message.role to correct GenAI content role
fix: respect A2A Message.role in inbound event conversion