Fix deadlock in agent representation