google / google/adk-python

A2A inbound converters do not restore custom_metadata and drop metadata-only events

未关闭
#5,185 2 条评论 0 个 reaction 已指派 3 人 已被 @GWeale 认领 在 GitHub 查看
core needs review
主要语言
Python
星标
21.5k
派生
4k
平均合并
1 天 22 小时
30 天内合并 PR
31

描述

## Bug Description

The public inbound converters `convert_a2a_message_to_event()` and `convert_a2a_task_to_event()` in `to_adk_event.py` only restore `actions` from A2A metadata. Other ADK event metadata fields (`custom_metadata`, `usage_metadata`, `error_code`, `long_running_tool_ids`, etc.) are silently dropped.

Additionally, `_create_event()` returns `None` when there are no `parts` and no `actions`, even if `event_metadata` is present. This means metadata-only A2A messages are discarded entirely.

## Steps to Reproduce

```python
from a2a.types import Message, Part, TextPart, Role

msg = Message(
role=Role.agent,
parts=[],
metadata={"adk_custom_metadata": {"flag": True}}
)
event = convert_a2a_message_to_event(msg, author="agent")
assert event is not None # FAILS — metadata-only message silently dropped
```

## Expected Behavior

- `custom_metadata`, `usage_metadata`, and other semantic metadata fields should be restored on the resulting `Event`
- Metadata-only messages (no content parts, but valid metadata) should produce a valid `Event` with `content=None`

## Affected Files

- `src/google/adk/a2a/converters/to_adk_event.py`

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。