1. Docs
  2. Reference
  3. REST API Docs
  4. AI Agents

AI Agents

    Cancel Task

    Preview. This endpoint is in preview and may change without notice.
    POST /api/preview/agents/{orgName}/tasks/{taskID}/cancel

    Cancels an agent task. When force is true, immediately terminates the runtime session and resets the task to idle. This is the escalation path when a graceful cancel (via the user_cancel event in RespondToTask) is insufficient or the task is stuck. Unlike graceful cancel, force-cancel does not attempt to notify the agent runtime — it kills the session directly and resets the task state. Currently only force cancellation is supported; the force field must be set to true. Returns 409 if the session was stopped but the task status could not be reset to idle.

    Request Parameters

    • orgName string path required
      The organization name
    • taskID string path required
      The agent task identifier

    Request Body

    • force boolean required
      If true, immediately terminate the runtime session and reset the task to idle without attempting a graceful cancel. Required to be true in the current implementation.

    Responses

    204 Task cancelled successfully
    Errors: 400 force must be true (graceful cancel not yet supported via this endpoint) 404 task 409 session stopped but task status could not be reset to idle