Thread safe fsm in agent.