def METHOD_NAME(self) -> str:
    with redis_lock(ORPHANED_WIN_TASK_LOCK, self.app.oid) as acquired:
        if not acquired:
            return f"{self.app.oid} still running"
        from core.tasks import _get_agent_qs
        AgentTup = namedtuple("AgentTup", ["agent_id", "task_names"])
        items: "list[AgentTup]" = []
        exclude_tasks = ("TacticalRMM_SchedReboot",)
        for agent in _get_agent_qs():
            if agent.status == AGENT_STATUS_ONLINE:
                names = [task.win_task_name for task in agent.get_tasks_with_policies()]
                items.append(AgentTup._make([agent.agent_id, names]))
        async def _handle_task(nc: "NATSClient", sub, data, names) -> str:
            try:
                msg = await nc.request(
                    subject=sub, payload=msgpack.dumps(data), timeout=5
                )
            except TimeoutError:
                return "timeout"
            try:
                r = msgpack.loads(msg.data)
            except Exception as e:
                return str(e)
            if not isinstance(r, list):
                return "notlist"
            for name in r:
                if name.startswith(exclude_tasks):
                    # skip system tasks or any pending reboots
                    continue
                if name.startswith("TacticalRMM_") and name not in names:
                    nats_data = {
                        "func": "delschedtask",
                        "schedtaskpayload": {"name": name},
                    }
                    print(f"Deleting orphaned task: {name} on agent {sub}")
                    await nc.publish(subject=sub, payload=msgpack.dumps(nats_data))
            return "ok"
        async def _run() -> None:
            opts = setup_nats_options()
            try:
                nc = await nats.connect(**opts)
            except Exception as e:
                return str(e)
            payload = {"func": "listschedtasks"}
            tasks = [
                _handle_task(
                    nc=nc, sub=item.agent_id, data=payload, names=item.task_names
                )
                for item in items
            ]
            await asyncio.gather(*tasks)
            await nc.flush()
            await nc.close()
        asyncio.run(_run())
        return "completed"