See also the
kodosumi-examples
repository on HITL.Overview
The HTIL system consists of three main components:- Entry Points - Initial form inputs that launch workflow executions.
- Locks - Points where execution pauses and waits for human input
- Leases - Handlers that process human input and continue execution
Basic Implementation
1. Entry Point with Form Input
First, create an entry point that collects initial user input:2. Runner Function with Lock
The runner function executes the workflow and can request human intervention:3. Lock Handler
Define what the human sees when the lock is triggered:4. Lease Handler
Process the human input and continue execution:Lock vs Lease Decorators
@app.lock(lock_id)
- Purpose: Defines the user interface shown when execution pauses
- Parameters: Receives the data passed from
tracer.lock()
- Return: A
Model
object defining the form elements - When called: When the lock is first triggered
@app.lease(lock_id)
- Purpose: Processes human input and continues execution
- Parameters: Receives the form data submitted by the human
- Return: Data that will be passed back to the runner function
- When called: When the human submits the lock form
Missing Lease Handler
Complete Example
Here’s a complete HTIL service implementation:API Workflow
Step 1: Get Input Schema
Request:Step 2: Launch Workflow Execution
Request:Step 3: Check Execution Status
Request:Step 4: Get Lock Input Schema
Request:Step 5: Submit Lock Data
Request:Step 6: Check Final Status
Request:Error Handling
Validation Errors
If the lease handler raises anInputsError
, the lock remains active: