From 8e65e2e7b0d4629049c6699217ebca4d29198153 Mon Sep 17 00:00:00 2001 From: sinohqb Date: Mon, 17 Aug 2026 02:57:08 +0800 Subject: [PATCH] fix(intelligent-eval): worker trigger message must demand immediate execution MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit openclaw agent has no cron state; a bare 'agenteval-intelligent-worker' message made the worker skill decide then 'wait for the next tick', deadlocking (task assigned, session never created). The trigger message now demands '立即完成当前任务,不要等待下一节拍' and, when all sessions are done, delegates to agenteval-intelligent-analyst. Verified end-to-end on t480: 1h-window eval went executing -> session (2 real turns) -> close -> report -> completed, fully agent-driven, no external IM channel. --- backend/agenteval/web/app.py | 10 ++++++- .../test_intelligent_eval_scan_scheduler.py | 30 +++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/backend/agenteval/web/app.py b/backend/agenteval/web/app.py index b8d9a78..4708625 100644 --- a/backend/agenteval/web/app.py +++ b/backend/agenteval/web/app.py @@ -60,12 +60,20 @@ async def _trigger_intelligent_worker() -> bool: import subprocess _logger = logging.getLogger("agenteval") + # 触发指令必须带"立即执行"语义:`openclaw agent` 无 cron state,若只发 + # skill 名,agent 会按 worker skill 的"跨节拍"设计决策后等下一拍而死锁。 + # 明确要求"立即完成当前任务"后,agent 会在本次触发内完成会话/分析。 + worker_msg = ( + "执行 agenteval-intelligent-worker skill,立即完成当前任务,不要等待下一节拍:" + "若需执行会话则立即创建会话并开始对话;若所有会话已完成则调用 " + "agenteval-intelligent-analyst skill 完成分析并生成报告。" + ) try: proc = await asyncio.to_thread( subprocess.run, [ "docker", "exec", "openclaw-eval", "openclaw", "agent", - "--agent", "main", "-m", "agenteval-intelligent-worker", "--json", + "--agent", "main", "-m", worker_msg, "--json", ], capture_output=True, text=True, diff --git a/tests/integration/test_intelligent_eval_scan_scheduler.py b/tests/integration/test_intelligent_eval_scan_scheduler.py index 5117ced..b30d224 100644 --- a/tests/integration/test_intelligent_eval_scan_scheduler.py +++ b/tests/integration/test_intelligent_eval_scan_scheduler.py @@ -78,3 +78,33 @@ def test_trigger_worker_calls_docker_exec(monkeypatch): assert "docker" in joined and "openclaw" in joined assert "agenteval-intelligent-worker" in joined assert "--agent" in joined and "main" in joined + + +def test_trigger_worker_msg_has_execute_semantics(monkeypatch): + """The trigger message must instruct immediate execution (no cron state). + + `openclaw agent` has no cron state; a bare skill name makes the worker + skill "decide then wait for the next tick", deadlocking. The message must + say "立即完成当前任务 / 不要等待下一节拍". + """ + import asyncio + import subprocess + from unittest.mock import MagicMock + + import agenteval.web.app as app_mod + + calls: list = [] + monkeypatch.setattr(app_mod, "_has_pending_task", lambda: True) + + def fake_run(cmd, **kwargs): + calls.append(cmd) + return MagicMock(returncode=0, stderr="") + + monkeypatch.setattr(subprocess, "run", fake_run) + + asyncio.run(app_mod._trigger_intelligent_worker()) + joined = " ".join(calls[0]) + assert "不要等待下一节拍" in joined + assert "立即完成当前任务" in joined + assert "agenteval-intelligent-worker" in joined + assert "agenteval-intelligent-analyst" in joined