Featuring bacterial invasion and colonization within cells, chronic infection-induced immune suppression, and inflammatory cell infiltration, osteomyelitis is currently an intractable and recurrent bone disease. In this study, an injectable hydrogel that gels in situ and is loaded with engineered antimicrobial cells (LL37-MSC@OCAHM) is developed. This anti-inflammatory hydrogel not only maintains cell activity in the inflammatory environment but also releases magnesium ions (Mg