feat(host-agent): renew active assignment leases
This commit is contained in:
@@ -76,3 +76,39 @@ def test_task_runner_executes_loop_and_writes_timeline(tmp_path) -> None:
|
||||
assert len(timeline.read(task.id)) == 2
|
||||
assert metadata.get_task(task.id)["status"] == "completed"
|
||||
|
||||
|
||||
def test_task_runner_stops_before_the_next_planned_action() -> None:
|
||||
scene = Scene(width=10, height=20, elements=[])
|
||||
stop_requested = False
|
||||
actions: list[str] = []
|
||||
|
||||
def record_action(**kwargs):
|
||||
nonlocal stop_requested
|
||||
actions.append("tap")
|
||||
stop_requested = True
|
||||
return {"ok": True}
|
||||
|
||||
runner = TaskRunner(
|
||||
planner=ScriptedPlanner(
|
||||
[
|
||||
PlannedStep(action="tap", description="first", args={}),
|
||||
PlannedStep(action="tap", description="second", args={}),
|
||||
]
|
||||
),
|
||||
executor=Executor(
|
||||
tools={"tap": record_action},
|
||||
config=ExecutorConfig(max_retries=1, backoff_seconds=0),
|
||||
),
|
||||
config=TaskRunnerConfig(max_steps=5),
|
||||
observer=lambda device_id: scene,
|
||||
screenshot_provider=lambda device_id: PNG_10X20,
|
||||
)
|
||||
|
||||
result = runner.run(
|
||||
Task(goal="perform two actions", device_id="phone"),
|
||||
should_stop=lambda: stop_requested,
|
||||
)
|
||||
|
||||
assert result.status == "failed"
|
||||
assert result.failure_reason == "execution interrupted"
|
||||
assert actions == ["tap"]
|
||||
|
||||
Reference in New Issue
Block a user