agent-chat-ui: Interrupts not working as expected (graph resets instead of resuming)

I’m experiencing two issues when using Agent Chat UI with LangGraph:

  1. Only the second interrupt (from the get_user_feedback node) appears in the UI.
  2. After responding to that interrupt, the graph restarts from the beginning rather than resuming from the current node.

I have verified that everything works correctly in LangGraph Studio (as shown in the attached video).
I’m not proficient in TypeScript and have only recently started working with LangGraph, so I might be missing an obvious issue on my end.

Steps to Reproduce:

  1. Use the code below.
  2. Run Agent Chat UI.
  3. Notice that only the second interrupt is displayed and after providing input, the graph resets.
Minimal reproducible code
from enum import Enum
from typing import Annotated
from typing import Literal
from typing import TypedDict

from dotenv import load_dotenv
from langchain.chat_models import init_chat_model
from langchain_core.messages import AIMessage
from langchain_core.messages import AnyMessage
from langchain_core.messages import HumanMessage
from langchain_core.output_parsers import StrOutputParser
from langchain_core.prompts import ChatPromptTemplate
from langchain_core.runnables import RunnableConfig
from langgraph.checkpoint.memory import MemorySaver
from langgraph.graph import add_messages
from langgraph.graph import START
from langgraph.graph import StateGraph
from langgraph.types import Command
from langgraph.types import interrupt


load_dotenv()


class State(TypedDict):
  messages: Annotated[list[AnyMessage], add_messages]


class YesNoEnum(str, Enum):
  YES = 'yes'
  NO = 'no'


model = init_chat_model()

checkpointer = MemorySaver()

config = RunnableConfig(
  configurable={
      'model': 'gpt-4o-mini',
      'temperature': 0.5,
      'max_tokens': None,
      'timeout': None,
  }
)


async def validate_request_scope(state: State) -> Command[Literal['provide_cat_info', 'handle_off_topic']]:
  prompt = ChatPromptTemplate.from_messages([
      ('system', '''
You are the input controller for a "cats-only" system.
Determine if a user request EXCLUSIVELY relates to cats.

Answer ONLY "yes" or "no" (all lower case):
- "yes" if the request is about cats
- "no" otherwise
          '''),
      ('human', '''
Please validate the following user query:
{user_query}
          ''')
  ])

  chain = prompt | model | StrOutputParser()

  result = (chain.invoke(
      {
          'user_query': state['messages'][-1].content,
      },
      config=config,
  )).strip().lower()

  try:
      validation_result = YesNoEnum(result)
  except ValueError:
      validation_result = YesNoEnum.YES

  # Decision logic
  if validation_result is YesNoEnum.YES:
      goto = 'provide_cat_info'
      messages = []

  else:
      goto = 'handle_off_topic'
      messages = []

  return Command(
      update={
          'messages': messages,
      },
      goto=goto,
  )


async def handle_off_topic(state: State) -> Command[Literal['validate_request_scope']]:  # noqa
  interrupt_message = {
      'message': 'I can only help with cats. Sorry, but your request is off-topic.'
  }

  new_query = interrupt(interrupt_message)

  return Command(
      update={
          'messages': HumanMessage(content=new_query),
      },
      goto='validate_request_scope',
  )


async def provide_cat_info(state: State):  # noqa
  messages = [AIMessage(content='Here is some info about cats.')]

  return {
      'messages': messages,
  }


async def get_user_feedback(state: State) -> Command[Literal['provide_cat_info']]:  # noqa
  interrupt_message = {
      'message': 'The cat info is ready. If you have any comments or additional details, '
                 'send them to me and I will continue working.'
  }

  feedback = interrupt(interrupt_message)

  return Command(
      update={
          'messages': [HumanMessage(content=feedback)],
      },
      goto='provide_cat_info',
  )

workflow = StateGraph(State)

workflow.add_node('validate_request_scope', validate_request_scope)
workflow.add_node('handle_off_topic', handle_off_topic)
workflow.add_node('provide_cat_info', provide_cat_info)
workflow.add_node('get_user_feedback', get_user_feedback)

workflow.add_edge(START, 'validate_request_scope')
workflow.add_edge('provide_cat_info', 'get_user_feedback')

graph = workflow.compile()

Video Demonstration: [Video demonstration link]

Please let me know if additional information is needed. Thanks!

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 27 (13 by maintainers)

Most upvoted comments

Understood. I’ll open a dedicated issue or discussion at a later point in time.

@alex-feel started the PR for handling unknown interrupt objects.

@bracesproul,

I watched the video, and I noticed that the new implementation proposes a separate input field for interrupts. I was expecting that the system would simply use the existing chat input field for interrupt responses.

My reasoning is that the graph represents a continuous process, and an interrupt is just a system-triggered request for feedback — similar to how a user’s initial message starts the graph. From a UX perspective, having the user switch to a completely separate field to provide their response seems awkward and unnecessary. It would be much more natural for the interrupt to utilize the same input field used for regular chat messages.

Could you please elaborate on the rationale behind using a separate input field for interrupts? I’d appreciate any further insights, as I believe maintaining a single input field would provide a more seamless experience.

Thanks again for your work on this!

@bracesproul, that’s great — thank you!

Just a heads-up: if I’m unavailable for a while and you need to test the interrupt functionality, the repository cats-only-system-langgraph contains the code.

Thanks!

@alex-feel started the PR for handling unknown interrupt objects. Once this merges support will be live. hopefully sometime today

@bracesproul, thanks for clarifying. This is exactly the case you described: resuming via the chat input kicks off a new run instead of resuming the previous state, so I’ll simply wait for that functionality. Thanks again for your support.

@bracesproul,

I have a few clarifications regarding the interrupt schema you mentioned:

  1. Reference to Agent Inbox: You referred to the schema from the Agent Inbox repository. Could you explain why you’re suggesting that? I’m using Agent Chat UI, which is designed to work with the standard LangGraph interrupt function. I don’t see how the Agent Inbox schema relates to my current setup.

  2. Standard Schema vs. Agent Inbox: Is the schema you mentioned a standard requirement for LangGraph interrupts, or is it specific only to Agent Inbox? According to the documentation I’ve reviewed (e.g., human_in_the_loop and interrupt type reference), my initial implementation already conforms to the expected usage.

  3. Behavioral Inconsistency: My code works exactly the same before and after applying the suggested schema. The interrupt from the get_user_feedback function displays correctly, but the one from handle_off_topic never shows up in Agent Chat UI. This inconsistency is puzzling.

  4. Unexpected UI Elements: When experimenting with the proposed schema, I encountered a strange form that includes a “Mark as Resolved” button and a separate input field for user responses. I’m aiming to use the existing chat input field exclusively; having two different input mechanisms degrades the UX.

  5. Clarification on Requirements: It seems there might be some confusion here. I don’t need the Agent Inbox or its specialized schema — I need the standard interrupt functionality as described in the LangGraph documentation. Agent Chat UI is advertised as a Vite + React application that enables chatting with any LangGraph server using the messages key, so I would expect the standard interrupt to work out of the box.

  6. Everything Works in LangGraph Studio: All functionality works correctly in LangGraph Studio with my initial code — absolutely everything works as expected. This further indicates that the issue is not with my interrupt implementation but likely lies within the Agent Chat UI itself.

Based on these points, it appears that the cause of the problem is within the Agent Chat UI code, which seems to be a bug.

Could you please help clarify these points? I appreciate your insights and any further guidance you can provide.