From fec0f3bb7ab2ced964e6e8ef8aaf28f4bcd11072 Mon Sep 17 00:00:00 2001 From: cfdaily Date: Mon, 1 Jun 2026 00:15:29 +0800 Subject: [PATCH] auto-sync: 2026-06-01 00:15:29 --- src/daemon/spawner.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/daemon/spawner.py b/src/daemon/spawner.py index c1f43cf..4ebe822 100644 --- a/src/daemon/spawner.py +++ b/src/daemon/spawner.py @@ -430,6 +430,7 @@ curl -X POST http://{self.api_host}:{self.api_port}/api/projects/{project_id}/ta task_db_path: Optional[Path] = None, reuse_session_id: Optional[str] = None, on_checks_passed: Optional[Any] = None, + skip_counter: bool = False, ) -> str: """Spawn Full Agent(异步非阻塞) @@ -484,7 +485,8 @@ curl -X POST http://{self.api_host}:{self.api_port}/api/projects/{project_id}/ta raise AgentBusyError(f"{agent_id}: compacting") # 3. counter acquire(per session key 粒度) - if self.counter: + # v2.8.1 Bug-4 fix: retry 时跳过 counter(counter 从原始 spawn 保持到 retry 完成) + if self.counter and not skip_counter: if not await self.counter.can_acquire(agent_id, _sid_key): raise AgentBusyError(agent_id) await self.counter.acquire(agent_id, _sid_key) @@ -880,11 +882,9 @@ curl -X POST http://{api_host}:{api_port}/api/projects/{project_id}/tasks/{task_ 需要手动 release counter,然后 spawn_full_agent 内部会 acquire。 on_complete(含 counter release)置为 None,避免 double release。 """ - # ── 关键:手动 release counter(进程退出 = agent 空闲)── - if self.counter: - self.counter.release(agent_id, session_id or "main") - # 旧 wrapped_on_complete 含 counter.release,不再使用,防止 double release - on_complete = None + # v2.8.1 Bug-4 fix: 不再手动 release counter + 置 None on_complete + # counter 从原始 spawn 保持到 retry 完成,避免窗口期 ticker acquire 同一 agent + # on_complete 保留原始 wrapped_on_complete,retry 完成后自然 release counter # 续杯前检查任务状态,已终态则跳过 if db_path and task_id: @@ -894,7 +894,7 @@ curl -X POST http://{api_host}:{api_port}/api/projects/{project_id}/tasks/{task_ row = conn.execute( "SELECT status FROM tasks WHERE id=?", (task_id,) ).fetchone() - if row and row["status"] in ("done", "failed", "cancelled", "review", "pending"): + if row and row["status"] in ("done", "failed", "cancelled", "review") # Bug-6 fix: pending 不是终态: logger.info("Retry skip: task %s already %s (agent=%s)", task_id, row["status"], agent_id) # on_complete = wrapped_on_complete,会 release counter @@ -984,6 +984,7 @@ curl -X POST http://{api_host}:{api_port}/api/projects/{project_id}/tasks/{task_ on_complete=on_complete, use_main_session=True, # #02: 续杯走 main session task_db_path=db_path, + skip_counter=True, # Bug-4 fix: counter 已在原始 spawn 中持有 ) except AgentBusyError: # agent 被其他任务占用(不应发生,但防御)