Skip to main content

Human-in-the-Loop

HatiData V2 provides structured checkpoints where autonomous agent progression pauses for human review. Gates, review queues, and recovery workflows give managers and reviewers clear decision points without blocking the entire pipeline.

Gates: Structured Checkpoints

A gate is a named checkpoint in the agent lifecycle. Each gate has predicates — conditions that must be satisfied for the gate to pass.

Gate Types

GateNameAuto-Approvable?Purpose
G0UX ReviewNo (always manual)Wireframe sign-off before build
G1Proposal ApprovalNo (always manual)Client accepts proposal + triggers M1 payment
G2Architecture ReviewConditionallyArchitecture sign-off before parallel build
G3Build QualityConditionallyQA + security pass before staging
G4Pre-Launch ReviewNo (always manual)Client UAT + preview approval
G5Go-LiveNo (always manual)Final sign-off + M3 payment trigger

Gate Predicates

Each gate evaluates a set of predicates against a fact bag — a collection of current project state values:

{
"gate_id": "g3",
"predicates": [
{
"key": "test_results.passed_pct",
"operator": "gte",
"value": 95,
"description": "At least 95% of tests must pass"
},
{
"key": "security_findings.critical",
"operator": "eq",
"value": 0,
"description": "No critical security findings"
},
{
"key": "build_verification.compile_status",
"operator": "eq",
"value": "pass",
"description": "Build must compile successfully"
}
],
"auto_approvable": true,
"client_sign_off_required": false,
"approval_role": "pm"
}

Predicate Operators

OperatorMeaningExample
eqEqualssecurity_findings.critical eq 0
neNot equalsstatus ne "blocked"
gtGreater thanconfidence gt 0.8
gteGreater than or equaltests_passing gte 95
ltLess thancost_usd lt 500
lteLess than or equallatency_ms lte 2000
containsString containsdeploy_target contains "staging"
regexRegex match`agent_type regex "^(qa

Gate Evaluation Results

The gate evaluator returns one of three outcomes:

ResultMeaningNext Action
AutoApprovedAll predicates passed + gate is auto-approvablePhase advances automatically
PendingManualPredicates passed but gate requires human sign-offReviewRequest created
FailedOne or more predicates failedBlocked — fix required
// AutoApproved example
{
"result": "AutoApproved",
"gate_id": "g3",
"passed_conditions": ["test_results", "security_findings", "build_verification"],
"failed_conditions": []
}

// PendingManual example
{
"result": "PendingManual",
"gate_id": "g1",
"approval_role": "client",
"client_sign_off": true,
"passed_conditions": ["proposal_generated", "pricing_valid"],
"action_url": "/portal/{project_id}/gate/g1"
}

// Failed example
{
"result": "Failed",
"gate_id": "g3",
"failed_conditions": [
{
"key": "security_findings.critical",
"expected": "0",
"actual": "2",
"message": "2 critical security vulnerabilities must be resolved"
}
]
}

Review Queue

When human review is needed, a ReviewRequest is created and surfaced in the dashboard:

ReviewRequest Structure

FieldDescription
idUnique review request ID
entity_typeWhat needs review: gate, artifact, release_decision, recovery
entity_idThe specific entity to review
project_idWhich project
reasonWhy human review is needed
urgencylow, medium, high, critical
assigned_toRole (pm, client, admin) or specific email
statuspending, approved, rejected, deferred
created_atWhen the request was created
reviewed_atWhen it was acted on (null if pending)
reviewer_notesFree-text notes from the reviewer

API Endpoints

MethodPathDescription
GET/v2/reviewsList pending reviews (filterable by project, role, urgency)
GET/v2/reviews/:idGet review detail with context
POST/v2/reviews/:id/approveApprove with optional notes
POST/v2/reviews/:id/rejectReject with mandatory reason
POST/v2/reviews/:id/deferDefer with new deadline

Reviewer Guide

For Project Managers:

  1. Check the Review Queue in the Admin Portal (Command Centre)
  2. Click a pending review to see the evidence summary
  3. For gate reviews: check all predicates, review the evidence bundle
  4. Approve or reject with notes — the pipeline resumes or blocks accordingly

For Clients:

  1. Gate notifications appear as banners in the portal dashboard
  2. Click "Review Gate" to see the evidence checklist
  3. G1 (Proposal) and G4 (Preview) require explicit client sign-off
  4. Approval triggers the next phase + associated milestone payment

Recovery Workflows

When an agent fails and reaches L4 (Human Gate), the system creates a ReviewRequest for the recovery:

Recovery Levels and Human Involvement

LevelHuman Required?What the Reviewer Sees
L1 RetryNo(Automatic — same model retries)
L2 EscalationNo(Automatic — stronger model selected)
L3 RepairNo(Automatic — RepairAgent dispatched)
L4 HumanYesFull ExplainBundle + failure chain + suggested actions
BlockedYesMissing dependency or policy denial — manual intervention required

Recovery Actions via API

POST /v2/recovery/:attempt_id
{
"action": "retry",
"override_reason": "Reviewed the failure — transient issue, safe to retry"
}

Available actions:

ActionEffect
retryCreate new attempt with same configuration
retry_with_modelCreate new attempt with specified model override
escalateBump to next recovery level
repairDispatch RepairAgent with custom evidence
approveOverride the failure — mark as acceptable
blockPermanently block the task — requires human resolution

The Recovery Chain

Every recovery action is recorded in the recovery_actions table, forming an audit trail:

SELECT
ra.failure_kind,
ra.action_type,
ra.status,
ra.created_at
FROM hd_runtime.recovery_actions ra
WHERE ra.task_attempt_id = :attempt_id
ORDER BY ra.created_at;

Example chain:

L1 Retry      → failed (timeout)
L2 Escalation → failed (schema validation)
L3 Repair → failed (RepairAgent couldn't fix)
L4 Human → pending (waiting for PM review)

Notifications

Gate evaluations and review requests generate notifications:

EventNotificationRecipient
Gate ready for review"G2 Architecture Review is ready"PM
Gate requires client sign-off"Review your proposal — G1 pending"Client
L4 recovery needs human"Agent blocked — manual intervention needed"PM/Admin
Gate approved"G3 Build Quality approved — build continues"Client + PM
Gate rejected"G1 Proposal rejected — changes requested"PM

Next Steps

Stay in the loop

Product updates, engineering deep-dives, and agent-native insights. No spam.