How can I implement the ability to interrupt and resume execution at any time

I’m developing an agent using LangGraph. My main graph nests two subgraphs. I’ve noticed that LangGraph doesn’t natively support an interruption mechanism—by “interruption,” I mean the ability for a user to manually terminate execution at any node and immediately send a new message to continue the conversation. To address this, I’ve wrapped the execution in a Python async manager, using something similar to asyncio.CancelledError to cancel the ongoing run. However, when I restart the conversation, the checkpointed messages are always missing some content, making it difficult to properly restore and continue the dialogue from where it left off.

I’d like the state of all nodes executed prior to termination to be preserved when the interruption occurs. Could you please explain why this is happening, or suggest a more elegant way to handle such interruptions?

Thank you very much for your time—I’d greatly appreciate a prompt reply.

Hi @CxyZyr

that’s an interesting potential feature.
However, I wouldn’t cancel the run from the outside. Hard-cancelling mid-node will always risk losing in-flight work because LangGraph only checkpoints at step boundaries.

LangGraph persists state at well-defined super-step boundaries (after a node finishes and its writes are applied). If you cancel a run with something like asyncio.CancelledError while a node is still executing, any in-flight writes haven’t been committed to the checkpoint yet. On resume, LangGraph picks up from the last completed checkpoint and will re-run that node, so partial/streamed content from the interrupted node is not present in the checkpoint.

And I don’t know about any official API for hard-stopping a running graph.