Help! My coding agent can run code

A coding agent is only actually useful if it can run whatever code the task demands, but a tool that runs arbitrary code is just as dangerous as it sounds! So how do you protect ourself with guardrails that stop an agent from making mistakes you can't easily undo?