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
+17 -2
View File
@@ -1,6 +1,6 @@
from __future__ import annotations
from dataclasses import dataclass
from dataclasses import dataclass, field
from datetime import datetime
from typing import Any
@@ -17,6 +17,9 @@ class TimelineRecord:
tool_call: dict[str, Any]
result: dict[str, Any]
timestamp: str
ocr_results: list[dict[str, Any]] = field(default_factory=list)
before_screenshot_path: str | None = None
after_screenshot_path: str | None = None
screenshot_path: str | None = None
@@ -33,20 +36,29 @@ class Timeline:
tool_call: dict[str, Any],
result: dict[str, Any],
screenshot: bytes | None = None,
before_screenshot: bytes | None = None,
after_screenshot: bytes | None = None,
ocr_results: list[dict[str, Any]] | None = None,
) -> TimelineRecord:
index = len(self.read(task_id)) + 1
resolved_after_screenshot = (
after_screenshot if after_screenshot is not None else screenshot
)
resolved_ocr_results = list(ocr_results or [])
record = {
"index": index,
"scene": scene,
"prompt": prompt,
"tool_call": tool_call,
"result": result,
"ocr_results": resolved_ocr_results,
"timestamp": datetime.now().astimezone().isoformat(),
}
paths = self.artifact_store.write_step(
task_id=task_id,
index=index,
screenshot=screenshot,
before_screenshot=before_screenshot,
after_screenshot=resolved_after_screenshot,
record=record,
)
return TimelineRecord(
@@ -56,6 +68,9 @@ class Timeline:
tool_call=tool_call,
result=result,
timestamp=record["timestamp"],
ocr_results=resolved_ocr_results,
before_screenshot_path=paths["before_screenshot_path"],
after_screenshot_path=paths["after_screenshot_path"],
screenshot_path=paths["screenshot_path"],
)