[PR #1885] [MERGED] fix(docs): prioritize interrupt check in SQL agent HITL example #1937

Closed
opened 2026-02-17 17:22:53 -05:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/langchain-ai/docs/pull/1885
Author: @leecode
Created: 12/12/2025
Status: Merged
Merged: 12/19/2025
Merged by: @lnhsingh

Base: mainHead: patch-2


📝 Commits (3)

  • 954f884 fix(docs): prioritize interrupt check in SQL agent HITL example
  • 1f41b99 Merge branch 'main' into patch-2
  • 6cf5791 Merge branch 'main' into patch-2

📊 Changes

1 file changed (+3 additions, -3 deletions)

View changed files

📝 src/oss/langchain/sql-agent.mdx (+3 -3)

📄 Description

Overview

check for interrupt before messages to ensure interrupts are not skipped when both keys exist in the stream step.

Type of change

Type: Fix bug

Related issues/PRs

Checklist

  • I have read the contributing guidelines
  • I have tested my changes locally using docs dev
  • All code examples have been tested and work correctly
  • I have used root relative paths for internal links
  • I have updated navigation in src/docs.json if needed

Additional notes

Problem

The current SQL agent human-in-the-loop example checks for messages before __interrupt__ in the stream loop:

if "messages" in step:
    step["messages"][-1].pretty_print()
elif "__interrupt__" in step:  # This may never execute
    print("INTERRUPTED:")

This creates a potential bug: if a stream step contains both messages and interrupt keys simultaneously, the interrupt handling block will never execute due to the elif condition.

Solution

Reorder the condition checks to prioritize interrupt detection:

  if "__interrupt__" in step:  # Check interrupt first
      print("INTERRUPTED:")
      interrupt = step["__interrupt__"][0]
      for request in interrupt.value["action_requests"]:
          print(request["description"])
  elif "messages" in step:
      step["messages"][-1].pretty_print()

This ensures that interrupts are always detected and handled correctly, even when messages are present in the same step.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/langchain-ai/docs/pull/1885 **Author:** [@leecode](https://github.com/leecode) **Created:** 12/12/2025 **Status:** ✅ Merged **Merged:** 12/19/2025 **Merged by:** [@lnhsingh](https://github.com/lnhsingh) **Base:** `main` ← **Head:** `patch-2` --- ### 📝 Commits (3) - [`954f884`](https://github.com/langchain-ai/docs/commit/954f884f7a56e6ae60330cf772cb4b063e716d85) fix(docs): prioritize interrupt check in SQL agent HITL example - [`1f41b99`](https://github.com/langchain-ai/docs/commit/1f41b99aee739463a0aa93cae2b06e4ce9e58066) Merge branch 'main' into patch-2 - [`6cf5791`](https://github.com/langchain-ai/docs/commit/6cf5791a92620c99f44844951c8d2c10e692f0f0) Merge branch 'main' into patch-2 ### 📊 Changes **1 file changed** (+3 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `src/oss/langchain/sql-agent.mdx` (+3 -3) </details> ### 📄 Description ## Overview check for __interrupt__ before messages to ensure interrupts are not skipped when both keys exist in the stream step. ## Type of change **Type:** Fix bug ## Related issues/PRs ## Checklist <!-- Put an 'x' in all boxes that apply --> - [x] I have read the [contributing guidelines](README.md) - [x] I have tested my changes locally using `docs dev` - [x] All code examples have been tested and work correctly - [ ] I have used **root relative** paths for internal links - [ ] I have updated navigation in `src/docs.json` if needed ## Additional notes ### Problem The current SQL agent human-in-the-loop example checks for `messages` before `__interrupt__` in the stream loop: ```python if "messages" in step: step["messages"][-1].pretty_print() elif "__interrupt__" in step: # This may never execute print("INTERRUPTED:") ``` This creates a potential bug: if a stream step contains both messages and __interrupt__ keys simultaneously, the interrupt handling block will never execute due to the elif condition. ### Solution Reorder the condition checks to prioritize interrupt detection: ```python if "__interrupt__" in step: # Check interrupt first print("INTERRUPTED:") interrupt = step["__interrupt__"][0] for request in interrupt.value["action_requests"]: print(request["description"]) elif "messages" in step: step["messages"][-1].pretty_print() ``` This ensures that interrupts are always detected and handled correctly, even when messages are present in the same step. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-02-17 17:22:53 -05:00
yindo closed this issue 2026-02-17 17:22:53 -05:00
yindo changed title from [PR #1885] fix(docs): prioritize interrupt check in SQL agent HITL example to [PR #1885] [MERGED] fix(docs): prioritize interrupt check in SQL agent HITL example 2026-06-05 18:15:46 -04:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/docs#1937