Architecture
Khala has three planes. The control plane is the panel, its API and the tool gateway: where agents are defined, governed and observed. The build plane is where code is written and checked. The runtime plane is where deployed agents and hosted MCP servers run. They are separate on purpose: the build and runtime planes run code in sandboxes and have no direct path to the control plane’s database.
Nothing in the build or runtime plane is a virtual machine per agent. Sandboxes are packed onto a shared pool of nodes, and the ones that sit idle are paused with their state saved, so capacity follows what is active at the same time, not what is deployed.
This page is the reference architecture that the three deployment modalities follow: SaaS, BYOC and on-premise.
Users
Your network or the internet
- Web panel
- Desktop panel
Control plane
Stateless API, one database
- Khala API
- Tool gateway
- PostgreSQL 18
- Email provider (SMTP)
Build plane
Kubernetes
- Build orchestrator
- Build sandbox pool
- Egress gateway
Runtime plane
Kubernetes
- Deployed agents
- Hosted MCP servers
- Object storage for paused state
Your systems
Reached only through the egress gateway
- Git host
- Secret manager
- Model endpoints
- MCP servers
Control plane
Section titled “Control plane”| Component | What it is | State |
|---|---|---|
| Panel | A static web application, also packaged as a desktop application | None on the server |
| API | One Go binary serving HTTPS under /v1. Generated from an OpenAPI contract, which it also serves at /openapi.json |
Stateless; scales horizontally |
| Tool gateway | The single path for every call from an agent to a tool. Applies policies and approvals, attaches credentials, records each call. Serves MCP servers built from OpenAPI. See Hosted MCP servers and tool gateway | None |
| Database | PostgreSQL 18. Holds all tenant data, sessions and sign-in challenges | The only stateful component |
| Any SMTP provider, for sign-in codes | External |
There is no cache server and no message broker. Sign-in rate limits are counted in the database, so they hold across several API instances.
Build plane
Section titled “Build plane”| Component | What it does |
|---|---|
| Build orchestrator | Drives the six steps of a build, enforces budgets, survives restarts |
| Sandbox pool | Runs one isolated sandbox per build on Kubernetes |
| Egress gateway | The only way out of a sandbox. Enforces the allowlist of each build and attaches credentials to outbound requests |
| Object storage | Holds snapshots of paused sandboxes, so a build waiting for a person uses no compute |
Runtime plane
Section titled “Runtime plane”| Component | What it does |
|---|---|
| Runtime pool | Runs each deployed agent and each hosted MCP server in its own isolated sandbox, many sandboxes per node |
| Pausing and resuming | A sandbox nobody has called for a while is paused: its memory and files are saved to object storage and its node is freed. The next request resumes it. Latency-sensitive agents can be kept warm |
| Isolation by risk | Low and medium risk run on an isolated user-space kernel; critical risk on hardware virtualisation |
| Object storage | Holds the saved state of paused agents and servers |
| From | To | Protocol | Purpose |
|---|---|---|---|
| Panel | API | HTTPS | Everything a user does |
| API | PostgreSQL | TLS | Data |
| API | SMTP provider | SMTP with TLS | Sign-in codes |
| API | Build orchestrator | Internal | Start, follow and cancel builds |
| Sandbox | Egress gateway | Mutually authenticated | Every outbound request |
| Egress gateway | Model endpoint | HTTPS | Inference |
| Egress gateway | Git host | HTTPS | Clone, push, pull request |
| Egress gateway | Package registries | HTTPS | Build dependencies |
| Agent sandbox | Tool gateway | Mutually authenticated | Every tool call |
| Tool gateway | MCP servers: hosted, by URL, or the API behind an OpenAPI server | HTTPS | Tool calls, with credentials attached |
| Users and systems | Deployed agents | HTTPS | Invoking an agent |
| Control plane | Secret manager | HTTPS | Resolve credential references |
No component accepts inbound connections from a sandbox except the egress gateway and, for tool calls, the tool gateway.
Trust boundaries
Section titled “Trust boundaries”- Browser or desktop ↔ API. Authenticated session, role checked per operation, origin allowlist.
- API ↔ database. Every query is filtered by the organization of the session.
- Control plane ↔ build and runtime planes. They receive what one build or one deployment needs and return results. They hold no database credentials.
- Sandbox ↔ everything. Denied by default. See Sandbox security.
- Agent ↔ tools. Only through the tool gateway, which applies your policies on every call.