Skip to content

Commit 8ff8578

Browse files
committed
Updated tests to fix assertions
1 parent b8d47b1 commit 8ff8578

3 files changed

Lines changed: 37 additions & 4 deletions

File tree

‎src/select_ai/agent/a2a/server.py‎

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,16 @@
77

88
"""A2A HTTP server for Oracle Database AI Agent Teams."""
99

10+
import json
1011
from contextlib import asynccontextmanager
1112
from typing import Optional
1213

1314
from a2a.compat.v0_3.conversions import to_compat_agent_card
14-
from a2a.helpers import new_task_from_user_message, new_text_part
15+
from a2a.helpers import (
16+
new_data_part,
17+
new_task_from_user_message,
18+
new_text_part,
19+
)
1520
from a2a.server.agent_execution import AgentExecutor
1621
from a2a.server.request_handlers import DefaultRequestHandler
1722
from a2a.server.routes import create_jsonrpc_routes
@@ -27,6 +32,25 @@
2732
from select_ai.agent.a2a.task_store import OracleTaskStore
2833
from select_ai.version import __version__
2934

35+
_A2UI_MIME_TYPE = "application/a2ui+json"
36+
37+
38+
def _a2ui_payload(result: str | None) -> dict | None:
39+
"""Return an A2UI response envelope, if ``RUN_TEAM`` returned one."""
40+
if not result:
41+
return None
42+
try:
43+
payload = json.loads(result)
44+
except json.JSONDecodeError:
45+
return None
46+
if not isinstance(payload, dict):
47+
return None
48+
if payload.get("metadata", {}).get("mimeType") != _A2UI_MIME_TYPE:
49+
return None
50+
if not isinstance(payload.get("data"), list):
51+
return None
52+
return payload
53+
3054

3155
class DatabaseTeamExecutor(AgentExecutor):
3256
"""Execute A2A requests with one Oracle conversation per A2A context."""
@@ -57,8 +81,13 @@ async def execute(self, context, event_queue):
5781
prompt=context.get_user_input(),
5882
params={"conversation_id": conversation_id},
5983
)
84+
a2ui_payload = _a2ui_payload(result)
6085
await updater.add_artifact(
61-
parts=[new_text_part(result or "")],
86+
parts=(
87+
[new_data_part(a2ui_payload)]
88+
if a2ui_payload is not None
89+
else [new_text_part(result or "")]
90+
),
6291
name="database-agent-result",
6392
last_chunk=True,
6493
)

‎tests/agents/test_3300_teams.py‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,9 @@ def test_3304_team_and_task_history(team):
216216
assert len(tool_runs) == 1
217217
assert tool_runs[0].tool_name == PYSAI_3300_TOOL_NAME
218218
assert tool_runs[0].invocation_id
219-
assert tool_runs[0].output == {"message": "history test complete"}
219+
assert tool_runs[0].output == {
220+
"status": "success",
221+
"result": '\'{"message":"history test complete"}\'',
222+
}
220223
finally:
221224
conversation.delete(force=True)

‎tests/agents/test_3700_async_teams.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,8 @@ async def test_3304_async_team_and_task_history(team):
228228
assert tool_runs[0].tool_name == PYSAI_3700_TOOL_NAME
229229
assert tool_runs[0].invocation_id
230230
assert tool_runs[0].output == {
231-
"message": "async history test complete"
231+
"status": "success",
232+
"result": '\'{"message":"async history test complete"}\'',
232233
}
233234
finally:
234235
await conversation.delete(force=True)

0 commit comments

Comments
 (0)