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

Aberta
#8,357 0 comentários 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 3 dias

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
3/5
Tempo estimado
1-2 dias
Facilidade para iniciantes
42/100
Tipo de issue
Bug
Clareza
Claramente especificada
Status de atividade
Ativa
Stack de tecnologia
python

Direção de pesquisa

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.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

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.

Linguagem predominante
Python
Estrelas
22.3k
Forks
4.4k
Merge médio
1d 2h
PRs com merge (30d)
6

Preparar o ambiente

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de google/adk-python

Todas as issues de google/adk-python

Issues semelhantes

Mais issues de Python

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.