Expand description
Human-in-the-Loop Support
Provides pause/resume, approval gates, and interactive breakpoints for graph-based workflows.
§Features
- Approval Gates: Pause execution for human approval before continuing
- Breakpoints: Define nodes where execution pauses for inspection/input
- Input Collection: Request structured input from humans during execution
- Interrupt/Resume: Pause and resume execution at any point
§Example
ⓘ
use cortexai_crew::human_loop::{HumanLoop, ApprovalGate, InteractiveGraph};
// Create a graph with approval gates
let graph = GraphBuilder::new("approval_workflow")
.add_node("generate", generate_content)
.add_node("review", review_node)
.add_node("publish", publish_content)
.add_edge("generate", "review")
.add_edge("review", "publish")
.set_entry("generate")
.build()?;
// Wrap with human-in-the-loop
let interactive = InteractiveGraph::new(graph)
.with_approval_gate("review", ApprovalGate::new("Review the generated content"))
.with_breakpoint("publish");
// Run interactively
let mut session = interactive.start(initial_state).await?;
loop {
match session.next().await? {
HumanLoopAction::Continue(state) => { /* auto-continues */ }
HumanLoopAction::AwaitApproval { gate, state } => {
// Show content to user, get approval
if user_approves() {
session.approve().await?;
} else {
session.reject("Needs more work").await?;
}
}
HumanLoopAction::AwaitInput { request, state } => {
let input = get_user_input(&request);
session.provide_input(input).await?;
}
HumanLoopAction::Breakpoint { node_id, state } => {
// Inspect state, optionally modify
session.resume().await?;
}
HumanLoopAction::Complete(result) => break,
}
}Structs§
- Approval
Gate - Approval gate configuration
- Human
Input Request - Input request for human interaction
- Interactive
Graph - Interactive graph wrapper with human-in-the-loop support
- Interactive
Session - Interactive execution session
- Interactive
Workflow Builder - Builder for creating interactive workflows
- Select
Option - Option for select inputs
Enums§
- Approval
Response - Human response to an approval gate
- Human
Input Type - Type of input expected for human interaction
- Human
Loop Action - Action required from human
- Session
Status - Session status