Requirement for the exponent generation during DH protocol
Since $g$, $A=g^a$ and $B=g^b$ are made public, everyone could repeat the same operation and brute force DH with small exponents. 

There are already many responses:
link to security.stackexchange.com
link to crypto.stackexchange.com

Summary: considering a security level of $n$, it is advised to use exponents of at least $2n$ bits.