Skip to content

Commit 85eb411

Browse files
CopilotCopilot
andcommitted
Add edge-case test for empty service_session_id preservation (#5353)
Add test_run_empty_service_session_id_preserved to verify that an empty string service_session_id is preserved as context_id and not overridden by the additional_properties fallback. This is the only scenario where the 'is not None' check behaves differently from the old 'or' logic. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 32a124d commit 85eb411

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

python/packages/a2a/tests/test_a2a_agent.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -970,6 +970,24 @@ async def test_run_message_context_id_used_when_session_has_no_service_id(mock_a
970970
assert mock_a2a_client.last_message.context_id == "fallback-ctx"
971971

972972

973+
@mark.asyncio
974+
async def test_run_empty_service_session_id_preserved(mock_a2a_client: MockA2AClient) -> None:
975+
"""Test that empty string service_session_id is preserved and not overridden by additional_properties."""
976+
agent = A2AAgent(name="Test Agent", id="test-agent", client=mock_a2a_client, http_client=None)
977+
mock_a2a_client.add_message_response("msg-ctx5", "reply")
978+
979+
session = AgentSession(service_session_id="")
980+
message = Message(
981+
role="user",
982+
contents=[Content.from_text(text="Hello")],
983+
additional_properties={"context_id": "fallback-ctx"},
984+
)
985+
await agent.run(messages=[message], session=session)
986+
987+
assert mock_a2a_client.last_message is not None
988+
assert mock_a2a_client.last_message.context_id == ""
989+
990+
973991
# endregion
974992

975993

0 commit comments

Comments
 (0)