Host Agent now persists step-level execution detail locally (via a real TaskMetadataStore/Timeline wired into TaskRunner) and reports a bounded in-progress snapshot piggybacked on lease renewal. Cloud persists that snapshot per active assignment and exposes it through the existing task list/detail query path; Cloud Console renders it as a live badge. Host Agent's local console gains authenticated, read-only task list and detail/timeline pages (same-origin, server-rendered) with inlined screenshots. Also fixes a pre-existing gap in the shared Timeline: the actual per-step LLM prompt is now recorded instead of the task goal, benefiting both Runtime and Host Agent consoles. When a host uses the cloud planner transport, each decide call's prompt and resulting tool decision are durably logged in a new planner_decision_log table (with bounded retention) and browsable from Cloud Console; direct-transport hosts explicitly surface a "not reported" state. Includes Alembic migrations 0008 (progress columns on scheduled_tasks) and 0009 (planner_decision_log), bounded Host-Agent-local retention, dual-backend repository parity, and Vitest + pytest coverage. Task 6.5 (manual end-to-end device verification) remains. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
55 lines
1.8 KiB
Python
55 lines
1.8 KiB
Python
from __future__ import annotations
|
|
|
|
from storage.artifact_store import ArtifactStore
|
|
from storage.timeline import Timeline
|
|
from tests.fakes import PNG_10X20
|
|
|
|
|
|
def test_timeline_records_survive_reopening_store(tmp_path) -> None:
|
|
store = ArtifactStore(tmp_path / "history")
|
|
timeline = Timeline(store)
|
|
timeline.append(
|
|
task_id="task-1",
|
|
scene={"screen": {"width": 1, "height": 1}, "elements": []},
|
|
prompt="goal",
|
|
tool_call={"action": "tap"},
|
|
result={"ok": True},
|
|
screenshot=PNG_10X20,
|
|
)
|
|
timeline.append(
|
|
task_id="task-1",
|
|
scene={"screen": {"width": 1, "height": 1}, "elements": []},
|
|
prompt="goal",
|
|
tool_call={"action": "input_text"},
|
|
result={"ok": True},
|
|
screenshot=PNG_10X20,
|
|
)
|
|
|
|
reopened = Timeline(ArtifactStore(tmp_path / "history"))
|
|
records = reopened.read("task-1")
|
|
|
|
assert [record["index"] for record in records] == [1, 2]
|
|
assert records[0]["screenshot_path"].endswith("001.png")
|
|
|
|
|
|
def test_timeline_records_per_step_prompt_not_task_goal(tmp_path) -> None:
|
|
"""The prompt field should persist exactly what was passed to append(),
|
|
not a pre-D9 task goal fallback."""
|
|
store = ArtifactStore(tmp_path / "history")
|
|
timeline = Timeline(store)
|
|
|
|
per_step_prompt = "Goal:\nsend a message\n\nCurrent Scene (JSON):\n{...}\n\nCall exactly one tool."
|
|
timeline.append(
|
|
task_id="task-42",
|
|
scene={"screen": {"width": 1, "height": 1}, "elements": []},
|
|
prompt=per_step_prompt,
|
|
tool_call={"action": "tap"},
|
|
result={"ok": True},
|
|
screenshot=PNG_10X20,
|
|
)
|
|
|
|
records = timeline.read("task-42")
|
|
assert len(records) == 1
|
|
assert records[0]["prompt"] == per_step_prompt
|
|
assert "Call exactly one tool" in records[0]["prompt"]
|