Safe Task Planning with Long-Term Graph Memory for Embodied Agents