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

Aperta
#8,357 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 3 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
42/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
python

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
Python
Stelle
22.3k
Fork
4.4k
Merge medio
1g 2h
PR unite (30g)
6

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di google/adk-python

Tutte le issue di google/adk-python

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.