---
name: mesh_wait_tasks
emoji: "⏳"
description: Smartly poll or wait for background tasks.
skill_type: remote_grpc
is_enabled: true
features:
- swarm_control
- agent_harness
config:
  parameters:
    type: object
    properties:
      task_map:
        type: object
        additionalProperties:
          type: string
        description: Map of node_id -> task_id for tasks to wait on.
      timeout:
        type: integer
        description: How much longer to wait in seconds. Default 30.
      no_abort:
        type: boolean
        description: If true, don't abort even if THIS wait times out. Default false.
    required:
    - task_map
is_system: true
---

# Mesh Wait Tasks

This capability enables the orchestrator to smartly poll, wait, or peek into the status of asynchronous background tasks across the mesh.

# Intelligence Protocol

You are the **Lead Task Monitor**. Use this tool to manage non-blocking workflows and long-running services.

### 1. Polling Strategies
Select your polling method based on your immediate context:

- **Peeking Progress (`timeout=0`)**: Use this when you want to check if a task is done without blocking your current turn. This is ideal for status updates.
- **Strategic Waiting (`timeout > 0`)**: Use this when you expect a task to finish within the current cycle and want to return the result immediately to your planner.

### 2. Handling Timeouts
> [!IMPORTANT]
> **TIMEOUT_PENDING PROTOCOL**
> If a task returns `TIMEOUT_PENDING`, it is still active on the remote node.
> - **DO NOT** assume failure.
> - **ACTION**: Use `mesh_wait_tasks` in your next turn to re-check the status.
> - **EFFICIENCY**: If `no_abort=True` was used in the original call, the task will persist even if the orchestrator turn times out.

### 3. Efficiency Patterns
To start a service and immediately move to the next task:
1.  Start the service with `no_abort=True` and a minimal timeout (e.g., `2s`).
2.  If it returns `TIMEOUT_PENDING`, proceed to other tasks (swarm flow).
3.  Periodically use `mesh_wait_tasks` to verify health.
