> ## Documentation Index
> Fetch the complete documentation index at: https://developers.telnyx.com/llms.txt
> Use this file to discover all available pages before exploring further.

# ports.tasks

> `readonly` **tasks**: [`AgentHarnessTaskPort`](/docs/agent-sdk/harness-sdk/ports/tasks#agentharnesstaskport)

## On the Agent Runtime

[The runtime adapter](/docs/agent-sdk/harness-sdk/adapters/runtime#on-the-agent-runtime) builds the port from `host`, which carries the protected members of the `Agent` class.

```ts theme={null}
// runtime-adapter.ts
const tasks = Object.freeze({
  delivery: "at-least-once",
  queue: async (method, payload, scheduleOptions) => host.queue(method, payload, scheduleOptions),
  schedule: async (delaySeconds, method, payload, scheduleOptions) => host.schedule(delaySeconds, method, payload, scheduleOptions),
  every: async (intervalSeconds, method, payload, scheduleOptions) => host.every(intervalSeconds, method, payload, scheduleOptions),
  cancel: (id) => host.cancelSchedule(id),
  list: () => host.listSchedules(),
});
```

* `queue()` calls [`queue()`](/docs/agent-sdk/interface/queue), for a task due at once.
* `schedule()` calls [`schedule()`](/docs/agent-sdk/interface/schedule), for a task due after a delay.
* `every()` calls [`every()`](/docs/agent-sdk/interface/every), for a task that recurs at an interval.
* `cancel()` calls [`cancelSchedule()`](/docs/agent-sdk/interface/cancelSchedule), which removes a pending task.
* `list()` calls [`listSchedules()`](/docs/agent-sdk/interface/listSchedules), which returns a [`TaskRecord`](/docs/agent-sdk/interface/listSchedules#taskrecord) for every pending task.
* With a stable `id` in its [`ScheduleOptions`](/docs/agent-sdk/interface/schedule#scheduleoptions), a call to `queue()`, `schedule()` or `every()` replaces the pending task with that id.
* `delivery` declares the scheduler's own guarantee. A task survives crashes and restarts. It can be delivered more than once.
* The harness's task names begin with `__telnyx_agent_harness_` and name no method of the class, so they reach [`onTask()`](/docs/agent-sdk/interface/onTask). Its default does nothing and counts the task as delivered.

## AgentHarnessTaskPort

Existing Agent task scheduler semantics.

Stable ids are pending-task upserts only. This is deliberately not a run
admission ledger: there are no run statuses, terminal records, or persistent
idempotency history in this contract.

**Properties**
**delivery**

> `readonly` **delivery**: `"at-least-once"`

**Methods**
**cancel()**

> **cancel**(`id`): `Promise`\<`boolean`>

**Parameters**

| Parameter | Type |
| - | - |
| `id` | `string` |

**Returns**
`Promise`\<`boolean`>

**every()**

> **every**(`intervalSeconds`, `method`, `payload?`, `options?`): `Promise`\<`string`>

**Parameters**

| Parameter | Type |
| - | - |
| `intervalSeconds` | `number` |
| `method` | `string` |
| `payload?` | `unknown` |
| `options?` | `ScheduleOptions` |

**Returns**
`Promise`\<`string`>

**list()**

> **list**(): `Promise`\<`TaskRecord`\[]>

**Returns**
`Promise`\<`TaskRecord`\[]>

**queue()**

> **queue**(`method`, `payload?`, `options?`): `Promise`\<`string`>

**Parameters**

| Parameter | Type |
| - | - |
| `method` | `string` |
| `payload?` | `unknown` |
| `options?` | `ScheduleOptions` |

**Returns**
`Promise`\<`string`>

**schedule()**

> **schedule**(`delaySeconds`, `method`, `payload?`, `options?`): `Promise`\<`string`>

**Parameters**

| Parameter | Type |
| - | - |
| `delaySeconds` | `number` |
| `method` | `string` |
| `payload?` | `unknown` |
| `options?` | `ScheduleOptions` |

**Returns**
`Promise`\<`string`>
