18 USC 5034 - Duties of magistrate judge

The magistrate judge shall insure that the juvenile is represented by counsel before proceeding with critical stages of the proceedings. Counsel shall be assigned to represent a juvenile when the juvenile and his parents, guardian, or custodian are financially unable to obtain adequate representation. In cases where the juvenile and his parents, guardian, or custodian are financially able to obtain adequate representation but have not retained counsel, the magistrate judge may assign counsel and order the payment of reasonable attorneys fees or may direct the juvenile, his parents, guardian, or custodian to retain private counsel within a specified period of time. The magistrate judge may appoint a guardian ad litem if a parent or guardian of the juvenile is not present, or if the magistrate judge has reason to believe that the parents or guardian will not cooperate with the juvenile in preparing for trial, or that the interests of the parents or guardian and those of the juvenile are adverse. If the juvenile has not been discharged before his initial appearance before the magistrate judge, the magistrate judge shall release the juvenile to his parents, guardian, custodian, or other responsible party (including, but not limited to, the director of a shelter-care facility) upon their promise to bring such juvenile before the appropriate court when requested by such court unless the magistrate judge determines, after hearing, at which the juvenile is represented by counsel, that the detention of such juvenile is required to secure his timely appearance before the appropriate court or to insure his safety or that of others.