Stop Rewriting Agent Integrations! Use sandbox-agent Instead
Stop Rewriting Agent Integrations! Use sandbox-agent Instead
What if I told you that every hour your team spends rebuilding agent integrations is an hour stolen from shipping actual product? Here's the dirty secret nobody talks about: coding agents are eating software development alive, but we're all duct-taping our own fragile bridges to control them. Claude Code works one way. Codex demands another. OpenCode, Cursor, Amp, Pi — each speaks its own proprietary dialect, expects its own terminal rituals, and breaks in its own spectacular ways when you try to run it remotely.
And the worst part? You know this pain intimately. You've SSH'd into a sandbox, watched TTY handling implode, seen streaming output vanish into the void. You've built custom wrappers that work until the next agent update. You've lost entire session transcripts because the process died and took everything with it. The current state of remote agent control is a graveyard of abandoned integration branches and 3 AM debugging sessions.
Enter sandbox-agent — the universal HTTP server that runs inside your sandbox and turns agent chaos into one clean API. No more rewriting integrations. No more SSH nightmares. No more lost sessions. One binary. One interface. Six agents. Infinite sandboxes. This is how remote agent control should have worked from day one.
What is sandbox-agent?
sandbox-agent is an open-source Rust server developed by Rivet that creates a universal HTTP + SSE bridge between your applications and popular coding agents. Rather than building custom integrations for each agent's proprietary API, you deploy one lightweight binary inside any sandbox environment — E2B, Daytona, Modal, Cloudflare Containers, Agent Computer, Docker↗ Bright Coding Blog, or your own infrastructure — and control everything remotely via a standardized REST API.
The project emerged from Rivet's own struggles running autonomous coding agents at scale. They observed three critical failures in existing approaches: SDKs assuming local execution (useless for isolated production environments), every agent implementing incompatible interfaces (forcing constant rewrites), and ephemeral sessions destroying valuable audit trails. Their solution? A universal adapter pattern that normalizes agent behavior behind a single OpenAPI-specified HTTP interface.
What makes sandbox-agent genuinely exciting is its adapter architecture. Each supported agent — Claude Code, Codex, OpenCode, Cursor, Amp, and Pi — gets a dedicated translation layer that handles the messy reality of process spawning, TTY negotiation, event format conversion, and streaming normalization. Your application speaks one language. The adapters handle the polyglot chaos behind the scenes.
The project is actively maintained with a public roadmap including Python↗ Bright Coding Blog SDK support, automatic MCP configuration, and enhanced todo list management. The experimental Gigacode feature even lets you drive any coding agent through OpenCode's familiar TUI interface — imagine using Codex with OpenCode's interface, or Claude Code with Cursor's shortcuts.
Key Features That Change Everything
Universal Agent API with Full Feature Parity
This isn't a lowest-common-denominator abstraction that strips away agent capabilities. sandbox-agent provides complete feature coverage across all six supported agents. Claude Code's sophisticated tool use? Preserved. Codex's reasoning traces? Normalized and streamed. OpenCode's session management? Fully accessible. You swap agents by changing a string in your config, not by rewriting integration logic.
Universal Session Schema for Eternal Auditability
Every event — tool calls, file modifications, command executions, reasoning steps — streams through a standardized JSON schema. Push to Postgres for relational querying. Flood ClickHouse for analytics. Pipe into Rivet Actors for real-time processing. When the agent process terminates, your complete transcript survives. Compliance teams rejoice. Debuggers celebrate.
Zero-Dependency Rust Binary
One curl command installs a static binary that starts in milliseconds with predictable memory footprint. No Node.js runtime to ship. No Python environment to configure. No Docker image bloat. This matters enormously in sandbox environments where every megabyte and startup second counts.
Dual Operation Modes
Run as a standalone HTTP server for polyglot environments, or embed directly via the TypeScript SDK for Node.js and browser applications. The SDK provides full type safety and native streaming support — no polling hacks, no WebSocket complexity.
Built-In Inspector UI
Debug sessions visually at http://localhost:2468/ui/. Watch events flow in real-time, inspect message histories, and diagnose agent behavior without parsing JSON logs. This is the observability layer that coding agents desperately needed.
OpenCode Compatibility Layer (Experimental)
Leverage existing OpenCode tooling — CLI, SDK, even the web UI — to control any supported agent. This dramatically reduces onboarding friction for teams already invested in the OpenCode ecosystem.
Real-World Use Cases Where sandbox-agent Dominates
Autonomous Code Review Pipelines
Imagine triggering Claude Code to analyze pull requests inside isolated E2B sandboxes. sandbox-agent streams every reasoning step, file access, and suggestion to your audit pipeline. Security teams review complete transcripts. Developers receive structured feedback. The sandbox destroys itself after analysis — zero persistent attack surface.
Multi-Agent Orchestration Platforms
Build systems that route tasks to optimal agents dynamically. Complex refactoring? Spawn Claude Code. Quick API integration? Deploy Codex. Legacy codebase exploration? Unleash Cursor. All through identical HTTP calls. Your orchestrator doesn't care which agent executes — it just requests capabilities and receives normalized events.
Compliance-Heavy Enterprise Environments
Financial services and healthcare organizations can't let AI agents run unmonitored on production infrastructure. sandbox-agent deploys inside certified sandbox providers, streams complete session records to immutable storage, and maintains separation between agent execution and sensitive systems. Auditors get timestamps. Regulators get transparency.
Educational Coding Platforms
Teach AI-assisted development without exposing students to arbitrary code execution risks. Each learner gets an isolated sandbox with sandbox-agent providing controlled agent access. Instructors observe sessions in real-time via the Inspector UI. Platform builders integrate once, offer multiple agent choices instantly.
Step-by-Step Installation & Setup Guide
Server Installation (Any Sandbox)
The fastest path to production deployment:
# One-line installation — works on any Linux environment
curl -fsSL https://releases.rivet.dev/sandbox-agent/0.4.x/install.sh | sh
# Start the server with authentication
sandbox-agent server --token "$SANDBOX_TOKEN" --host 127.0.0.1 --port 2468
# Or disable auth for local development (never in production!)
sandbox-agent server --no-token --host 127.0.0.1 --port 2468
Pre-install agent binaries to avoid lazy-loading delays on first use:
sandbox-agent install-agent --all
TypeScript SDK Installation
For Node.js and browser integrations:
# npm installation
npm install sandbox-agent@0.4.x
# Bun installation with native binary permissions
bun add sandbox-agent@0.4.x
bun pm trust @sandbox-agent/cli-linux-x64 @sandbox-agent/cli-linux-arm64 @sandbox-agent/cli-darwin-arm64 @sandbox-agent/cli-darwin-x64 @sandbox-agent/cli-win32-x64
CLI Wrapper Installation
# Global npm install
npm install -g @sandbox-agent/cli@0.4.x
# Or use without installing
npx @sandbox-agent/cli@0.4.x --help
bunx @sandbox-agent/cli@0.4.x --help
Skill-Based Installation
For modern skill registry workflows:
npx skills add rivet-dev/skills -s sandbox-agent
bunx skills add rivet-dev/skills -s sandbox-agent
Environment Configuration
Extract existing credentials from your local agent configurations for sandbox testing:
# Prints exportable environment variables for OpenAI, Anthropic, etc.
sandbox-agent credentials extract-env --export
Critical Security Note: Always use authenticated server mode in production. The --no-token flag is exclusively for local development. Rotate tokens regularly and inject them via your secrets manager, never hardcoded.
REAL Code Examples from the Repository
Example 1: SDK Embedded Mode — Local Agent Control
The simplest possible integration runs agents as local subprocesses through the TypeScript SDK:
import { SandboxAgent } from "sandbox-agent";
// Start embedded server — spawns agent processes locally
const client = await SandboxAgent.start();
// List available agents (Claude Code, Codex, OpenCode, etc.)
const agents = await client.listAgents();
console.log("Available agents:", agents);
// Create a named session with specific agent configuration
await client.createSession("demo", {
agent: "codex", // Target agent — change to "claude-code", "opencode", etc.
agentMode: "default", // Agent-specific mode (varies by agent)
});
// Send a message to the session
await client.postMessage("demo", {
message: "Hello from the SDK."
});
// Stream all events with automatic reconnection from offset 0
for await (const event of client.streamEvents("demo", { offset: 0 })) {
// event.type: "message", "tool_call", "command_execution", etc.
// event.data: normalized payload regardless of source agent
console.log(event.type, event.data);
}
What's happening here? SandboxAgent.start() launches the Rust binary as a managed subprocess, establishes a local HTTP connection, and returns a typed client. The createSession call initializes a specific agent with its required environment. The streamEvents generator yields normalized events — identical structure whether Claude Code or Codex generated them. The offset: 0 parameter enables resume after disconnections, crucial for long-running agent tasks.
Example 2: SDK Server Mode — Remote Sandbox Connection
Connect to sandbox-agent running in cloud infrastructure:
import { SandboxAgent } from "sandbox-agent";
// Connect to remote sandbox-agent server
const client = await SandboxAgent.connect({
baseUrl: "http://127.0.0.1:2468", // Your sandbox's exposed endpoint
token: process.env.SANDBOX_TOKEN, // Authentication token from secrets manager
});
// Identical API to embedded mode — true portability
const agents = await client.listAgents();
await client.createSession("production-task", {
agent: "claude-code",
agentMode: "default",
});
The power of this pattern: Your application code doesn't change between local development and production deployment. Swap start() for connect(), update the baseUrl, and identical logic runs against a sandbox in E2B, Daytona, or your Kubernetes cluster. This is the "write once, deploy anywhere" promise actually delivered.
Example 3: CLI Session Management
Automate agent workflows from shell scripts and CI pipelines:
# Create a new session specifying agent and remote endpoint
sandbox-agent api sessions create my-session \
--agent codex \
--endpoint http://127.0.0.1:2468 \
--token "$SANDBOX_TOKEN"
# Send a single message (blocking)
sandbox-agent api sessions send-message my-session \
--message "Refactor the authentication module to use JWT" \
--endpoint http://127.0.0.1:2468 \
--token "$SANDBOX_TOKEN"
# Send with streaming output (real-time progress)
sandbox-agent api sessions send-message-stream my-session \
--message "Generate comprehensive tests for the payment API" \
--endpoint http://127.0.0.1:2468 \
--token "$SANDBOX_TOKEN"
When to use this: The CLI excels in CI/CD pipelines, infrastructure-as-code deployments, and operational runbooks. The send-message-stream variant is essential for long-running tasks where you need real-time progress visibility. Parse the streaming JSON for automated decision-making — abort on error patterns, continue on success indicators.
Example 4: Complete Session Lifecycle with Event Streaming
import { SandboxAgent } from "sandbox-agent";
async function runAutonomousTask(agentType: string, instruction: string) {
const client = await SandboxAgent.connect({
baseUrl: process.env.SANDBOX_AGENT_URL!,
token: process.env.SANDBOX_TOKEN!,
});
// Generate unique session ID with timestamp
const sessionId = `task-${Date.now()}`;
// Initialize session with full configuration
await client.createSession(sessionId, {
agent: agentType,
agentMode: "default",
});
// Dispatch the primary instruction
await client.postMessage(sessionId, { message: instruction });
// Collect all events for persistence
const events = [];
for await (const event of client.streamEvents(sessionId, { offset: 0 })) {
events.push(event);
// Real-time processing: react↗ Bright Coding Blog to specific event types
if (event.type === "tool_call" && event.data.name === "execute_command") {
console.warn(`Agent executing: ${event.data.arguments.command}`);
}
// Detect completion or error states
if (event.type === "session_end" || event.type === "error") {
break;
}
}
// Persist to your storage (Postgres, ClickHouse, S3, etc.)
await persistToStorage(sessionId, events);
// Cleanup: session data remains in agent's disk, but our transcript is safe
return { sessionId, eventCount: events.length };
}
// Execute with different agents using identical logic
await runAutonomousTask("codex", "Implement OAuth2 flow");
await runAutonomousTask("claude-code", "Debug memory leak in worker pool");
This pattern solves the ephemeral session problem permanently. Even if the sandbox terminates immediately after execution, your complete event transcript exists in external storage with full fidelity. Replay sessions for debugging, train models on successful patterns, or audit compliance requirements — all from normalized data that never depended on agent-specific formats.
Advanced Usage & Best Practices
Agent Selection Strategies: Don't default to one agent. Build capability-based routing — Claude Code for complex architectural decisions, Codex for rapid implementation, Cursor for codebase exploration. The config-change swap means A/B testing agents costs zero integration effort.
Event Stream Processing: The universal schema enables sophisticated downstream processing. Filter tool_call events for security monitoring. Aggregate file_modification events for automatic documentation generation. Transform reasoning events into training data for fine-tuned models.
Sandbox Provider Optimization: Each provider has unique characteristics. E2B offers exceptional cold-start speed for ephemeral tasks. Daytona provides persistent volumes for long-running sessions. Modal scales horizontally for concurrent agent execution. Match your deployment target to your workload pattern.
Credential Isolation: Never mount host credentials into sandboxes. Use sandbox-agent credentials extract-env to generate scoped tokens, inject via environment variables, and rotate aggressively. The extracted credentials are ephemeral by design — perfect for CI environments.
Inspector Integration: Enable the Inspector UI in development and staging for rapid debugging. The visual event stream reveals agent decision patterns invisible in logs. Share Inspector URLs with team members for collaborative debugging sessions.
Comparison with Alternatives
| Capability | sandbox-agent | Official Agent SDKs | Raw SSH | Vercel AI SDK |
|---|---|---|---|---|
| Remote Sandbox Execution | ✅ Native HTTP | ❌ Local only | ⚠️ Fragile TTY | ❌ LLM-only |
| Multi-Agent Support | ✅ 6 agents, 1 API | ❌ 1 SDK per agent | ❌ Manual per agent | ❌ No agents |
| Session Persistence | ✅ Universal streaming | ❌ Process-bound | ❌ Manual capture | ❌ N/A |
| TypeScript/Node SDK | ✅ Full type safety | ⚠️ Varies | ❌ None | ✅ Yes |
| Browser Compatibility | ✅ HTTP/SSE | ❌ No | ❌ No | ✅ Yes |
| Startup Time | ✅ <100ms Rust | ⚠️ Runtime-dependent | ⚠️ Connection overhead | ✅ Fast |
| TTY Handling | ✅ Perfect streaming | ✅ Native | ❌ Broken | N/A |
| Agent Feature Parity | ✅ Complete | ✅ Complete | ⚠️ Partial | ❌ N/A |
The verdict: Official SDKs work beautifully for local experimentation. Vercel AI SDK excels at building chat interfaces around LLMs. But when you need production-grade remote agent control with isolation, auditability, and multi-agent flexibility, sandbox-agent occupies a unique position that nothing else currently fills.
FAQ: What Developers Actually Ask
Does sandbox-agent replace the Vercel AI SDK?
Absolutely not — they're complementary tools for different layers. AI SDK orchestrates LLM conversations and renders chat UIs. sandbox-agent controls autonomous coding agents that write files, execute commands, and modify codebases. Use AI SDK for user-facing chat, sandbox-agent for backend automation.
Which coding agents work right now?
Claude Code, Codex, OpenCode, Cursor, Amp, and Pi are fully supported with normalized APIs. The experimental Gigacode feature adds OpenCode TUI compatibility across all agents.
How do I persist session data?
sandbox-agent streams normalized events via SSE — you capture and store them. The documentation provides patterns for Postgres, ClickHouse, and Rivet Actors. The SDK intentionally doesn't dictate storage, maximizing deployment flexibility.
Can I develop locally before deploying to sandboxes?
Yes — the embedded mode runs agents as local subprocesses with identical APIs. Develop locally, deploy to E2B/Daytona/Modal for production without code changes.
What platforms support deployment?
Any Linux environment running the static binary: Docker containers, E2B sandboxes, Daytona workspaces, Modal functions, Cloudflare Containers, Vercel Sandboxes, Agent Computer instances, or bare VMs.
How do I use personal API keys in sandboxed environments?
Run sandbox-agent credentials extract-env --export to extract keys from your local agent configurations. Pipe the output into your sandbox's environment configuration for seamless authenticated testing.
Why Rust instead of TypeScript or Python?
Static binary distribution, sub-100ms startup, and predictable memory usage. In sandbox environments where you pay for execution time and memory, Rust's efficiency translates directly to cost savings and faster scaling.
Why avoid SSH for remote agent control?
Coding agents require interactive terminals with proper TTY handling for tool confirmations, streaming output, and human-in-the-loop flows. SSH with piped commands breaks all of these critical interactions. HTTP provides clean, observable, retryable communication.
Conclusion: The Future of Agent Infrastructure Is Here
The coding agent revolution is unstoppable, but our infrastructure for controlling it has been embarrassingly primitive. We've accepted SSH hacks, proprietary SDK lock-in, and lost session data as inevitable costs of doing business with AI that writes code. sandbox-agent exposes these as false constraints.
This is infrastructure that respects your time. One integration effort unlocks six agents. One deployment pattern works across every sandbox provider. One event schema preserves every interaction for analysis and audit. The Rust binary starts faster than you can blink. The TypeScript SDK feels native in modern applications. The Inspector UI finally makes agent behavior observable.
For teams building autonomous development tools, compliance platforms, or educational environments, sandbox-agent isn't a nice-to-have — it's the difference between shipping in weeks versus months, between secure operations and dangerous exposures, between strategic flexibility and vendor lock-in.
Stop rewriting agent integrations. Start building what matters.
👉 Get sandbox-agent on GitHub — star the repo, read the docs at sandboxagent.dev, and join the Discord community to shape the roadmap. The Python SDK is coming, automatic MCP configuration is in progress, and this is just the beginning of universal agent infrastructure.
Your future self — the one not debugging SSH at 3 AM — will thank you.
Outils recommandés
Explore on the BrightCoding network
Hand-picked resources from our other sites.
wesm/agentsview: Local-First Analytics for AI Coding Agent Costs
wesm/agentsview is a local-first, MIT-licensed Go binary that discovers, indexes, and analyzes sessions from 25+ AI coding agents including Claude Code and Code...
rsclaw-ai/rsclaw: 15MB Rust Binary for Persistent AI Agents
rsclaw-ai/rsclaw is a Rust-built AI agent engine with three-layer persistent memory, 15 LLM providers, A2A v1.0 cross-machine orchestration, and a 15MB static b...
Stop Tethering to Your Terminal! Claude-to-IM Skill Unleashed
Bridge Claude Code and Codex to Telegram, Discord, WeChat & more with Claude-to-IM skill. Chat with AI coding agents from anywhere, with full permission control...
Continuez votre lecture
Why Alexandrie is the Ultimate Markdown Note-Taking App
Why CrossPaste is the Ultimate Game Changer for Clipboard Management
Why Chandra is the Ultimate OCR Tool for Handwriting and Tables
Stop Coding Alone: OPC-Skills Gives Your AI Agent Superpowers
Commentaires 0
Aucun commentaire pour l'instant. Soyez le premier à réagir !