feat(runtime): capture step evidence in console
Tests / Test passed: 862

This commit is contained in:
2026-07-15 10:12:09 +08:00
parent 8d5b02e37f
commit ccde30e378
20 changed files with 594 additions and 53 deletions
+31
View File
@@ -1,5 +1,7 @@
from __future__ import annotations
from pathlib import Path
from storage.artifact_store import ArtifactStore
from storage.timeline import Timeline
from tests.fakes import PNG_10X20
@@ -52,3 +54,32 @@ def test_timeline_records_per_step_prompt_not_task_goal(tmp_path) -> None:
assert len(records) == 1
assert records[0]["prompt"] == per_step_prompt
assert "Call exactly one tool" in records[0]["prompt"]
def test_timeline_records_before_and_after_screenshots_with_ocr(tmp_path) -> None:
timeline = Timeline(ArtifactStore(tmp_path / "history"))
before = b"before-image"
after = b"after-image"
timeline.append(
task_id="task-evidence",
scene={"screen": {"width": 1, "height": 1}, "elements": []},
prompt="goal",
tool_call={"action": "tap", "description": "tap search"},
result={"ok": True},
before_screenshot=before,
after_screenshot=after,
ocr_results=[
{
"text": "Search",
"confidence": 0.98,
"bounds": {"x": 1, "y": 2, "width": 3, "height": 4},
}
],
)
record = timeline.read("task-evidence")[0]
assert Path(record["before_screenshot_path"]).read_bytes() == before
assert Path(record["after_screenshot_path"]).read_bytes() == after
assert record["screenshot_path"] == record["after_screenshot_path"]
assert record["ocr_results"][0]["text"] == "Search"