Hi everyone,
When building human-in-the-loop flows we need to check for the "__interrupt__" key as a magic string in streaming output.
LangGraph already provides START and END as public constants so users don’t have to hard-code
"__start__" and "__end__". But there’s no equivalent for the interrupt key, even though
checking for it is a required part of every human-in-the-loop streaming implementation.
Why not adding a public INTERRUPT constant to langgraph.constants:
from langgraph.constants import INTERRUPT
async for metadata, mode, chunk in graph.astream(
initial_input,
stream_mode=["messages", "updates"],
subgraphs=True,
config=config,
):
if mode == "updates":
if INTERRUPT in chunk:
interrupt_info = chunk[INTERRUPT][0].value
...
The implementation would be literally a two-line addition to langgraph/constants.py, following the
exact same sys.intern() pattern.
I think this makes sense because:
-
The constant already exists internally as
INTERRUPT = sys.intern("__interrupt__")
inlanggraph._internal._constantsand is used across the pregel engine. This would
just promote it to the public module. -
Users already reference it by name. The interrupt docs show
if "__interrupt__" in chunkas the standard pattern. LangGraph’s own tests do the
same (test_pregel.py,test_pregel_async.py). -
Complements the existing
Interrupttype. Users importInterruptandinterrupt
fromlanggraph.typesfor the values — a companionINTERRUPTconstant for the dict
key completes the public surface.
Context on PR #5529
I’m aware that PR #5529 moved all
constants (including INTERRUPT) to _internal/_constants.py in a bulk refactor before
v1. I believe making INTERRUPT public could be very useful now.
Would love to hear if others have run into this, or if the team has thoughts on whether
this should be public or not. Happy to open a PR if needed.
Thanks!