How Castari Works
Understand how Castari deploys and runs your agents.
Architecture Overview
┌─────────────┐ ┌──────────────────┐ ┌─────────────┐
│ You │ │ Castari API │ │ E2B │
│ (CLI/SDK) │ ───▶ │ (Control Plane) │ ───▶ │ Sandboxes │
└─────────────┘ └──────────────────┘ └─────────────┘
│
┌─────────┼─────────┐
▼ ▼ ▼
PostgreSQL Redis Clerk Auth
Control Plane — Manages agents, secrets, invocations, and usage tracking.
E2B Sandboxes — Isolated execution environments where your agents run.
Deployment Flow
When you run cast deploy:
Upload Code
Your agent code is uploaded to Castari (or cloned from git).
Create Sandbox
An isolated E2B sandbox is created for your agent.
Install Dependencies
npm install runs inside the sandbox.
Inject Secrets
Any secrets you’ve set become environment variables.
Ready
Agent status becomes active. Ready to invoke.
Invocation Flow
When you run cast invoke:
Request Received
Your prompt is sent to the Castari API.
Sandbox Activated
A fresh sandbox is spun up for this request.
Agent Runs
Your agent code executes with the prompt as input.
Response Collected
Output is captured and returned to you.
Cleanup
Sandbox is destroyed. No state persists.
Per-Request Scaling
Every invocation gets a fresh sandbox. This means:
- No state leaks — Each request is isolated
- True security — No cross-request data exposure
- Automatic scaling — Parallel invocations run in parallel sandboxes
- No cold starts — Sandboxes are pre-warmed
Agent Entry Point Contract
Your agent communicates via stdin/stdout:
Input: prompt → stdin
Output: response → stdout
Example:
// Read prompt from stdin
let prompt = "";
for await (const chunk of process.stdin) {
prompt += chunk;
}
// Process and respond
const response = await runAgent(prompt);
// Write to stdout
console.log(response);
Security Model
| Layer | Protection |
|---|
| Sandbox | Isolated E2B container |
| Network | Egress allowed, no ingress |
| Secrets | Encrypted at rest, injected at runtime |
| Code | Your code, your sandbox, not shared |
Resource Limits
| Resource | Limit |
|---|
| Memory | 2 GB |
| CPU | 2 cores |
| Timeout | 120 seconds |
| Disk | 10 GB |
Contact us if you need higher limits for production workloads.
See Also