There's a cool research project https://github.com/exoharness/exo that is designed specifically as a self-modifying harness, so architecturally it separates things in a way that makes it a lot harder for the agent to break itself when modifying itself. It looks pretty neat. Saw the author do an interview on a podcast explaining it.
also haven't read too deep into the deepseek agent harness but the math in there was really cool. it sounded promising, at least.