Skip to content

AbortError

Thrown when ctx.abort(reason) is called in any middleware hook.

This is a hard stop — it unwinds the entire onion stack up to the session level and rejects the AgentRun.result promise. No LLM call is made after abort.

// In a middleware:
turn: async (ctx, next) => {
if (ctx.state.totalCost > 1.00) ctx.abort("Budget exceeded")
await next()
}

new AbortError(reason): AbortError

string

AbortError

AgentExpressError.constructor

readonly optional cause?: Error

Original error that caused this one, if any.

AgentExpressError.cause


code: string

Machine-readable error code (e.g., “ABORT”, “RATE_LIMIT”, “TOOL_DENIED”).

AgentExpressError.code


readonly reason: string

The reason passed to ctx.abort().


readonly retryable: boolean

Whether this error can be retried by retry middleware.

AgentExpressError.retryable