fix webui tool trace dedupe

This commit is contained in:
Xubin Ren
2026-05-19 13:12:19 +08:00
parent c4794b82a9
commit 0a5606b409
5 changed files with 165 additions and 25 deletions
+47
View File
@@ -98,6 +98,53 @@ def test_replay_file_edit_event_creates_file_activity(tmp_path, monkeypatch) ->
assert msgs[2]["activitySegmentId"] != msgs[1]["activitySegmentId"]
def test_replay_tool_events_dedupes_finish_after_start() -> None:
msgs = replay_transcript_to_ui_messages([
{
"event": "message",
"chat_id": "t-tool",
"text": 'exec({"cmd":"ls"})',
"kind": "tool_hint",
"tool_events": [
{
"phase": "start",
"call_id": "call-exec",
"name": "exec",
"arguments": {"cmd": "ls"},
},
],
},
{
"event": "message",
"chat_id": "t-tool",
"text": "",
"kind": "progress",
"tool_events": [
{
"phase": "end",
"call_id": "call-exec",
"name": "exec",
"arguments": {"cmd": "ls"},
"result": "ok",
},
{
"phase": "end",
"call_id": "call-read",
"name": "read_file",
"arguments": {"path": "notes.md"},
"result": "done",
},
],
},
])
assert len(msgs) == 1
assert msgs[0]["traces"] == [
'exec({"cmd": "ls"})',
'read_file({"path": "notes.md"})',
]
def test_build_response_schema(monkeypatch, tmp_path) -> None:
from nanobot.utils.webui_transcript import build_webui_thread_response