"Vibe-Trading: Your Personal Trading Agent"
Python ai-agentalgorithmic-tradingbacktestingfintechllmmcpmulti-agentpythonquantitative-financetrading
fix(swarm): unblock run_swarm retries and clean Ctrl+C shutdown (#42)
warren618fc708d15c5a7
diff --git a/agent/src/swarm/runtime.py b/agent/src/swarm/runtime.pyindex 5935d026d..faf9500b6 100644--- a/agent/src/swarm/runtime.py+++ b/agent/src/swarm/runtime.py@@ -343,10 +343,14 @@ class SwarmRuntime:def _event_callback(event: SwarmEvent) -> None:self._emit_event(run.id, event)- with ThreadPoolExecutor(max_workers=self._max_workers) as executor:- futures: dict[Future[WorkerResult], str] = {}- layer_budget = 0 # seconds — max per-task (retries × timeout) across layer-+ # Manual executor lifecycle (not `with`) so KeyboardInterrupt and+ # the layer deadline don't block main on `shutdown(wait=True)` —+ # `wait=False + cancel_futures=True` lets pending work drop and+ # the CLI return immediately. Running workers finish naturally.+ executor = ThreadPoolExecutor(max_workers=self._max_workers)+ futures: dict[Future[WorkerResult], str] = {}+ layer_budget = 0 # seconds — max per-task (retries × timeout) across layer+ try:for tid in layer_task_ids:task = task_store.load_task(tid)agent_spec = agent_map.get(task.agent_id)@@ -417,6 +421,12 @@ class SwarmRuntime:status="timeout", summary="",error=f"Worker exceeded layer deadline of {layer_deadline}s",)+ except KeyboardInterrupt:+ cancel_event.set()+ logger.warning("Swarm layer interrupted — cancelling pending workers")+ raise+ finally:+ executor.shutdown(wait=False, cancel_futures=True)return resultsdiff --git a/agent/src/tools/swarm_tool.py b/agent/src/tools/swarm_tool.pyindex 1d42958b2..25e85549b 100644--- a/agent/src/tools/swarm_tool.py+++ b/agent/src/tools/swarm_tool.py@@ -583,6 +583,7 @@ class SwarmTool(BaseTool):"required": ["prompt"],}is_readonly = False+ repeatable = True # loop.py dedups by tool name; each prompt is a distinct run (#42)def execute(self, **kwargs: Any) -> str:"""Start a swarm run: auto-match preset, extract variables, wait for completion.