Python: preserve A2A message context_id (#4686)

* Python: forward A2A context_id

* Avoid duplicating A2A context ids

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
Eduard van Valkenburg
2026-03-16 22:41:31 +01:00
committed by GitHub
Unverified
parent 414496dda7
commit 0fdcfd0f4c
2 changed files with 19 additions and 1 deletions
@@ -507,6 +507,23 @@ def test_prepare_message_for_a2a_with_multiple_contents() -> None:
assert result.parts[3].root.kind == "text" # JSON text remains as text (no parsing)
def test_prepare_message_for_a2a_forwards_context_id() -> None:
"""Test conversion of Message preserves context_id without duplicating it in metadata."""
agent = A2AAgent(client=MagicMock(), _http_client=None)
message = Message(
role="user",
contents=[Content.from_text(text="Continue the task")],
additional_properties={"context_id": "ctx-123", "trace_id": "trace-456"},
)
result = agent._prepare_message_for_a2a(message)
assert result.context_id == "ctx-123"
assert result.metadata == {"trace_id": "trace-456"}
def test_parse_contents_from_a2a_with_data_part() -> None:
"""Test conversion of A2A DataPart."""