# abortController Option

> The option that lets your code stop a whole agent run.

**Field:** Artificial Intelligence  
**Category:** Claude Agent SDK  
**Also known as:** abortController, Agent SDK abortController, Agent SDK cancel, Claude Agent SDK abortController

## Think of it like

It is like the off switch on a toy, not the pause button.

## Definition

abortController is the TypeScript Agent SDK option that lets you cancel a query() call. You make a standard AbortController, pass it in, and call abort() on it when you want the run to end. The SDK then stops the work and ends that call. If you leave it out, the SDK makes one of its own. Use interrupt() to stop one turn and go on, and abortController to end the whole call.

## Example

A web request that started an agent times out after one minute. The server calls abort(), and the agent run ends with it.

## Example code

```typescript
const ac = new AbortController();
query({ prompt, options: { abortController: ac } });
ac.abort();
```

Cancel the run from your own code.

## Why it matters

A run nobody waits for still costs tokens. Cancelling it stops the spend.

## Common mistake

Using it to stop one turn. That ends the whole call, so use interrupt() instead.

## Three principles

- **Ends the call.** Not just one turn.
- **Standard AbortController.** From JavaScript.
- **TypeScript only.** As an option.

## Related terms

- [interrupt() Method](https://learn.benibix.com/term/ai/interrupt-method)
- [query() Function](https://learn.benibix.com/term/ai/query-function)
- [maxTurns Option](https://learn.benibix.com/term/ai/max-turns-option)
- [maxBudgetUsd Option](https://learn.benibix.com/term/ai/max-budget-usd-option)
- [ClaudeAgentOptions](https://learn.benibix.com/term/ai/claude-agent-options)

## Told apart from

- [interrupt() vs abortController](https://learn.benibix.com/compare/interrupt-vs-abortcontroller): People think interrupt() and abortController do the same thing, because both stop an agent that is still at work. They do not. interrupt() stops only the turn the agent is on, and the session stays open, so you can send a new message right after. It needs streaming input mode. abortController ends the whole query() call, and nothing more comes back from it. Use the first to steer, and the second to quit.

![Two rows of turns. With interrupt(), turn 1 is done, turn 2 is stopped, and turn 3 is a new message, because the session stays open. With abortController, turn 1 is done, turn 2 is stopped, and nothing more comes, because the call is over.](https://learn.benibix.com/diagrams/ai9-sdk-stop.svg)

---

Source: https://learn.benibix.com/term/ai/abort-controller-option
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-20
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
