---
url: >-
  https://adk.nht.io/api/@nhtio/adk/dispatch_runner/type-aliases/DispatchPipelineMiddlewareFn.md
description: >-
  Middleware function signature for the input and output pipelines in {@link
  @nhtio/adk!DispatchRunner}.
---

# Type Alias: DispatchPipelineMiddlewareFn

```ts
type DispatchPipelineMiddlewareFn = (
  ctx: DispatchContext,
  next: NextFn,
) => void | Promise<void>;
```

Defined in: [lib/types/dispatch\_runner.ts:29](https://github.com/NHTIO/ADK/blob/v1.20260605.0/src/lib/types/dispatch_runner.ts#L29)

Middleware function signature for the input and output pipelines in [@nhtio/adk!DispatchRunner](../classes/DispatchRunner.md).

## Parameters

| Parameter | Type                                                           |
| --------- | -------------------------------------------------------------- |
| `ctx`     | [`DispatchContext`](../../types/interfaces/DispatchContext.md) |
| `next`    | `NextFn`                                                       |

## Returns

`void` | `Promise`<`void`>

## Remarks

Receives the active [@nhtio/adk!DispatchContext](../../types/interfaces/DispatchContext.md) and a `next` callback to advance the pipeline.
Middleware can inspect `ctx.isSignalled` to bail early when an earlier middleware or the
executor has called `ctx.ack()` / `ctx.nack()`, and `ctx.aborted` for external cancellation.
Use `ctx.iteration` and `ctx.toolCallCount(checksum)` to implement iteration bounds and
checksum-repeat bounds in your own middleware — the runner itself does not impose either.
