2026-03-25 17:41:55 +08:00
|
|
|
from __future__ import annotations
|
|
|
|
|
|
2026-04-22 17:09:37 +08:00
|
|
|
from schemas.agent.runtime_models import RouterAgentOutput, WorkerAgentOutputLite
|
2026-03-25 17:41:55 +08:00
|
|
|
|
|
|
|
|
|
2026-04-22 17:09:37 +08:00
|
|
|
def test_router_agent_output_parses_simplified_contract() -> None:
|
2026-03-25 17:41:55 +08:00
|
|
|
payload = {
|
2026-04-22 17:09:37 +08:00
|
|
|
"objective": "查询今天的日程安排",
|
|
|
|
|
"context_summary": "用户询问天气",
|
|
|
|
|
"requires_tool_evidence": True,
|
2026-03-25 17:41:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
model = RouterAgentOutput.model_validate(payload)
|
|
|
|
|
|
2026-04-22 17:09:37 +08:00
|
|
|
assert model.objective == "查询今天的日程安排"
|
|
|
|
|
assert model.requires_tool_evidence is True
|
2026-03-30 18:36:57 +08:00
|
|
|
|
|
|
|
|
|
2026-04-22 17:09:37 +08:00
|
|
|
def test_worker_agent_output_lite_keeps_suggested_actions() -> None:
|
2026-03-30 18:36:57 +08:00
|
|
|
payload = {
|
|
|
|
|
"status": "success",
|
|
|
|
|
"answer": "done",
|
2026-04-22 17:09:37 +08:00
|
|
|
"suggested_actions": ["要不要我继续帮你查明天的安排?"],
|
2026-03-30 18:36:57 +08:00
|
|
|
}
|
|
|
|
|
|
2026-04-22 17:09:37 +08:00
|
|
|
model = WorkerAgentOutputLite.model_validate(payload)
|
2026-03-30 18:36:57 +08:00
|
|
|
|
2026-04-22 17:09:37 +08:00
|
|
|
assert model.suggested_actions == ["要不要我继续帮你查明天的安排?"]
|