The answer is really not that simple.
There are lots of herbicides with different structure and characteristics.
We have to see the two things meeting, one is the herbicide, each one degrades basically in different timeframe, and this time varies depending on temperatire humidity, etc. And the second factor is the environment itself, in this case your compost. First of all is it a closed systeme or can it leak? Its known that every chemical or biological compound is maybe faster degraded in the presence of different microorganism families. And as above mentioned temperatiure, moisture, pH of the environment.
So sadly its really not simple, i know pesticides which are broken down in one year or less and there are one which take longer. Theoretically the longer should/would be restricted more. But still there is no general answer sadly. And therefore it stays a risky question to welcome alien material to your ground.