Skip to content

"Vibe-Trading: Your Personal Trading Agent"

fix(swarm): wire task_blocked into CLI live panel + carry agent_id

Haozhe Wu46e49626b9e0
diff --git a/agent/cli/_legacy.py b/agent/cli/_legacy.py
index 0757e3f13..47ce9625e 100644
--- a/agent/cli/_legacy.py
+++ b/agent/cli/_legacy.py
@@ -1840,6 +1840,12 @@ class _SwarmDashboard:
agent["elapsed"] = (time.monotonic() - agent["started_at"]) if agent["started_at"] else 0
error = data.get("error", "")[:80]
self.completed_summaries.append((agent["name"], f"[red]FAILED: {error}[/red]"))
+ elif etype == "task_blocked":
+ agent["status"] = "blocked"
+ blocked_by = ", ".join(data.get("blocked_by", []))
+ self.completed_summaries.append(
+ (agent["name"], f"[yellow]BLOCKED by: {blocked_by}[/yellow]")
+ )
elif etype == "task_retry":
attempt = data.get("attempt", "?")
agent["status"] = "retry"
diff --git a/agent/src/swarm/models.py b/agent/src/swarm/models.py
index 73d62aa7a..95ddc1273 100644
--- a/agent/src/swarm/models.py
+++ b/agent/src/swarm/models.py
@@ -128,7 +128,8 @@ class SwarmEvent(BaseModel):
Appended to events.jsonl; supports SSE streaming and post-run audit.
Attributes:
- type: Event type, e.g. "run_started", "task_completed", "task_failed".
+ type: Event type, e.g. "run_started", "task_completed", "task_failed",
+ "task_blocked" (upstream not completed → downstream skipped).
agent_id: Associated agent ID (optional).
task_id: Associated task ID (optional).
data: Arbitrary additional data.
diff --git a/agent/src/swarm/runtime.py b/agent/src/swarm/runtime.py
index 989ca7cb9..dee51e9bb 100644
--- a/agent/src/swarm/runtime.py
+++ b/agent/src/swarm/runtime.py
@@ -526,6 +526,7 @@ class SwarmRuntime:
run.id,
self._make_event(
"task_blocked",
+ agent_id=task.agent_id,
task_id=tid,
data={"blocked_by": blocked_by_ids, "reason": reason},
),
diff --git a/agent/tests/test_swarm_dag_gating.py b/agent/tests/test_swarm_dag_gating.py
index 33c396fbc..2e4d4fb33 100644
--- a/agent/tests/test_swarm_dag_gating.py
+++ b/agent/tests/test_swarm_dag_gating.py
@@ -117,6 +117,12 @@ def test_blocked_downstream_emits_task_blocked_event(tmp_path, risk_fails):
assert "task-risk" in blocked_evt.get("data", {}).get("blocked_by", []), (
f"task_blocked.data.blocked_by must reference upstream task; got {blocked_evt['data']}"
)
+ # CLI live panel (cli/_legacy.py) keys events off agent_id to update the
+ # per-agent row — task_blocked without agent_id silently noops the UI.
+ assert blocked_evt.get("agent_id") == "pm", (
+ f"task_blocked must carry agent_id for CLI live-panel routing; got "
+ f"{blocked_evt.get('agent_id')!r}"
+ )
def test_run_marked_failed_when_downstream_blocked(tmp_path, risk_fails):