Skip to content
BENIBIX Learn

interrupt() Method

AI🧩 Claude Agent SDKAgent SDK Basics

Also known as Agent SDK interrupt, query.interrupt(), Claude Agent SDK interrupt()

The method that stops what the agent is doing, but keeps the chat.

Think of it like

It is like saying stop to a helper. Then you give a new job.

Example

A user clicks Stop while the agent heads the wrong way. The app calls interrupt(), then sends the user's new message.

Why it matters

Users change their minds. This lets them steer without losing the session.

Definition

interrupt() is the Agent SDK method that stops what the agent is doing right now. It only works in streaming input mode, on the query object in TypeScript or on ClaudeSDKClient in Python. The session stays open, so you can send a new message straight after. In Python, read the messages still waiting before you read the reply to the new one. It is the same as pressing Esc in Claude Code.

Example code

typescript
await q.interrupt();
Stop the current turn. The session stays open.
interrupt() stops one turn, and the session stays open for the next.

Common mistake

Calling it in single message mode. It needs streaming input mode.

Key takeaways

  1. 1
    Stops this turn. Not the session.
  2. 2
    Streaming input only. Not one-shot.
  3. 3
    Then send more. Same session.

Compare