Implementation:0xSteph Pentest ai HITL
| Knowledge Sources | |
|---|---|
| Domains | HITL, Teleoperation, Signal_Handling |
| Last Updated | 2026-10-23 00:00 GMT |
Overview
Concrete tool for human-in-the-loop teleoperation that pauses an agent via double Ctrl+C and drops the user into a REPL, provided by the pentest-ai engine.
Description
The hitl module implements human-in-the-loop teleoperation. Two consecutive Ctrl+C (SIGINT) presses within a 0.6-second window pause the orchestrator and drop the user into a REPL. From the REPL, the operator can step through agent decisions, inspect findings and chains, inject instructions, skip steps, abort, or resume autonomous operation. The module is signal-based, not asyncio-based, because Ctrl+C arrives via SIGINT regardless of where the asyncio loop is. The orchestrator polls should_pause() at well-defined yield points.
Usage
Import this module when you need to enable human-in-the-loop control during engagements. Used by the orchestrator at the top of each agent decision cycle.
Code Reference
Source Location
- Repository: 0xSteph_Pentest_ai
- File: engine/hitl.py
- Lines: 1-217
Signature
DOUBLE_CTRL_C_WINDOW_SECONDS = 0.6
def install() -> None: ...
def uninstall() -> None: ...
def should_pause() -> bool: ...
def should_abort() -> bool: ...
def consume_inject() -> str | None: ...
def repl(state: Any) -> dict[str, Any]: ...
Import
from engine.hitl import install, uninstall, should_pause, should_abort, consume_inject, repl
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| SIGINT | signal | Yes | Two presses within 0.6s triggers pause |
| state | Any | Yes (repl) | Engagement state for inspection |
Outputs
| Name | Type | Description |
|---|---|---|
| should_pause | bool | True if pause is requested |
| should_abort | bool | True if abort is requested |
| inject | None | Free-form instruction to inject into next agent turn |
| repl result | dict | Instructions for orchestrator (resume, abort, skip, step) |
Usage Examples
Install and Check in Orchestrator
from engine import hitl
hitl.install()
try:
while not hitl.should_abort():
if hitl.should_pause():
result = hitl.repl(engagement_state)
if result.get("action") == "abort":
break
if result.get("action") == "resume":
continue
# ... run next agent decision ...
injected = hitl.consume_inject()
if injected:
# Add to agent's context for next turn
pass
finally:
hitl.uninstall()