post hook edit entity
The participant create in set_kavo_state() triggers your post hook again which then calls set_kavo_state() etc.  You need to determine whether the post hook is being called just to update the $kavo_status_field and $kavo_message_field fields - and therefore not set up another callback to set_kavo_state().

Do you actually need to call your external API for participant edits?  If you could limit the post hook to only trigger on 'create' you would avoid the loop.