91 lines
2.4 KiB
Python
91 lines
2.4 KiB
Python
from __future__ import annotations
|
|
|
|
from schemas.agent.runtime_models import RouterAgentOutput, WorkerAgentOutputRich
|
|
|
|
|
|
def test_router_agent_output_coerces_key_entity_value_to_string() -> None:
|
|
payload = {
|
|
"normalized_task_input": {
|
|
"user_text": "test",
|
|
"multimodal_summary": [],
|
|
"context_summary": "",
|
|
},
|
|
"key_entities": [
|
|
{
|
|
"name": "priority",
|
|
"type": "number",
|
|
"value": 8,
|
|
}
|
|
],
|
|
"constraints": [],
|
|
"task_typing": {
|
|
"primary": "planning",
|
|
"secondary": [],
|
|
},
|
|
"execution_mode": "onestep",
|
|
"result_typing": {
|
|
"primary": "summary",
|
|
"secondary": [],
|
|
},
|
|
}
|
|
|
|
model = RouterAgentOutput.model_validate(payload)
|
|
|
|
assert model.key_entities[0].value == "8"
|
|
|
|
|
|
def test_router_agent_output_coerces_constraint_value_to_string() -> None:
|
|
payload = {
|
|
"normalized_task_input": {
|
|
"user_text": "test",
|
|
"multimodal_summary": [],
|
|
"context_summary": "",
|
|
},
|
|
"key_entities": [],
|
|
"constraints": [
|
|
{
|
|
"key": "strict_mode",
|
|
"value": True,
|
|
"required": True,
|
|
}
|
|
],
|
|
"task_typing": {
|
|
"primary": "planning",
|
|
"secondary": [],
|
|
},
|
|
"execution_mode": "onestep",
|
|
"result_typing": {
|
|
"primary": "summary",
|
|
"secondary": [],
|
|
},
|
|
}
|
|
|
|
model = RouterAgentOutput.model_validate(payload)
|
|
|
|
assert model.constraints[0].value == "True"
|
|
|
|
|
|
def test_worker_agent_output_rich_accepts_list_item_status_object() -> None:
|
|
payload = {
|
|
"status": "success",
|
|
"answer": "done",
|
|
"result_type": "summary",
|
|
"ui_hints": {
|
|
"intent": "status",
|
|
"status": "info",
|
|
"title": "状态",
|
|
"listItems": [
|
|
{
|
|
"title": "任务A",
|
|
"status": {"type": "info", "value": "已归档"},
|
|
}
|
|
],
|
|
},
|
|
}
|
|
|
|
model = WorkerAgentOutputRich.model_validate(payload)
|
|
|
|
assert model.ui_hints is not None
|
|
assert model.ui_hints.list_items[0].status is not None
|
|
assert model.ui_hints.list_items[0].status.value == "info"
|