New agent code for advanced tutorial