[GH-ISSUE #2592] LangGraph Interrupt Example Not Working with Azure OpenAI #312

Open
opened 2026-02-17 17:19:37 -05:00 by yindo · 0 comments
Owner

Originally created by @ghchen99 on GitHub (Feb 11, 2026).
Original GitHub issue: https://github.com/langchain-ai/docs/issues/2592

LangGraph Interrupts Issue with Azure OpenAI

Issue Type

Bug / Compatibility Issue

Language

Python

Description

Attempting to run the LangGraph Interrupts full example from the official documentation using Azure OpenAI instead of Anthropic, but encountering a KeyError when accessing interrupt data.

Original Documentation:
[LangGraph Documentation - Interrupts](https://docs.langchain.com/oss/python/langgraph/interrupts#full-example)


Original Working Example (Anthropic)

import sqlite3
from typing import TypedDict
from langchain.tools import tool
from langchain_anthropic import ChatAnthropic
from langgraph.checkpoint.sqlite import SqliteSaver
from langgraph.graph import StateGraph, START, END
from langgraph.types import Command, interrupt

class AgentState(TypedDict):
    messages: list[dict]

@tool
def send_email(to: str, subject: str, body: str):
    """Send an email to a recipient."""
    # Pause before sending; payload surfaces in result["__interrupt__"]
    response = interrupt({
        "action": "send_email",
        "to": to,
        "subject": subject,
        "body": body,
        "message": "Approve sending this email?",
    })
    if response.get("action") == "approve":
        final_to = response.get("to", to)
        final_subject = response.get("subject", subject)
        final_body = response.get("body", body)
        print(f"[send_email] to={final_to} subject={final_subject} body={final_body}")
        return f"Email sent to {final_to}"
    return "Email cancelled by user"

model = ChatAnthropic(
    model="claude-sonnet-4-5-20250929"
).bind_tools([send_email])

def agent_node(state: AgentState):
    result = model.invoke(state["messages"])
    return {"messages": state["messages"] + [result]}

builder = StateGraph(AgentState)
builder.add_node("agent", agent_node)
builder.add_edge(START, "agent")
builder.add_edge("agent", END)

checkpointer = SqliteSaver(sqlite3.connect("tool-approval.db"))
graph = builder.compile(checkpointer=checkpointer)

config = {"configurable": {"thread_id": "email-workflow"}}
initial = graph.invoke(
    {
        "messages": [
            {
                "role": "user",
                "content": "Send an email to alice@example.com about the meeting"
            }
        ]
    },
    config=config,
)

print(initial["__interrupt__"])

resumed = graph.invoke(
    Command(resume={"action": "approve", "subject": "Updated subject"}),
    config=config,
)

print(resumed["messages"][-1])

Modified Version (Azure OpenAI)

Changes Made

1. Switched Model to Azure OpenAI

model = init_chat_model(
    "azure_openai:gpt-4.1",
    azure_deployment=os.getenv("AZURE_OPENAI_DEPLOYMENT_NAME"),
).bind_tools([send_email])

2. Fixed SQLite Thread Safety Issue

Initial Error Encountered:

sqlite3.ProgrammingError: SQLite objects created in a thread can only be used in that same thread.

Solution Applied:

checkpointer = SqliteSaver(
    sqlite3.connect("tool-approval.db", check_same_thread=False)
)

Current Error

Command Used

uv run python .\tools.py

Error Message

KeyError: '__interrupt__'

Error Location

The error occurs at:

print(initial["__interrupt__"])

Expected Behavior

When the agent invokes the send_email tool, the interrupt() function should pause execution and the returned initial dictionary should contain an "__interrupt__" key with the interrupt payload for approval.

Actual Behavior

The "__interrupt__" key is not present in the initial dictionary when using Azure OpenAI, causing a KeyError.


Questions

  1. Is there a compatibility issue between LangGraph interrupts and Azure OpenAI models?
  2. Does Azure OpenAI handle tool calls differently in a way that prevents the interrupt mechanism from working?
  3. Are there additional configuration steps required for interrupts to work with Azure OpenAI?

Environment Details

  • LangGraph Version: 1.0.8
  • LangChain Version: 1.2.10
  • LangChain Core Version: 1.2.10
  • LangChain OpenAI Version: 1.1.8
  • LangGraph Checkpoint SQLite: 3.0.3
  • OpenAI SDK Version: 2.18.0
  • Python Version: 3.12
  • Azure OpenAI Model: gpt-4.1

Complete Package List

Package                     Version
--------------------------- ---------
aiosqlite                   0.22.1
annotated-types             0.7.0
anyio                       4.12.1
certifi                     2026.1.4
charset-normalizer          3.4.4
colorama                    0.4.6
distro                      1.9.0
h11                         0.16.0
httpcore                    1.0.9
httpx                       0.28.1
idna                        3.11
jiter                       0.13.0
jsonpatch                   1.33
jsonpointer                 3.0.0
langchain                   1.2.10
langchain-core              1.2.10
langchain-openai            1.1.8
langgraph                   1.0.8
langgraph-checkpoint        4.0.0
langgraph-checkpoint-sqlite 3.0.3
langgraph-prebuilt          1.0.7
langgraph-sdk               0.3.5
langsmith                   0.7.1
openai                      2.18.0
orjson                      3.11.7
ormsgpack                   1.12.2
packaging                   26.0
pydantic                    2.12.5
pydantic-core               2.41.5
python-dotenv               1.2.1
pyyaml                      6.0.3
regex                       2026.1.15
requests                    2.32.5
requests-toolbelt           1.0.0
sniffio                     1.3.1
sqlite-vec                  0.1.6
tenacity                    9.1.4
tiktoken                    0.12.0
tqdm                        4.67.3
typing-extensions           4.15.0
typing-inspection           0.4.2
urllib3                     2.6.3
uuid-utils                  0.14.0
xxhash                      3.6.0
zstandard                   0.25.0
Originally created by @ghchen99 on GitHub (Feb 11, 2026). Original GitHub issue: https://github.com/langchain-ai/docs/issues/2592 # LangGraph Interrupts Issue with Azure OpenAI ## Issue Type Bug / Compatibility Issue ## Language Python ## Description Attempting to run the **LangGraph Interrupts full example** from the official documentation using **Azure OpenAI** instead of **Anthropic**, but encountering a `KeyError` when accessing interrupt data. **Original Documentation:** [[LangGraph Documentation - Interrupts](https://docs.langchain.com/oss/python/langgraph/interrupts#full-example)](https://docs.langchain.com/oss/python/langgraph/interrupts#full-example) --- ## Original Working Example (Anthropic) ```python import sqlite3 from typing import TypedDict from langchain.tools import tool from langchain_anthropic import ChatAnthropic from langgraph.checkpoint.sqlite import SqliteSaver from langgraph.graph import StateGraph, START, END from langgraph.types import Command, interrupt class AgentState(TypedDict): messages: list[dict] @tool def send_email(to: str, subject: str, body: str): """Send an email to a recipient.""" # Pause before sending; payload surfaces in result["__interrupt__"] response = interrupt({ "action": "send_email", "to": to, "subject": subject, "body": body, "message": "Approve sending this email?", }) if response.get("action") == "approve": final_to = response.get("to", to) final_subject = response.get("subject", subject) final_body = response.get("body", body) print(f"[send_email] to={final_to} subject={final_subject} body={final_body}") return f"Email sent to {final_to}" return "Email cancelled by user" model = ChatAnthropic( model="claude-sonnet-4-5-20250929" ).bind_tools([send_email]) def agent_node(state: AgentState): result = model.invoke(state["messages"]) return {"messages": state["messages"] + [result]} builder = StateGraph(AgentState) builder.add_node("agent", agent_node) builder.add_edge(START, "agent") builder.add_edge("agent", END) checkpointer = SqliteSaver(sqlite3.connect("tool-approval.db")) graph = builder.compile(checkpointer=checkpointer) config = {"configurable": {"thread_id": "email-workflow"}} initial = graph.invoke( { "messages": [ { "role": "user", "content": "Send an email to alice@example.com about the meeting" } ] }, config=config, ) print(initial["__interrupt__"]) resumed = graph.invoke( Command(resume={"action": "approve", "subject": "Updated subject"}), config=config, ) print(resumed["messages"][-1]) ``` --- ## Modified Version (Azure OpenAI) ### Changes Made #### 1. Switched Model to Azure OpenAI ```python model = init_chat_model( "azure_openai:gpt-4.1", azure_deployment=os.getenv("AZURE_OPENAI_DEPLOYMENT_NAME"), ).bind_tools([send_email]) ``` #### 2. Fixed SQLite Thread Safety Issue **Initial Error Encountered:** ``` sqlite3.ProgrammingError: SQLite objects created in a thread can only be used in that same thread. ``` **Solution Applied:** ```python checkpointer = SqliteSaver( sqlite3.connect("tool-approval.db", check_same_thread=False) ) ``` --- ## Current Error ### Command Used ```bash uv run python .\tools.py ``` ### Error Message ``` KeyError: '__interrupt__' ``` ### Error Location The error occurs at: ```python print(initial["__interrupt__"]) ``` --- ## Expected Behavior When the agent invokes the `send_email` tool, the `interrupt()` function should pause execution and the returned `initial` dictionary should contain an `"__interrupt__"` key with the interrupt payload for approval. ## Actual Behavior The `"__interrupt__"` key is not present in the `initial` dictionary when using Azure OpenAI, causing a `KeyError`. --- ## Questions 1. Is there a compatibility issue between LangGraph interrupts and Azure OpenAI models? 2. Does Azure OpenAI handle tool calls differently in a way that prevents the interrupt mechanism from working? 3. Are there additional configuration steps required for interrupts to work with Azure OpenAI? --- ## Environment Details - **LangGraph Version:** 1.0.8 - **LangChain Version:** 1.2.10 - **LangChain Core Version:** 1.2.10 - **LangChain OpenAI Version:** 1.1.8 - **LangGraph Checkpoint SQLite:** 3.0.3 - **OpenAI SDK Version:** 2.18.0 - **Python Version:** 3.12 - **Azure OpenAI Model:** gpt-4.1 ### Complete Package List ``` Package Version --------------------------- --------- aiosqlite 0.22.1 annotated-types 0.7.0 anyio 4.12.1 certifi 2026.1.4 charset-normalizer 3.4.4 colorama 0.4.6 distro 1.9.0 h11 0.16.0 httpcore 1.0.9 httpx 0.28.1 idna 3.11 jiter 0.13.0 jsonpatch 1.33 jsonpointer 3.0.0 langchain 1.2.10 langchain-core 1.2.10 langchain-openai 1.1.8 langgraph 1.0.8 langgraph-checkpoint 4.0.0 langgraph-checkpoint-sqlite 3.0.3 langgraph-prebuilt 1.0.7 langgraph-sdk 0.3.5 langsmith 0.7.1 openai 2.18.0 orjson 3.11.7 ormsgpack 1.12.2 packaging 26.0 pydantic 2.12.5 pydantic-core 2.41.5 python-dotenv 1.2.1 pyyaml 6.0.3 regex 2026.1.15 requests 2.32.5 requests-toolbelt 1.0.0 sniffio 1.3.1 sqlite-vec 0.1.6 tenacity 9.1.4 tiktoken 0.12.0 tqdm 4.67.3 typing-extensions 4.15.0 typing-inspection 0.4.2 urllib3 2.6.3 uuid-utils 0.14.0 xxhash 3.6.0 zstandard 0.25.0 ```
yindo added the langgraphexternal labels 2026-02-17 17:19:37 -05:00
yindo changed title from LangGraph Interrupt Example Not Working with Azure OpenAI to [GH-ISSUE #2592] LangGraph Interrupt Example Not Working with Azure OpenAI 2026-06-05 17:26:13 -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#312