Skip to main content

Module interrupt

Module interrupt 

Source
Expand description

A re-armable, per-turn interrupt handle for an AgentRunner.

A TUI (or any caller) can ask the agent to abandon the current turn — aborting an in-flight LLM generation — and return to awaiting the next input, WITHOUT tearing down the session (conversation history is preserved). Because a CancellationToken is one-shot, this handle swaps in a fresh token after each interrupt so the next turn starts armed again.

Semantics (interactive path): on interrupt the runner abandons whatever the turn is doing and ends it cleanly, then waits for the next message via on_input. An interrupt during an LLM generation aborts the stream; an interrupt during a tool batch abandons it — synthesizing a result for every in-flight tool_use (so no call is left unanswered) and killing any subprocess via kill_on_drop — then the next LLM-call race ends the turn.

Structs§

InterruptHandle
A cloneable handle to interrupt the in-flight turn of an agent run.