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.
Example
Section titled “Example”// In a middleware:turn: async (ctx, next) => { if (ctx.state.totalCost > 1.00) ctx.abort("Budget exceeded") await next()}Extends
Section titled “Extends”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new AbortError(
reason):AbortError
Parameters
Section titled “Parameters”reason
Section titled “reason”string
Returns
Section titled “Returns”AbortError
Overrides
Section titled “Overrides”Properties
Section titled “Properties”cause?
Section titled “cause?”
readonlyoptionalcause?:Error
Original error that caused this one, if any.
Inherited from
Section titled “Inherited from”code:
string
Machine-readable error code (e.g., “ABORT”, “RATE_LIMIT”, “TOOL_DENIED”).
Inherited from
Section titled “Inherited from”reason
Section titled “reason”
readonlyreason:string
The reason passed to ctx.abort().
retryable
Section titled “retryable”
readonlyretryable:boolean
Whether this error can be retried by retry middleware.