auto-sync: 2026-05-20 08:33:13
This commit is contained in:
+6
-27
@@ -796,27 +796,6 @@ class TestE9RealAgentDispatch:
|
||||
assert resp.status_code == 200, f"Create task failed: {resp.text}"
|
||||
return tid
|
||||
|
||||
def _poll_task(self, pid, tid, timeout, terminal_states=None):
|
||||
"""轮询任务状态直到终态或超时"""
|
||||
terminal = terminal_states or ("done", "failed", "cancelled")
|
||||
deadline = time.time() + timeout
|
||||
last_status = None
|
||||
while time.time() < deadline:
|
||||
resp = http_requests.get(
|
||||
f"{API_BASE}/api/projects/{pid}/tasks/{tid}", timeout=10
|
||||
)
|
||||
if resp.status_code == 200:
|
||||
data = resp.json()
|
||||
last_status = data.get("status")
|
||||
if last_status in terminal:
|
||||
return data
|
||||
time.sleep(POLL_INTERVAL)
|
||||
# 超时,返回最后状态
|
||||
resp = http_requests.get(
|
||||
f"{API_BASE}/api/projects/{pid}/tasks/{tid}", timeout=10
|
||||
)
|
||||
return resp.json() if resp.status_code == 200 else {"status": "unknown"}
|
||||
|
||||
def test_e91_simple_task_agent_execute(self):
|
||||
"""E9-1: 简单任务 → 生产Ticker调度 → 真实Agent执行 → 状态自动流转到终态"""
|
||||
pid = self._create_project("E9-1")
|
||||
@@ -835,7 +814,7 @@ class TestE9RealAgentDispatch:
|
||||
)
|
||||
|
||||
print(f"\n🚀 E9-1: 等待调度 + Agent执行 (pid={pid}, tid={tid})")
|
||||
result = self._poll_task(
|
||||
result = _poll_task(
|
||||
pid, tid, timeout=MAX_WAIT_AGENT,
|
||||
terminal_states=("done", "failed", "cancelled", "blocked"),
|
||||
)
|
||||
@@ -875,7 +854,7 @@ class TestE9RealAgentDispatch:
|
||||
)
|
||||
|
||||
print(f"\n🚀 E9-2: 等待review调度 + Agent执行 (pid={pid}, tid={tid})")
|
||||
result = self._poll_task(
|
||||
result = _poll_task(
|
||||
pid, tid, timeout=MAX_WAIT_AGENT,
|
||||
terminal_states=("done", "failed", "cancelled", "blocked"),
|
||||
)
|
||||
@@ -905,7 +884,7 @@ class TestE9RealAgentDispatch:
|
||||
|
||||
print(f"\n🚀 E9-3: 等待Guardrails拦截 (pid={pid}, tid={tid})")
|
||||
# Guardrails 在 Ticker dispatch 时检查,需要等一个 tick
|
||||
result = self._poll_task(
|
||||
result = _poll_task(
|
||||
pid, tid, timeout=MAX_WAIT_DISPATCH,
|
||||
terminal_states=("done", "failed", "cancelled", "blocked", "claimed", "working"),
|
||||
)
|
||||
@@ -1005,7 +984,7 @@ class TestE10FullChain:
|
||||
|
||||
# 6. 等待 Ticker 依赖推进(1-2个tick)
|
||||
print(f"\n🚀 E10a: 等待依赖推进 (pid={pid})")
|
||||
dep_result = self._poll_task(
|
||||
dep_result = _poll_task(
|
||||
pid, dep_id, timeout=MAX_WAIT_DISPATCH,
|
||||
terminal_states=("pending", "claimed", "working", "done"),
|
||||
)
|
||||
@@ -1089,7 +1068,7 @@ class TestE10FullChain:
|
||||
|
||||
# 3. 等待Agent执行完成
|
||||
print(f"\n🚀 E10b: 等待Agent执行子任务 (pid={pid}, tid={child_id})")
|
||||
result = self._poll_task(
|
||||
result = _poll_task(
|
||||
pid, child_id, timeout=MAX_WAIT_AGENT,
|
||||
terminal_states=("done", "failed", "cancelled", "blocked"),
|
||||
)
|
||||
@@ -1101,7 +1080,7 @@ class TestE10FullChain:
|
||||
)
|
||||
|
||||
# 4. 轮询父任务状态变化(等待Ticker聚合)
|
||||
parent_result = self._poll_task(
|
||||
parent_result = _poll_task(
|
||||
pid, parent_id, timeout=MAX_WAIT_DISPATCH,
|
||||
terminal_states=("working", "review", "done", "failed"),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user