HITL Rest Workflow Guide
Prerequisites
1
2
Create an Agent with HITL Enabled
curl -X POST "$BACKEND_URL/agents/" \
-H "X-API-Key: $AIP_MASTER_API_KEY" \
-H "Content-Type: application/json" \
-d @agent_payload.json{
"name": "hitl_approval_agent",
"instruction": "Whenever an action needs approval, call the requires_approval_tool first.",
"type": "config",
"framework": "langchain",
"version": "1.0",
"tools": ["<TOOL_ID_FROM_UPLOAD>"],
"agent_config": {
"hitl_enabled": true,
"lm_provider": "openai",
"lm_name": "gpt-4.1"
},
"tool_configs": {
"<TOOL_ID_FROM_UPLOAD>": {
"hitl": {
"timeout_seconds": 180
}
}
}
}3
Run the Agent and Watch for HITL Pauses
curl -N -X POST "$BACKEND_URL/agents/<AGENT_ID>/run" \
-H "X-API-Key: $AIP_MASTER_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"input": "Please send an offer email to jane.doe@example.com and update her ATS record."
}'{
"status": "success",
"task_state": "working",
"content": "Awaiting human approval for request 'bc4d0a77-7800-470e-a91c-7fd663a66b4d'. Invoke ApprovalManager.resolve_pending_request using this identifier to continue execution.",
"metadata": {
"kind": "agent_thinking_step",
"status": "finished",
"hitl": {
"required": true,
"decision": "pending",
"request_id": "bc4d0a77-7800-470e-a91c-7fd663a66b4d",
"timeout_at": "2025-10-14T01:56:22.464367+00:00",
"timeout_seconds": 10
},
"tool_info": {
"id": "call_UHU9hq7rfikCrTLhImGmRx37",
"name": "requires_approval_tool",
"args": {},
"output": "Awaiting human approval for request 'bc4d0a77-7800-470e-a91c-7fd663a66b4d'. Invoke ApprovalManager.resolve_pending_request using this identifier to continue execution.",
"execution_time": null
}
}
}4
Resolve a HITL Request
curl -X POST "$BACKEND_URL/agents/hitl/decision" \
-H "X-API-Key: $AIP_MASTER_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"request_id": "bc4d0a77-7800-470e-a91c-7fd663a66b4d",
"decision": "approved",
"operator_input": "Looks good",
"run_id": "optional-client-tracker"
}'5
Optional: List Pending HITL Requests
curl -X GET "$BACKEND_URL/agents/hitl/pending" \
-H "X-API-Key: $AIP_MASTER_API_KEY"[
{
"request_id": "bc4d0a77-7800-470e-a91c-7fd663a66b4d",
"tool": "requires_approval_tool",
"arguments": {
"action": "Finalize Jane Doe's hiring decision in the ATS for the Senior Backend Engineer role, including score and recommendation to move forward with offer."
},
"created_at": "2025-10-08T14:41:01.553063+00:00",
"agent_id": "hitl_approval_agent-a44ac39b",
"run_id": null,
"hitl_metadata": {
"required": true,
"decision": "pending",
"timeout_at": "2025-10-08T15:41:01.553063+00:00",
"timeout_seconds": 180
},
"additional_context": {
"tool_name": "requires_approval_tool",
"arguments": {
"action": "Finalize Jane Doe's hiring decision in the ATS for the Senior Backend Engineer role, including score and recommendation to move forward with offer."
},
"agent_id": "hitl_approval_agent-a44ac39b"
}
}
]Last updated