Please wrap this line in
`agent.with_lock do`
  # Your line here
`end`