Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LangGraph Node Interrupt show the node with Status = "ERROR" #1127

Open
JamesBowerXanda opened this issue Oct 25, 2024 · 0 comments
Open

LangGraph Node Interrupt show the node with Status = "ERROR" #1127

JamesBowerXanda opened this issue Oct 25, 2024 · 0 comments

Comments

@JamesBowerXanda
Copy link

Issue you'd like to raise.

I am using LangGraph to create an application and am using the NodeInterrupt class to create dynamic interrupts to allow human in the loop interactions in certain scenarios. I noticed that when I run a graph that gets interrupted and look at the traces in LangSmith the overall run status will have status succeeded but the node that got interrupted will have status Error.

I appreciate this is because the node started but did not complete but it feels wrong somehow when it is an intentional interrupt.

Here is some example code I ran and I have attached the LangSmith screenshot.

from langgraph.graph import START, END, StateGraph, MessagesState
from langgraph.errors import NodeInterrupt
from langchain_core.messages import AIMessage, HumanMessage


class State(MessagesState):
    pass

async def hello_node(state: State):
    return {"messages": [AIMessage(content="Hello")]}

async def human_node(state: State2):
    raise NodeInterrupt("human")

async def goodbye_node(state: State):
    return {"messages": [AIMessage(content="Goodbye")]}


builder = StateGraph(State)
builder.add_node("hello", hello_node)
builder.add_node("human", human_node)
builder.add_node("goodbye", goodbye_node)
builder.add_edge(START, "hello")
builder.add_edge("hello", "human")
builder.add_edge("human", "goodbye")
builder.add_edge("goodbye", END)

checkpointer = MemorySaver()

graph = builder.compile(checkpointer=checkpointer)

config = {
    "configurable": {
        "thread_id": 2
    }
}

state = await graph.ainvoke({"messages": []}, config=config)

state = await graph.aget_state(config)
next_node = state.next
await graph.aupdate_state(config, {"messages": [HumanMessage(content="let's checkout")]}, as_node="human")
await graph.ainvoke(None, config=config)

image

Suggestion:

It would be nice if the status for the node showed something like "INTERRUPTED" instead of "ERROR" and maybe didn't show the full stacktrace of the NodeInterrupt Exception since it is an intended interruption.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant