Skip to content

Correct LangGraph interrupt resumption and preserve user input - #260

Open
Vsevolod Kukol (sevoku) wants to merge 2 commits into
AzureCosmosDB:mainfrom
sevoku:dev/sevoku/fix-langgraph-interrupt-resume
Open

Vsevolod Kukol (sevoku) wants to merge 2 commits into
AzureCosmosDB:mainfrom
sevoku:dev/sevoku/fix-langgraph-interrupt-resume

Conversation

@sevoku

@sevoku Vsevolod Kukol (sevoku) commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

Summary

Correct the caller and node guidance in pattern-langgraph-interrupt-human.md so a paused interrupt() receives the user's response and adds it to the graph's message history through the appropriate async execution APIs.

Problem

The rule tells callers to resume with graph.stream(new_input, config). Ordinary graph input does not provide the resume value expected by a pending interrupt(); the supported API uses Command(resume=...).

The example's human_node also discards the return value of interrupt() and returns None. Changing only the caller would therefore still lose the user's response instead of recording it in the conversation. The async agent node and checkpointer example also require an async execution path rather than synchronous graph.stream() execution.

Changes

  • Use graph.astream(Command(resume=user_message), config) and consume it with async for, reusing the interrupted run's thread_id. Document await graph.ainvoke(...) as the non-streaming alternative for the async graph and checkpointer.
  • Capture the value returned by interrupt() and return it as a user message through MessagesState.
  • Clarify that the interrupted node restarts, rather than continuing directly from the interrupted line, and that side effects before interrupt() must be idempotent.
  • Link to the current LangGraph interrupt documentation.

API Evidence

The official resuming-interrupts documentation states that callers resume with Command(resume=...), must reuse the same thread ID, and that the supplied value becomes the return value of interrupt().

The interrupt() API reference demonstrates capturing that returned value and incorporating it into the node's state update. The side-effect guidance explains why code before the interrupt runs again.

This guidance is specifically for resuming a pending dynamic interrupt, not a requirement to replace ordinary input dictionaries in normal multi-turn conversations.

Original Discussion And Scope

Addresses the original review discussion on microsoft/vscode-cosmosdb#3355, where the skill is vendored into the VS Code extension.

This PR changes only the interrupt rule. The async-execution review finding is addressed by 9f134a2, which adds explicit async for consumption and the ainvoke() alternative.

The conflicting checkpoint-guidance discussion is tracked by companion PR #261, which removes raw checkpoint reconstruction and internal trigger injection from the other rule. Both PRs should land before publishing the updated guidance. #261 remains unmerged and its changes are not duplicated here.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Resolve the asynchronous API usage and related guidance inconsistencies before approval.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 1 Medium severity · 2 Low severity

Open (3)
What changed in this PR

Updates LangGraph interrupt guidance to correctly resume with Command(resume=...) and preserve user input.

Changes:

  • Reuses the thread ID when resuming.
  • Records interrupt() output in message history.
  • Documents node restart behavior and idempotent side effects.
  • Links current LangGraph documentation.
File Summary
skills/​cosmosdb-best-practices/​rules/​pattern-langgraph-interrupt-human.md Corrects interrupt resumption and message-history guidance.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread skills/cosmosdb-best-practices/rules/pattern-langgraph-interrupt-human.md Outdated
Comment thread skills/cosmosdb-best-practices/rules/pattern-langgraph-interrupt-human.md Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

Required version and manifest updates are missing for this significant rule change.

Review effort: Lite
Findings: None

Resolved since last review (3)

This branch has not been deployed

No deployments
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.

2 participants