feat: improve batch task controls and release 1.2.0
This commit is contained in:
1 parent
0e13bb5c29
commit
84e183d28d
38 files changed
+632
-147
No files matched your search
@@ -116,6 +116,35 @@ async def test_interruptible_call_returns_normal_result_without_pause(tmp_path,
|
||||
assert await control.run_interruptibly(model_call()) == (False, "current result")
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_new_guidance_cancels_stale_model_without_releasing_device(tmp_path, monkeypatch):
|
||||
monkeypatch.setattr(task_control, "TRACES_PATH", tmp_path)
|
||||
released = []
|
||||
|
||||
class Lock:
|
||||
def release(self):
|
||||
released.append(True)
|
||||
|
||||
control = task_control.TaskControl("task-123", Lock())
|
||||
started = asyncio.Event()
|
||||
cancelled = asyncio.Event()
|
||||
|
||||
async def stale_model():
|
||||
started.set()
|
||||
try:
|
||||
await asyncio.Event().wait()
|
||||
finally:
|
||||
cancelled.set()
|
||||
|
||||
call = asyncio.create_task(control.run_interruptibly(stale_model()))
|
||||
await asyncio.wait_for(started.wait(), 1)
|
||||
task_control.add_instruction("task-123", "改为检查当前页面", source="mcp")
|
||||
assert await asyncio.wait_for(call, 1) == (True, None)
|
||||
assert cancelled.is_set()
|
||||
assert released == []
|
||||
assert task_control.consume_instructions(control.directory)["instruction"] == "改为检查当前页面"
|
||||
|
||||
|
||||
def test_guidance_history_distinguishes_submission_from_runner_consumption(tmp_path, monkeypatch):
|
||||
monkeypatch.setattr(task_control, "TRACES_PATH", tmp_path)
|
||||
first = task_control.add_instruction("task-123", "从快捷设置进入", source="web")
|
||||
|
||||
Reference in new issue
Block a user