---
url: >-
  https://adk.nht.io/api/@nhtio/adk/batteries/tools/_shared/functions/runInputPipeline.md
---

# Function: runInputPipeline()

```ts
function runInputPipeline<C>(
  mw: Middleware<MiddlewareFn<C>>,
  ctx: C,
  label: string,
): Promise<string | undefined>;
```

Defined in: [batteries/tools/\_shared/index.ts:211](https://github.com/NHTIO/ADK/blob/v1.20260609.1/src/batteries/tools/_shared/index.ts#L211)

Run an input pipeline over `ctx`. Returns the short-circuit string when a stage short-circuited,
or `undefined` when the pipeline reached its terminal handler. A non-terminal pipeline (a stage
that neither called `next()` nor short-circuited) throws — the caller converts it to an
`Error:` string.

## Type Parameters

| Type Parameter |
| -------------- |
| `C`            |

## Parameters

| Parameter | Type                                                                     | Description                                                                        |
| --------- | ------------------------------------------------------------------------ | ---------------------------------------------------------------------------------- |
| `mw`      | `Middleware`<[`MiddlewareFn`](../type-aliases/MiddlewareFn.md)<`C`>> | The `Middleware` instance holding the stages (a fresh `.runner()` is minted here). |
| `ctx`     | `C`                                                                      | The mutable input context handed to each stage.                                    |
| `label`   | `string`                                                                 | Battery name, used in the non-terminal error message.                              |

## Returns

`Promise`<`string` | `undefined`>

The short-circuit result string, or `undefined` if the pipeline ran to completion.
