fix deadlock when resolving a reference: agent.rb