Skip to content

AgentStreamContext

Defined in: src/middleware/stages.ts:129

Context passed to agent-stream-stage middleware. Wraps the entire agent output stream at the outermost interception point.

readonly agent: LocalAgent;

Defined in: src/middleware/stages.ts:131

The agent instance (escape hatch for advanced use cases).


readonly args: InvokeArgs;

Defined in: src/middleware/stages.ts:133

The invocation arguments passed to agent.stream().


readonly optional options?: InvokeOptions;

Defined in: src/middleware/stages.ts:135

Per-invocation options (cancel signal, structured output, etc.).

interrupt<T>(params): MiddlewareInterruptResult<T>;

Defined in: src/middleware/stages.ts:51

Request a human-in-the-loop interrupt.

On first execution (no prior response), throws InterruptError to halt the agent. On resume (after the user provides a response), returns the response wrapped in MiddlewareInterruptResult.

Type ParameterDefault type
TJSONValue
ParameterTypeDescription
paramsInterruptParamsInterrupt parameters (name, optional reason, optional preemptive response)

MiddlewareInterruptResult<T>

The user’s response wrapped in { response: T }

InterruptError when no response has been provided yet

MiddlewareInterruptible.interrupt