---
title: Execution policy
description: Control concurrency, duration, admission, and cancellation.
pagination: false
sidebar:
  icon: sliders-horizontal
---

Set retry, timeout, concurrency, and cancellation policy on the task that owns the work.

> **Before you begin**
>
> Use an existing [task/job with its selected provider installed and
> bound](/docs/modules/jobs/quickstart) before running this example. Core task declarations do not
> install the provider's native SDK.

Execution policy belongs to the task because it describes how the durable operation runs.

```ts title="examples/commerce/src/services/orders/tasks/export-orders.task.ts"
/** Produces demonstration CSV through the ordinary order helper and emits validated progress around the durable export. */
import { defineTask } from "@relkit/app/tasks";
import { z } from "@relkit/app/schema";
import { exportOrderCsv } from "../helpers/fake-business.js";

const exportOrders = defineTask({
  id: "orders.export-orders",
  version: "1",
  execution: "durable",
  input: z.object({ orderIds: z.array(z.string()) }),
  output: z.object({ csv: z.string(), exported: z.number().int().nonnegative() }),
  progress: z.object({
    completed: z.number().int().nonnegative(),
    total: z.number().int().positive(),
  }),
  handler: async ({ orderIds }, context) => {
    await context.progress.emit({ completed: 0, total: orderIds.length });
    const csv = exportOrderCsv(orderIds);
    await context.progress.emit({ completed: orderIds.length, total: orderIds.length });
    return { csv, exported: orderIds.length };
  },
});

export default exportOrders;
```

Use task fields such as `maxDuration`, `maxElapsed`, `resources`, `concurrency`, `logging`, and `retry`.
Jobs keep admission and client exposure together; they do not override task execution policy.

Admission runs before a durable run is accepted. Keep admission checks fast and deterministic. Authorization belongs at the public boundary; the task must still validate every value it trusts from persisted input.

Cancellation is cooperative: the runtime records the requested state and the task should stop between side effects or checkpointable work. Do not delete a run to cancel it. Use the run control API so the provider can retain history and the operation ID can be audited.

The default run-list limit is 25 and the maximum is 100. Provider-specific ceilings are reported by `relkit jobs capabilities`.

{/* Generated by apps/docs/scripts/generate.ts. Do not edit. */}

**Reference and source**

- [`@relkit/jobs` API](/docs/api/jobs)

- [`examples/commerce/src/services/orders/tasks/export-orders.task.ts`](https://github.com/rel-kit/relkit/blob/main/examples/commerce/src/services/orders/tasks/export-orders.task.ts)
