Skip to content

Commit 09ed9c6

Browse files
committed
feat: Add InterruptService for human-in-the-loop graph workflows
Add interrupt system enabling pause/resume, human approval gates, and cancellation during graph execution. Includes InterruptService with priority queues and per-session metrics, InterruptReasoner for LLM-based interrupt decisions, GraphInterruptMixin for execution loop integration, checkpoint tracing, and interrupt samples with architecture documentation.
1 parent d789845 commit 09ed9c6

File tree

27 files changed

+8672
-102
lines changed

27 files changed

+8672
-102
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Composable HITL Orchestrated Pipeline
2+
3+
Demonstrates how to compose HITL review loops as reusable `NestedGraphNode` building blocks in a larger orchestrated pipeline.
4+
5+
## Graph Structure
6+
7+
**Outer graph** (`document_pipeline`):
8+
```
9+
[classify] --> [process] --> [aggregate]
10+
```
11+
12+
**Inner graph** (`review_stage`, wrapped as `NestedGraphNode`):
13+
```
14+
[execute] --> [review_gate] --> approved? --> [done]
15+
|
16+
v rejected
17+
[revise] --> [review_gate] (loop)
18+
```
19+
20+
## Key Concepts
21+
22+
- **Reusable HITL block**: The inner review graph is built once and wrapped in `NestedGraphNode`
23+
- **Clean abstraction**: Outer orchestrator doesn't know about inner HITL details
24+
- **Independent review cycles**: Each inner graph has its own interrupt timing
25+
- **Observability**: `_debug_process_output` tracks nested graph output (via Part B observability)
26+
- **Rule-based classification**: `classify` node determines stages without LLM
27+
28+
## Running
29+
30+
```bash
31+
# Without LLM (deterministic fallback):
32+
python -m contributing.samples.graph_agent_hitl_orchestrated.agent
33+
34+
# With LLM:
35+
export GOOGLE_API_KEY="your-key"
36+
python -m contributing.samples.graph_agent_hitl_orchestrated.agent
37+
```
38+
39+
## How It Works
40+
41+
1. `classify` reads input document, determines processing stages (extract/summarize/translate)
42+
2. `process` (NestedGraphNode) runs the inner review graph with HITL loop
43+
3. Inner `execute` performs the stage task, `review_gate` pauses for human approval
44+
4. If rejected: inner `revise` incorporates feedback, loops back
45+
5. If approved: inner `done` returns output to outer graph
46+
6. `aggregate` combines results into final output
47+
48+
## Differences from `graph_agent_hitl_review`
49+
50+
- `graph_agent_hitl_review`: Standalone HITL review loop
51+
- `graph_agent_hitl_orchestrated`: Wraps the review pattern as a NestedGraphNode in a larger pipeline, showing composability

contributing/samples/graph_agent_hitl_orchestrated/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)