Skip to content

Conversation

@hardiknahata
Copy link

@hardiknahata hardiknahata commented Nov 4, 2025

Fixes an issue where only the first interrupt in a multi-turn conversation would display in the UI. Subsequent interrupts were processed correctly by the backend but failed to render in the interface.

Problem

The interrupt rendering logic only displayed interrupts when attached to the last message or when no AI/tool messages existed. When users responded to an interrupt, new messages were added to the thread, causing the previous message to no longer be "last", which prevented subsequent interrupts from displaying.

Solution

Thread-level interrupt rendering (index.tsx)

  • Added dedicated interrupt component rendering after all messages
  • Renders when: interrupt exists, AI/tool messages present, and not loading
  • Uses unique key "interrupt-msg-after-messages" to prevent conflicts

Interrupt component updates (ai.tsx)

  • Added isInterruptOnly prop to identify interrupt-only component renders
  • Updated Interrupt rendering conditions to include isInterruptOnly
  • When message === undefined, component renders only the interrupt content

This preserves existing behavior for message-attached interrupts while enabling sequential interrupts to render independently.

Testing

Verified with a LangGraph agent triggering multiple sequential interrupts:

  • ✅ First interrupt displays correctly
  • ✅ User responds to first interrupt
  • ✅ Second interrupt displays in UI (previously broken)
  • ✅ Multi-turn interrupt conversations work seamlessly

Enables Agent Chat to support graphs requiring multiple human-in-the-loop interactions, matching LangGraph Studio behavior.

Fixes an issue where only the first interrupt in a multi-turn conversation
would display in the UI. Subsequent interrupts were processed correctly by
the backend but failed to render in the interface.

## Problem

The interrupt rendering logic only displayed interrupts when attached to the
last message or when no AI/tool messages existed. When users responded to an
interrupt, new messages were added to the thread, causing the previous message
to no longer be "last", which prevented subsequent interrupts from displaying.

## Solution

**Thread-level interrupt rendering (index.tsx)**
- Added dedicated interrupt component rendering after all messages
- Renders when: interrupt exists, AI/tool messages present, and not loading
- Uses unique key "interrupt-msg-after-messages" to prevent conflicts

**Interrupt component updates (ai.tsx)**
- Added `isInterruptOnly` prop to identify interrupt-only component renders
- Updated `Interrupt` rendering conditions to include `isInterruptOnly`
- When `message === undefined`, component renders only the interrupt content

This preserves existing behavior for message-attached interrupts while enabling
sequential interrupts to render independently.

## Testing

Verified with a LangGraph agent triggering multiple sequential interrupts:
- ✅ First interrupt displays correctly
- ✅ User responds to first interrupt
- ✅ Second interrupt displays in UI (previously broken)
- ✅ Multi-turn interrupt conversations work seamlessly

Enables Agent Chat to support graphs requiring multiple human-in-the-loop
interactions, matching LangGraph Studio behavior.
@vercel
Copy link

vercel bot commented Nov 4, 2025

@hardiknahata is attempting to deploy a commit to the LangChain Team on Vercel.

A member of the Team first needs to authorize it.

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

Successfully merging this pull request may close these issues.

1 participant