use ref instead of agent to register message types