 In 1814 he was sent as diplomatic agent to the revolutionary government of Buenos Ayres, where he remained for some time, but due to the after-effects of the disaster of Rancagua, he was forced to seek refuge in the United Provinces of the Rio de la Plata.He was only able to return to Chile after the battle of Chacabuco, in 1817.That same year he was appointed secretary of the treasury by the Supreme Director Bernardo O'Higgins.