Skip to content

Python: [Bug]: A2AAgent should not ignore _update_event when processing responses #4901

@lixiaoqiang

Description

@lixiaoqiang

Description

The current implementation ignores the _update_event variable, which causes the streaming output of the connected agent to fail to obtain typewriter-effect output content.

        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", str(ulid.ULID()))),
                    raw_representation=item,
                )
                all_updates.append(update)
                yield update
            elif isinstance(item, tuple) and len(item) == 2 and isinstance(item[0], Task):
                task, _update_event = item # ~~~JUST HERE !!!! ~~~~
                for update in self._updates_from_task(task, background=background):
                    all_updates.append(update)
                    yield update
            else:
                raise NotImplementedError("Only Message and Task responses are supported")

The streaming response workflow of the A2A Server is roughly as follows:

  1. The first event returns a Task
  2. The second event returns the first chunk of the model output wrapped as a TaskArtifactUpdateEvent, with append = False and TaskState.working
		TaskArtifactUpdateEvent(
                    task_id=task_id,
                    context_id=context_id,
                    artifact= The First Chunk Of Model Output,
                    append= False,
                )
  1. Subsequent events wrap the subsequent model outputs as TaskArtifactUpdateEvent in sequence, with append = True and TaskState.working
  2. Returns a TaskStatusUpdateEvent with TaskState.completed

To be honest, after using the A2AAgent implementation for a period of time, I have encountered many issues, submitted some of them, and they have been fixed. First of all, I would like to thank all the developers for your hard work and timely responses.

However, this also exposes a problem: the implementation of A2AAgent has not been properly integration-tested in real business scenarios. It is already at the RC5 version, and the current quality is worrying.

Code Sample

Error Messages / Stack Traces

Package Versions

agent-framework:1.0.0rc5

Python Version

No response

Additional Context

No response

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingpythonv1.0Features being tracked for the version 1.0 GA

Type

Projects

Status

Planned

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions