Quick Start
1
Nothing to configure
Foreground subagents and context compaction open the window automatically. Use Messages that land while a subagent or compaction is running are queued with ”⏳ Finishing current work, your message is queued”.
busy_mode="interrupt" on your bot as before:2
Protect your own code (advanced)
protect_turn(None) is a safe no-op, so the same call works whether or not the agent has an interrupt controller.How It Works
Once a message is queued, further messages merge into it (MERGED) until it runs, so a later message never drops the queued one. After the queue drains and no window is open, the next mid-run message interrupts as before (INTERRUPTED).
When the window is open
Background subagents (
background=True) do not block the parent turn and are not protected.
API
/stop still works inside the window
protect() only affects implicit interrupts — new user messages under busy_mode="interrupt". An explicit /stop, or any call to controller.request(...), still fires immediately:
Best Practices
Prefer protect_turn(controller) over controller.protect()
Prefer protect_turn(controller) over controller.protect()
protect_turn is a safe no-op for None and for custom controllers that do not implement protect(), so code that may run with or without a controller stays simple.Keep windows short
Keep windows short
The window delays interrupts. Open it around the specific operation (a subagent run, a compaction) rather than wrapping an entire turn.
Don't use it to defer /stop
Don't use it to defer /stop
request() is not blocked. A stop sent inside the window still fires immediately.Related
Bot Run Control
busy_mode="interrupt" is the main consumer of the windowSubagent Tool
Foreground subagents open the window automatically
Context Compaction
Compaction opens the window automatically
Cooperative Tool Cancellation
How
interrupt_controller and /stop work end-to-end
