A2A (new executor): a state-only event becomes a status update whose agent message has no parts, and it lands in task history

Abierto
#8,357 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 3 días

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
42/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
python

Línea de trabajo

Start with convert_event_to_a2a_events in src/google/adk/a2a/converters/from_adk_event.py, around lines 205-220, where a state-only event builds Message(..., parts=[]) to carry actions metadata. Reproduce with to_a2a(...) using A2aAgentExecutor(force_new_version=True) and a before_agent_callback that sets state, then inspect task.history for the empty-parts agent message. Done when the status update and history carry no empty-parts message, with actions moved to metadata or the event skipped, and RemoteA2aAgent still reads the state delta.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Describe the bug

With the new A2A executor (A2aAgentExecutor(force_new_version=True), or any client that requests the ADK A2A extension), an ADK event that carries only actions (for example the state change from a before_agent_callback) is converted into a TASK_STATE_WORKING status update whose status.message has an empty parts list. The a2a-sdk task manager then appends that message to task.history, so GetTask and the SendMessage response return an agent message with no parts.

A2A v1.0 marks Message.parts as REQUIRED, and §5.7 says: "Arrays marked as required MUST contain at least one element." The legacy executor does not produce this message for the same agent.

The block is in convert_event_to_a2a_events in src/google/adk/a2a/converters/from_adk_event.py (main 4e3aff7, around L205–L220): when an event has no content parts but has actions, it builds Message(..., parts=[]) to carry the actions metadata.

To Reproduce

google-adk 2.15.1 (main 4e3aff7), a2a-sdk 1.3.1:

from google.adk.a2a.executor.a2a_agent_executor import A2aAgentExecutor
from google.adk.a2a.utils.agent_to_a2a import to_a2a
from google.adk.agents import BaseAgent
from google.adk.events import Event
from google.genai import types


class EchoAgent(BaseAgent):
  async def _run_async_impl(self, ctx):
    text = ctx.user_content.parts[0].text
    yield Event(author=self.name, invocation_id=ctx.invocation_id,
                content=types.Content(role='model', parts=[types.Part(text=f'echo: {text}')]))


def remember_turn(callback_context):
  callback_context.state['turns'] = callback_context.state.get('turns', 0) + 1


app = to_a2a(
    EchoAgent(name='echo_agent', before_agent_callback=remember_turn),
    host='127.0.0.1', port=10404,
    agent_executor_factory=lambda r: A2aAgentExecutor(runner=r, force_new_version=True),
)

Run it with uvicorn, then send {"jsonrpc":"2.0","id":1,"method":"SendMessage","params":{"message":{"messageId":"m1","role":"ROLE_USER","parts":[{"text":"hi"}]}}}.

result.task.history is:

[
  {"messageId": "m1", "role": "ROLE_USER", "parts": [{"text": "hi"}], ...},
  {"messageId": "...", "role": "ROLE_AGENT", "metadata": {"adk_actions": {"stateDelta": {"turns": 1.0}}, ...}}
]

The second message has no parts. With SendStreamingMessage, the same message appears as the status.message of a TASK_STATE_WORKING status update. Without force_new_version (legacy executor), the history holds the agent's echo: hi reply instead.

Expected behavior

No agent message with empty parts in status updates or in task history. The actions could travel in the status update event's own metadata (or the event could be skipped when there is nothing else to send), but that depends on how RemoteA2aAgent reads them back, so I've left the choice open.

Additional context

Found while running the A2A conformance suites (a2a-tck and the a2a-itk ACTS corpus) against to_a2a(). Neither suite checks history messages for empty parts today. I'm happy to open a PR once the preferred shape is clear.

Lenguaje dominante
Python
Estrellas
22.3k
Forks
4.4k
Merge medio
1 d 2 h
PR fusionados (30 d)
6

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de google/adk-python

Todos los issues de google/adk-python

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.