AI Agents in CI Need Isolation, Not Trust

AI Agents in CI Need Isolation, Not Trust

The dream of AI agents fixing bugs in your CI pipeline hits a hard constraint the moment you realize what that actually means: an autonomous system with shell access, running arbitrary commands, installing tools, starting databases, and occasionally discovering creative new interpretations of cleanup.

Last month, GitHub shipped Docker Sandboxes as a runtime for GitHub Agentic Workflows. I spent some time with it, and it changed how I think about agent safety.

The common assumption about agent security is that review catches mistakes. A human looks at the PR, sees the code, approves or rejects it. That works until it doesn’t. The OpenAI/Hugging Face incident showed 17,600 attacker actions that review alone can’t scale against. Useful agents do too much, too fast.

Isolation First, Trust Second

Docker Sandboxes flip the model. Instead of asking an agent to promise it won’t break things, you give it a disposable environment where breaking things is impossible to propagate.

The setup I tested was straightforward: a Java 21 registration service with an intentional bug (case-sensitive email storage despite a case-insensitive requirement). The agent’s job was to inspect the code, run the existing test suite, write a test for the missing invariant, fix the code if needed, and open a draft PR.

Inside the sandbox, the agent had complete autonomy. Sudo access, unrestricted shell, full root. It installed Maven, ran Testcontainers to spin up PostgreSQL, executed integration tests, modified the source, and re-ran everything. Classic integration-testing workflow, just automated.

Outside the sandbox, the surface area collapsed to almost nothing. The network policy allowlisted only the destinations the job actually needed. The agent’s GitHub token could read the repository and talk to Copilot, period. The subsequent PR creation happened in a separate job that could only touch files under src/.

Why the Architecture Matters

The key insight is that Docker Sandboxes use a microVM as the primary boundary, not a container. The agent runs in a dedicated environment with its own kernel, filesystem, and network stack. Most critically, it gets its own private Docker daemon.

This is not the same as running a container. The agent gets full root inside the VM without ever touching the host’s Docker daemon. The only bridge between them is the explicit shared workspace of the repository.

For integration testing, this is transformative. Testcontainers works exactly as it does on a developer’s laptop. The agent ran Maven inside a pinned container, passed the sandbox’s Docker socket through, and Testcontainers used that to launch PostgreSQL. Layers within layers, each with a purpose.

The agent found the bug immediately. The test for case-variant email addresses failed. It normalized the email before insertion, reran the suite, and both tests passed. The workflow compiled to a standard GitHub Actions job, installed the sandbox tooling, authenticated it, started the agent, cleaned everything up. No custom configuration. The generated lock file was platform-specific but the source stayed portable.

The Governance Question

What strikes me about this approach is that it doesn’t try to trust the agent. It trusts the boundary instead.

The agent can have broad autonomy inside. That’s what makes it useful. But that autonomy is contextual, temporary, and contained. The moment the job finishes, the environment is gone. Any mistakes, misadventures, or outright malice stay inside the microVM.

This scales in ways review doesn’t. If your organization starts rolling agents into CI across dozens of teams and repositories, review becomes a bottleneck. Docker AI Governance, which applies organization-wide policies for sandbox network, filesystem, and MCP access, plus audit logging, suggests where this is headed. The same policy model covers laptops and CI runners.

For developers, the implication is immediate: if you’re building or evaluating agentic workflows, isolation should be your first design decision, not your last. Start local with Docker Sandboxes on your machine. Run a task that needs real tools - tests, builds, Testcontainers dependencies. Experience how much freedom an agent actually needs, then decide what access makes sense in your CI.

The real question isn’t whether to use AI agents in your pipeline. It’s whether you’re willing to give them the autonomy they need without the infrastructure to contain it.

For more on securing automation in your pipeline, see https://mgks.dev/tags/ci-cd/ and https://mgks.dev/tags/security/.

The agents that will change how we work are the ones we can afford to let fail spectacularly without consequences.

Read Next