Skip to content

Python: [Bug]: Inconsistent handling of response_id in returned messages by A2AAgent #5263

@lixiaoqiang

Description

@lixiaoqiang

Description

The A2AAgent handles the response_id inconsistently when processing returned messages.
If the returned message type is A2AMessage, it sets response_id to A2AMessage.message_id; otherwise, it sets response_id to task.id.
This results in inconsistent response_id values.
Current code:

        async for item in a2a_stream:
            if isinstance(item, A2AMessage):
                # Process A2A Message
                contents = self._parse_contents_from_a2a(item.parts)
                update = AgentResponseUpdate(
                    contents=contents,
                    role="assistant" if item.role == A2ARole.agent else "user",
                    response_id=str(getattr(item, "message_id", uuid.uuid4())),
                    additional_properties=item.metadata,
                    raw_representation=item,
                )
                all_updates.append(update)
                yield update

I think it should be handled as follows:

        async for item in a2a_stream:
            if isinstance(item, A2AMessage):
                # Process A2A Message
                contents = self._parse_contents_from_a2a(item.parts)
                update = AgentResponseUpdate(
                    contents=contents,
                    role="assistant" if item.role == A2ARole.agent else "user",
                    response_id=item.task_id or uuid.uuid4(),
                    message_id=item.message_id,
                    additional_properties=item.metadata,
                    raw_representation=item,
                )
                all_updates.append(update)
                yield update

Code Sample

Error Messages / Stack Traces

Package Versions

agent-framework-core:1.0.1

Python Version

python 3.13

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions