feat: add steps_json to trace-row adapter

This commit is contained in:
2026-07-15 11:47:00 -04:00
parent 745b600b5d
commit cf7f15d8bb
2 changed files with 81 additions and 0 deletions
+30
View File
@@ -0,0 +1,30 @@
import json
from app.harness.steps_json_traces import steps_json_to_trace_rows
def test_parses_tool_call_into_name_and_args():
# 真实 infer_adhoc steps_json 形态:tool_call={"tool":..., "args":...}(非 "name"
steps = [
{
"thought": "看根节点",
"tool_call": {"tool": "view_node", "args": {"node_id": "v_L1_000"}},
"tool_output": "o0",
},
{
"thought": "搜索",
"tool_call": {"tool": "search_similar", "args": {"query": "gadget"}},
"tool_output": "hit",
},
]
rows = steps_json_to_trace_rows("vid1", "q1", json.dumps(steps))
assert [r["step"] for r in rows] == [0, 1]
assert rows[0]["tool_name"] == "view_node"
assert rows[0]["tool_args"] == {"node_id": "v_L1_000"}
assert rows[0]["video_id"] == "vid1" and rows[0]["question_id"] == "q1"
assert rows[1]["tool_output"] == "hit"
def test_empty_or_blank_steps_json_returns_empty():
assert steps_json_to_trace_rows("v", "q", "") == []
assert steps_json_to_trace_rows("v", "q", "[]") == []