agentkernel
Run AI coding agents in secure, isolated microVMs. Sub-125ms boot times, real hardware isolation.
Installation
# Homebrew (macOS / Linux)
&&
# Or with the install script
|
# Or with Cargo
# Then run setup to download/build required components
Quick Start
# Run any command in an isolated sandbox (auto-detects runtime)
# Run commands in your project
# Create from a template
# Or auto-name from your git branch
# Run with a specific image
The run Command
The fastest way to execute code in isolation. Creates a temporary sandbox, runs your command, and cleans up automatically.
# Auto-detects the right runtime from your command
# Override with explicit image
# Keep the sandbox after execution for debugging
# Use a config file
# Emit a signed execution receipt
Auto-Detection
agentkernel automatically selects the right Docker image based on:
- Command (for
run) - Detects from the command you're running - Project files - Detects from files in your directory
- Procfile - Parses Heroku-style Procfiles
- Config file - Uses
agentkernel.tomlif present
Supported Languages
| Language | Project Files | Commands | Docker Image |
|---|---|---|---|
| JavaScript/TypeScript | package.json, yarn.lock, pnpm-lock.yaml |
node, npm, npx, yarn, pnpm, bun |
node:22-alpine |
| Python | pyproject.toml, requirements.txt, Pipfile |
python, python3, pip, poetry, uv |
python:3.12-alpine |
| Rust | Cargo.toml |
cargo, rustc |
rust:1.85-alpine |
| Go | go.mod |
go, gofmt |
golang:1.23-alpine |
| Ruby | Gemfile |
ruby, bundle, rails |
ruby:3.3-alpine |
| Java | pom.xml, build.gradle |
java, mvn, gradle |
eclipse-temurin:21-alpine |
| Kotlin | *.kt |
- | eclipse-temurin:21-alpine |
| C# / .NET | *.csproj, *.sln |
dotnet |
mcr.microsoft.com/dotnet/sdk:8.0 |
| C/C++ | Makefile, CMakeLists.txt |
gcc, g++, make, cmake |
gcc:14-bookworm |
| PHP | composer.json |
php, composer |
php:8.3-alpine |
| Elixir | mix.exs |
elixir, mix |
elixir:1.16-alpine |
| Lua | *.lua |
lua, luajit |
nickblah/lua:5.4-alpine |
| HCL/Terraform | *.tf, *.tfvars |
terraform |
hashicorp/terraform:1.10 |
| Shell | *.sh |
bash, sh, zsh |
alpine:3.20 |
Procfile Support
If your project has a Procfile, agentkernel parses it to detect the runtime:
web: bundle exec rails server -p $PORT
worker: python manage.py runworker
Persistent Sandboxes
For longer-running work, create named sandboxes:
# Create a sandbox
# Create from a template with auto-expiry
# Create per-branch sandboxes (auto-named from git branch)
# Start it
# Run commands
# Attach an interactive shell
# SSH into a sandbox (certificate-authenticated)
# Stop and remove
# List all sandboxes (shows IP addresses for running containers)
Security Profiles
Control sandbox permissions with security profiles:
# Default: moderate security (network enabled, no mounts)
# Restrictive: no network, read-only filesystem, all capabilities dropped
# Permissive: network, mounts, environment passthrough
# Disable network access specifically
| Profile | Network | Mount CWD | Mount Home | Pass Env | Read-only |
|---|---|---|---|---|---|
| permissive | Yes | Yes | Yes | Yes | No |
| moderate | Yes | No | No | No | No |
| restrictive | No | No | No | No | Yes |
SSH Access
SSH into sandboxes with automatic certificate authentication. No passwords, no manual key setup.
# Create an SSH-enabled sandbox
# SSH in (ephemeral certs are generated automatically)
# Run a command over SSH
# Record a session (asciicast format)
# Use the raw ssh command (printed on connect)
# Generate SSH config for IDE integration (VS Code Remote-SSH, etc.)
How it works:
--sshinjects an OpenSSH server into the container at creation time- A CA keypair is generated per-sandbox; client certs are signed on each
sshconnect - Certs are short-lived (30 minutes by default) and stored in
~/.agentkernel/ssh/<name>/ - Password and keyboard-interactive auth are disabled — cert-only
- For Vault-based cert signing, set
vault_addrandvault_ssh_mountin config
Templates
Pre-configured sandbox environments for common use cases. 18+ built-in templates, or save your own.
# List available templates
# Create a sandbox from a template
# Save a running sandbox as a reusable template
# Add/remove custom templates
Built-in templates include: python, node, rust, go, ruby, java, dotnet, php, elixir, c-cpp, shell, terraform, python-ci, node-ci, rust-ci, data-science, web-dev, fullstack.
Snapshots & Sessions
Save and restore sandbox state, or tie sandbox lifecycle to agent conversations.
# Snapshots: save and restore sandbox state
# Sessions: agent conversation lifecycle
Pipelines & Parallel Execution
Chain sandboxes with data flow, or fan-out jobs across sandboxes.
# Pipelines: sequential multi-step execution with data flow
# Parallel: run independent jobs concurrently
Pipeline steps are defined in TOML with name, image, command, and optional input/output directories for data passing between steps.
Secrets — Credential Isolation
AI agents need API keys to call LLMs, but putting secrets inside sandboxes defeats the purpose of isolation. A compromised agent could exfiltrate your credentials to any host.
agentkernel solves this with network-layer secret injection (the Gondolin pattern): secrets never enter the VM. Instead, a host-side proxy intercepts outbound HTTPS requests and injects credentials at the network layer, scoped to specific domains.
# Inject OPENAI_API_KEY into requests to api.openai.com only
# Inside the sandbox:
# - curl https://api.openai.com/v1/models → Authorization header injected automatically
# - curl https://evil.com → blocked (403)
# - echo $OPENAI_API_KEY → "ak-proxy-managed" (placeholder, not the real key)
The sandbox sees placeholder env vars so tools don't fail existence checks, but the real secret never crosses the VM boundary. Unauthorized hosts are blocked entirely. This is a fundamentally different security model from injecting secrets as environment variables or mounted files.
Three vault backends for storing secrets: file (default), environment variables (CI/CD), or OS keychain (macOS Keychain, Linux secret-service). File-based injection via VSOCK is also supported for secrets that aren't HTTP headers.
# Secrets vault: store API keys and credentials
# Image cache management
# Export/import sandbox configs
# Export sandbox filesystem
Maintenance
# Garbage collection (remove expired/stopped sandboxes)
# Clean up everything (containers, images, cache)
# System diagnostics
# Performance benchmarking
# Shell completions
Configuration
Create agentkernel.toml in your project root:
[]
= "my-project"
= "python:3.12-alpine" # Explicit Docker image
[]
= "claude" # claude, gemini, codex, opencode
[]
= 2
= 1024
[]
= "restrictive" # permissive, moderate, restrictive
= false # Override: disable network
Most projects don't need a config file - agentkernel auto-detects everything.
HTTP API
Run agentkernel as an HTTP server for programmatic access:
# As a background service (recommended — survives reboots)
# Or run manually
# With API key authentication
# With multiple keys from a file (one per line)
Authentication
When --api-key or --api-key-file is set, all requests (except GET /health) must include an Authorization: Bearer <key> header. Multiple keys can be provided via repeated --api-key flags or a key file. Keys can also be set via the AGENTKERNEL_API_KEY env var or in agentkernel.toml.
Endpoints
| Method | Path | Description |
|---|---|---|
| GET | /health |
Health check (no auth required) |
| GET | /status |
Server version and backend info |
| GET | /stats |
Sandbox count, resource usage (CPU/memory/disk) |
| POST | /run |
Run command in temporary sandbox |
| GET | /sandboxes |
List all sandboxes (supports ?label=key:value filter) |
| POST | /sandboxes |
Create a sandbox (supports labels, description) |
| GET | /sandboxes/{name} |
Get sandbox info |
| PATCH | /sandboxes/{name} |
Update sandbox metadata (labels, description) |
| DELETE | /sandboxes/{name} |
Remove sandbox |
| POST | /sandboxes/{name}/exec |
Execute command in sandbox |
| POST | /gc |
Garbage-collect expired sandboxes |
Example
# Run a command
# Response: {"success": true, "data": {"output": "2\n"}}
# Create sandbox with labels
# Get stats (for fleet load balancing)
# Response includes sandbox_count, resource_usage (cpu_percent, memory_used_mb, etc.)
Multi-Agent Support
Check which AI coding agents are available:
Output:
AGENT STATUS API KEY
---------------------------------------------
Claude Code installed set
Gemini CLI not installed missing
Codex installed set
OpenCode installed set
SDKs
Official client libraries for the agentkernel HTTP API:
| SDK | Package | Install | Docs |
|---|---|---|---|
| Node.js | agentkernel |
npm install agentkernel |
Guide |
| Python | agentkernel-sdk |
pip install agentkernel-sdk |
Guide |
| Go | agentkernel |
go get github.com/thrashr888/agentkernel/sdk/golang |
Guide |
| Rust | agentkernel-sdk |
cargo add agentkernel-sdk |
Guide |
| Swift | AgentKernel |
Swift Package Manager | Guide |
import { AgentKernel } from "agentkernel";
const client = new AgentKernel();
// Run a command in a temporary sandbox
const result = await client.run(["python3", "-c", "print(1+1)"]);
console.log(result.output); // "2\n"
// Sandbox session with automatic cleanup
await using sandbox = await client.sandbox("my-session");
await sandbox.exec(["npm", "install"]);
const tests = await sandbox.exec(["npm", "test"]);
All SDKs support sandbox sessions with automatic cleanup, streaming output (SSE), and configuration via environment variables or explicit options. See SDK documentation for all languages.
Why agentkernel?
AI coding agents execute arbitrary code. Running them directly on your machine is risky:
- They can read/modify any file
- They can access your credentials and SSH keys
- Container escapes are a real threat
agentkernel uses Firecracker microVMs (the same tech behind AWS Lambda) to provide true hardware isolation:
| Feature | Docker | agentkernel |
|---|---|---|
| Isolation | Shared kernel | Separate kernel per VM |
| Boot time | 1-5 seconds | <125ms |
| Memory overhead | 50-100MB | <10MB |
| Escape risk | Container escapes possible | Hardware-enforced isolation |
Platform Support
| Platform | Backend | Status |
|---|---|---|
| Linux (x86_64, aarch64) | Firecracker microVMs | Full support |
| Linux (x86_64, aarch64) | Hyperlight Wasm | Experimental |
| macOS 26+ (Apple Silicon) | Apple Containers | Full support (VM isolation) |
| macOS (Apple Silicon, Intel) | Docker | Full support (~220ms) |
| macOS (Apple Silicon, Intel) | Podman | Full support (~300ms) |
| Kubernetes cluster | K8s Pods | Full support |
| Nomad cluster | Nomad Jobs | Full support |
On macOS, agentkernel automatically selects the best available backend:
- Apple Containers (macOS 26+) - True VM isolation, ~940ms
- Docker - Fastest container option, ~220ms
- Podman - Rootless/daemonless, ~300ms
Firecracker and Hyperlight require KVM (Linux only).
Orchestration Backends
Deploy agentkernel on Kubernetes or Nomad for team and cloud environments. Sandboxes run as pods or job allocations with warm pools for fast acquisition.
# Kubernetes
# Nomad
Install with Helm or Nomad Pack:
# Kubernetes (Helm)
# Nomad (job file)
Features: warm pools, NetworkPolicy/network isolation, Kubernetes CRDs (AgentSandbox, AgentSandboxPool), configurable resource limits. See Orchestration docs for details.
Agent Plugins
Use agentkernel with your AI coding agent. The plugin install command sets up MCP server configs, skills, and commands for each agent.
What Gets Installed
| Agent | Files | How It Works |
|---|---|---|
| Claude Code | .claude/skills/agentkernel/SKILL.md, .claude/commands/sandbox.md, .mcp.json |
Skill teaches Claude when/how to sandbox. /sandbox command for explicit use. MCP server provides tools. |
| Codex | .mcp.json |
MCP server provides run_command, create_sandbox, exec_in_sandbox tools. |
| Gemini CLI | .gemini/settings.json |
MCP server provides sandbox tools via Gemini's MCP integration. |
| OpenCode | .opencode/plugins/agentkernel.ts |
TypeScript plugin auto-creates session sandboxes. Requires agentkernel serve. |
| Generic MCP | .mcp.json |
Works with any MCP-compatible agent. |
Usage in Claude Code
Once installed, Claude uses agentkernel for isolated execution:
/sandbox python3 -c "print('Hello from sandbox!')"
/sandbox npm test
/sandbox cargo build
Performance
| Mode | Platform | Latency | Use Case |
|---|---|---|---|
| Hyperlight Pool | Linux | <1µs | Sub-microsecond with pre-warmed runtimes (experimental) |
| Hyperlight (cold) | Linux | ~41ms | Cold start Wasm runtime |
| Daemon (warm pool) | Linux | 195ms | API/interactive - fast with full VM isolation |
| Docker | macOS | ~220ms | macOS development (fastest) |
| Podman | macOS | ~300ms | macOS development (rootless) |
| Podman | Linux | ~310ms | Linux without KVM (fastest, daemonless) |
| Docker | Linux | ~350ms | Linux without KVM |
| Firecracker (cold) | Linux | ~800ms | One-off commands |
See BENCHMARK.md for detailed benchmarks and methodology.
Daemon Mode (Linux)
For the fastest execution on Linux, use daemon mode to maintain a pool of pre-warmed VMs:
# Start the daemon (pre-warms 3 VMs)
# Run commands (uses warm VMs - ~195ms latency)
# Check pool status
# Output: Pool: Warm VMs: 3, In use: 0, Min/Max: 3/5
# Stop the daemon
The daemon maintains 3-5 pre-booted Firecracker VMs. Commands execute in ~195ms vs ~800ms for cold starts - a 4x speedup.
Hyperlight Backend (Linux, Experimental)
Hyperlight uses Microsoft's hypervisor-isolated micro VMs to run WebAssembly with dual-layer security (Wasm sandbox + hypervisor boundary). This provides the fastest isolation with ~68ms latency.
Requirements:
- Linux with KVM (
/dev/kvmaccessible) - Build with
--features hyperlight
# Build with Hyperlight support
# Run Wasm modules (experimental)
Key differences from Firecracker:
- Runs WebAssembly modules only (not arbitrary shell commands)
- ~68ms startup vs 195ms daemon mode (2.9x faster)
- Sub-millisecond function calls after runtime is loaded
- Requires AOT-compiled Wasm modules for best performance
See BENCHMARK.md for detailed Hyperlight benchmarks.
When to use daemon mode:
- Running an API server
- Interactive development
- Many sequential commands
- Low latency requirements
When to use ephemeral mode:
- One-off commands
- Clean VM per execution
- Memory-constrained environments
Documentation
- Getting Started - Installation, quick start, benchmarks
- Commands - Full CLI reference
- Features - Desktop app, browser automation, secrets, durable objects
- Agents - Claude Code, OpenCode, Codex, Gemini, and more
- Configuration -
agentkernel.toml, security profiles, backends - API - HTTP API and MCP server
- SDKs - Node.js, Python, Go, Rust, Swift
- Operations - Kubernetes, Nomad, deployment
- Changelog
Examples
See the examples/ directory for language-specific configurations: