usestrix/strix · info · RuntimeError
Agent '{agent_id}' is no longer active
Error message
Agent '{agent_id}' is no longer active What it means
Raised by _stop_agent when coordinator.cancel_descendants_graceful(agent_id) completes but returns false. The graceful-cancel API returns a boolean acceptance: false means the coordinator no longer knows the agent as an active cancellable node (it finished, was already cancelled, or was reaped between the UI status check and the coordinator call). Distinct from error 45: this is the coordinator's own verdict after the live_view snapshot said the agent was stoppable.
Source
Thrown at strix/interface/tui/backend/controller.py:403
async def _stop_agent(self, payload: dict[str, Any]) -> dict[str, Any]:
agent_id = self._required_string(payload, "agent_id")
agent = self.live_view.agents.get(agent_id)
if agent is None:
raise ValueError(f"Unknown agent: {agent_id}")
status = str(agent.get("status", ""))
if status not in _STOPPABLE_AGENT_STATUSES:
raise RuntimeError(f"Agent '{agent_id}' cannot be stopped while {status or 'unknown'}")
if self.coordinator is None or self.scan_loop is None or self.scan_loop.is_closed():
raise RuntimeError("Scan loop is not ready")
if self.scan_loop is asyncio.get_running_loop():
accepted = await self.coordinator.cancel_descendants_graceful(agent_id)
else:
future = asyncio.run_coroutine_threadsafe(
self.coordinator.cancel_descendants_graceful(agent_id), self.scan_loop
)
accepted = await asyncio.wrap_future(future)
if not accepted:
raise RuntimeError(f"Agent '{agent_id}' is no longer active")
return {"stopped": True}
async def _open_viewer(self, _payload: dict[str, Any]) -> dict[str, Any]:
if self.viewer_url:
with contextlib.suppress(Exception):
webbrowser.open(self.viewer_url)
return {"status": "running", "url": self.viewer_url}
if self.report_state is None:
self.viewer_status = "failed"
return {"status": self.viewer_status, "error": "Scan output is not ready"}
try:
from strix.interface.tui.backend.messages import (
send_user_message_to_agent,
)
from strix.interface.viewer.server import (
authorized_url,
bundle_is_built,
serve,View on GitHub (pinned to 8551339130)
Solutions
- Treat it as success-with-no-op: the agent is no longer active, which is the desired end state
- Refresh live_view.agents to confirm the agent's final status instead of retrying the stop
- Suppress or downgrade this specific message in UI handling to avoid alarming users
- Avoid double-stop: disable the stop control immediately after the first request
Example fix
# before
await controller._stop_agent({"agent_id": aid})
# after
try:
await controller._stop_agent({"agent_id": aid})
except RuntimeError as e:
if "no longer active" in str(e):
pass # already finished; nothing to stop
else:
raise Defensive patterns
Strategy: fallback
Validate before calling
status = controller.live_view.agents.get(aid, {}).get("status", "")
if status not in ("running", "waiting", "budget_paused"):
return # goal state already reached Type guard
def already_gone(e: RuntimeError) -> bool:
return "no longer active" in str(e) Try / catch
try:
await controller._stop_agent({"agent_id": aid})
except RuntimeError as e:
if "no longer active" not in str(e):
raise
# agent finished concurrently — desired end state achieved, no-op Prevention
- Treat 'no longer active' as success (idempotent stop semantics)
- Debounce/duplicate-guard the stop button to avoid concurrent stop requests
- Refresh live_view after the race instead of retrying the stop
When it happens
Trigger: Stop request racing agent completion: live_view still showed 'running' when the handler started, but by the time the coordinator processed the cancel the agent had exited. Also after a coordinator restart invalidated agent bookkeeping.
Common situations: User clicks stop as an agent finishes its task; concurrent stop requests (first succeeds, second gets false); long scheduling delay on the scan loop letting the agent complete first.
Related errors
- Scan is already starting or running
- Message could not be delivered
- Unknown agent: {agent_id}
- Agent '{agent_id}' cannot be stopped while {status or 'unkno
- The interactive interface could not start: {exc}
AI-assisted analysis of usestrix/strix@8551339130 (2026-08-15).
Data as JSON: /api/errors/9c3dbfa554e55729.
Report an issue: GitHub.