Jonathan Pickard

All writing

Post

Reverse Onion Model for AI Agent Security: Protecting Yourself from the Inside Out

Jonathan Pickard · · 2 min read

I keep hearing that we need to be able to “pull the plug” on AI agents if something goes wrong. But if pulling the plug is our primary safeguard, the security design is incomplete.

By the time we reach for it, information may already have left the system or an irreversible action may already be underway.

A better starting point is to invert the familiar onion model of layered security.

Put the agent at the center. Then build outward, placing enforceable boundaries between its decisions and their consequences:

Declarative contract: Define the actions and workflows available to the agent.

Runtime enforcement: Validate actions and parameters in code, outside the model’s discretion.

Operating system: Restrict access to files, processes, and secrets.

Network controls: Limit destinations, connections, and service permissions.

Physical controls: Retain an independent way to stop the system.

This is where Cargo-AI fits in. Its declarative workflows and Rust runtime provide a concrete place to define and enforce those inner boundaries. Their strength depends on the restrictions actually implemented, reinforced by independent outer controls.

The goal is to give agents room to do useful work while limiting the consequences when they get something wrong.

Keep the ability to pull the plug, but engineer the layers that make reaching for it less likely.

If you’re building with AI agents and want help putting these boundaries into practice, connect with me and send me a message. We can look at your workflow and where Cargo-AI could help you build stronger controls.

Cargo-AI is MIT-licensed, open-source software for building your own AI agent harnesses and custom Rust tools. Inspect how they work. Run them locally. Own what you build.

Explore Cargo-AI: https://cargo-ai.org