You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 64e2cc2
Browse filesBrowse the repository at this point in the historyBrowse files
Prompt for human feedback in LangGraph HITL sample (#324)
* Prompt for human feedback in LangGraph HITL sample
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.
* Only require AI SDK team review for langgraph_plugin
* Revert: restore SDK team review for langgraph_plugin CODEOWNERS
Copy file name to clipboardExpand all lines: langgraph_plugin/graph_api/human_in_the_loop/README.md
+5-3Lines changed: 5 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,7 +14,7 @@ Demonstrates pausing a graph with LangGraph's `interrupt()` and waiting indefini
14
14
1. The Workflow starts and the `generate_draft` node produces a response.
15
15
2. The `human_review` node calls `interrupt(draft)`, pausing execution.
16
16
3. The Workflow stores the draft (visible via the query) and calls `workflow.wait_condition()` — blocking durably until the signal sets `_human_input`. This can wait indefinitely; Temporal persists the state.
17
-
4. An external process (UI, CLI, etc.) queries the draft and sends approval via signal.
17
+
4. An external process (UI, CLI, etc.) queries the draft and sends the human's feedback via signal.
18
18
5. The graph resumes — `interrupt()` returns the signal value and the node completes.
19
19
20
20
## Running the Sample
@@ -25,14 +25,16 @@ Prerequisites: `uv sync --group langgraph` and a running Temporal dev server (`t
25
25
# Terminal 1: start the worker
26
26
uv run langgraph_plugin/graph_api/human_in_the_loop/run_worker.py
27
27
28
-
# Terminal 2: start the workflow (polls for draft, then auto-approves)
28
+
# Terminal 2: start the workflow (polls for the draft, then prompts you for feedback)
29
29
uv run langgraph_plugin/graph_api/human_in_the_loop/run_workflow.py
30
30
```
31
31
32
+
When the draft is ready, you'll be prompted at the terminal. Type `approve` to accept it as-is, or type revision feedback and the draft will be regenerated by an LLM incorporating your notes.
33
+
32
34
## Files
33
35
34
36
| File | Description |
35
37
|------|-------------|
36
38
|`workflow.py`| Graph node functions, graph definition, and `ChatbotWorkflow` definition |
37
39
|`run_worker.py`| Builds graph, registers with `LangGraphPlugin`, starts worker |
38
-
|`run_workflow.py`| Starts workflow, polls draft via query, sends approval via signal |
40
+
|`run_workflow.py`| Starts workflow, polls draft via query, prompts for human feedback, sends it via signal |
0 commit comments