refactor: unify skills+cli runtime and streamline ag-ui flow

This commit is contained in:
qzl
2026-04-22 17:09:37 +08:00
parent eeed737949
commit 4d55df45ab
111 changed files with 4858 additions and 3264 deletions
@@ -63,8 +63,6 @@ def test_text_end_event_with_bare_fields() -> None:
"stage": "worker",
"status": "success",
"answer": "done",
"key_points": ["point1"],
"result_type": "execution_report",
"suggested_actions": ["action1"],
"ui_schema": {"version": "2.0"},
"inputTokens": 100,
@@ -80,8 +78,6 @@ def test_text_end_event_with_bare_fields() -> None:
assert result["messageId"] == "assistant-run-1"
assert result["status"] == "success"
assert result["answer"] == "done"
assert result["key_points"] == ["point1"]
assert result["result_type"] == "execution_report"
assert result["suggested_actions"] == ["action1"]
assert result["ui_schema"] == {"version": "2.0"}
assert "inputTokens" not in result
@@ -101,8 +97,6 @@ def test_text_message_end_agui_event_strips_internal_usage_fields() -> None:
"stage": "worker",
"status": "success",
"answer": "done",
"key_points": [],
"result_type": "execution_report",
"suggested_actions": [],
"inputTokens": 100,
"outputTokens": 50,
@@ -122,7 +116,7 @@ def test_text_message_end_agui_event_strips_internal_usage_fields() -> None:
assert "model" not in result
def test_tool_call_result_agui_event_strips_tool_ui_fields() -> None:
def test_tool_call_result_agui_event_compiles_tool_ui_hints() -> None:
event = {
"type": "TOOL_CALL_RESULT",
"threadId": "thread-1",
@@ -140,43 +134,14 @@ def test_tool_call_result_agui_event_strips_tool_ui_fields() -> None:
"status": "success",
"title": "Done",
},
"ui_schema": {"version": "2.0"},
}
result = to_agui_wire_event(event)
assert result["type"] == "TOOL_CALL_RESULT"
assert "ui_hints" not in result
assert "ui_schema" not in result
def test_text_message_end_agui_event_compiles_ui_hints_to_ui_schema() -> None:
event = {
"type": "TEXT_MESSAGE_END",
"threadId": "thread-1",
"runId": "run-1",
"messageId": "assistant-1",
"role": "assistant",
"stage": "worker",
"status": "success",
"answer": "done",
"key_points": [],
"result_type": "summary",
"suggested_actions": [],
"ui_hints": {
"intent": "message",
"status": "info",
"body": "done",
},
}
result = to_agui_wire_event(event)
assert result["type"] == "TEXT_MESSAGE_END"
assert "ui_hints" not in result
assert isinstance(result.get("ui_schema"), dict)
def test_step_started_internal_event_keeps_step_name() -> None:
internal = {
"type": "step.start",
@@ -83,15 +83,8 @@ async def test_store_persists_worker_output_with_answer_as_content(
"stage": "worker",
"status": "success",
"answer": "worker-answer",
"key_points": [],
"result_type": "summary",
"suggested_actions": [],
"error": None,
"ui_hints": {
"intent": "message",
"status": "success",
"sections": [],
},
}
)
@@ -101,7 +94,6 @@ async def test_store_persists_worker_output_with_answer_as_content(
metadata = cast(dict[str, Any], append_kwargs["metadata"])
assert sorted(metadata.keys()) == ["agent_output", "agent_type", "run_id"]
assert metadata["agent_output"]["answer"] == "worker-answer"
assert metadata["agent_output"]["ui_hints"]["intent"] == "message"
assert append_kwargs["cost"] == Decimal("0.123")
assert append_kwargs["visibility_mask"] == ((1 << 0) | (1 << 1))
assert captured["message_delta"] == 1
@@ -165,8 +157,6 @@ async def test_store_sets_history_only_visibility_for_automation_worker_output(
"runtime_mode": "automation",
"status": "success",
"answer": "automation-result",
"key_points": [],
"result_type": "summary",
"suggested_actions": [],
"error": None,
}
@@ -194,19 +184,9 @@ async def test_store_persists_router_step_output_for_cost_tracking(
"stepName": "router",
"_router_persist": {
"router_output": {
"normalized_task_input": {
"user_text": "安排明天会议",
"context_summary": "",
},
"key_entities": [],
"constraints": [],
"task_typing": {"primary": "scheduling"},
"execution_mode": "tool_assisted",
"result_typing": {"primary": "execution_report"},
"ui": {
"ui_mode": "none",
"ui_decision_reason": "单任务",
},
"objective": "安排明天会议",
"context_summary": "",
"requires_tool_evidence": True,
},
"response_metadata": {
"model": "doubao-seed-1-6-250615",