Prompt for human feedback in LangGraph HITL sample#324
Open
DABH wants to merge 2 commits into
Open
Conversation
The graph_api human-in-the-loop sample previously auto-approved the draft and used a hardcoded placeholder response, so running it didn't actually involve a human. Now the draft is generated by an LLM, the runner prompts interactively at the terminal for approval or revision feedback, and the review node revises the draft with the LLM based on that feedback. Tests mock the chat model so they stay deterministic and offline.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The
graph_apihuman-in-the-loop chatbot sample didn't actually involve a human when you ran it — it auto-approved the draft via signal and returned a hardcoded placeholder response. This change makes the sample live up to its name:generate_draftnow calls an LLM (claude-sonnet-4-6) instead of returning a canned string.run_workflow.pyprompts at the terminal forapproveor revision feedback, then signals the workflow.human_reviewregenerates the draft with the LLM incorporating the reviewer's notes.Test plan
uv run --group langgraph pytest tests/langgraph_plugin/human_in_the_loop_test.pypassesruff check --select Iandruff format --checkpassmypypasses on changed files