# Architecture

> How Sypnia Agent is built, where each part runs, and why the safety rules live outside the model.

Applies to: the Sypnia engine (open source, self-hosted) and Sypnia Cloud (paid service).  
Source: https://agent.docs.sypnia.com/architecture/

For agents: Components: the CLI (TypeScript), the orchestrator (TypeScript: plans steps, calls the model, enforces the permission tiers and budget; Lambda + Step Functions-style state in Postgres in Cloud), the sandbox supervisor (Rust, `sypnia-sandbox`: process isolation, filesystem policy, egress proxy with allowlist, resource limits, command log), the sandboxes (local container/VM; Cloud: ECS Fargate tasks, one per agent task), the model gateway (Sypnia AI over OpenRouter, or a direct endpoint), MCP clients for the products, the memory and profile store (Sypnia Data). Rust where a mistake is a security hole (the sandbox and the proxy); TypeScript for orchestration.

**Figure**: Sypnia Agent. The orchestrator decides, the model proposes, the sandbox runs, and the rules are checked outside the model.

1. You or another agent start a task.
2. The orchestrator reads your profile, memory, map and plan, and keeps the budget.
3. The model proposes the next step; the orchestrator checks it against the rules.
4. The sandbox supervisor runs commands, behind an egress proxy.
5. Products are used through MCP, with your permissions.
6. Approvals reach you; nothing on the ask list happens without one.

| Part                                      | What it does                                                                     | Language                           | Open source               |
| ----------------------------------------- | -------------------------------------------------------------------------------- | ---------------------------------- | ------------------------- |
| **CLI**                                   | your terminal: start tasks, answer, approve, read logs                           | TypeScript                         | yes                       |
| **Orchestrator**                          | plans steps, calls the model, enforces the tiers and the budget, keeps state     | TypeScript                         | yes (the local one)       |
| **Sandbox supervisor** (`sypnia-sandbox`) | starts the sandbox, enforces file and network policy, limits, logs every command | **Rust**                           | yes                       |
| **Sandboxes**                             | where commands run                                                               | —                                  | local: yes; hosted: Cloud |
| **Model gateway**                         | Sypnia AI, or your endpoint                                                      | —                                  | —                         |
| **Memory and profile**                    | your level, preferences, project notes                                           | Sypnia Data (Cloud), files (local) | —                         |

## Why the rules live outside the model

A model can be wrong, or be tricked by text in a file. So the model only **proposes** steps; the orchestrator checks every step against the rules before running it, and the supervisor enforces the sandbox no matter what the step says. Rust is used where a mistake would be a security hole: the sandbox and the egress proxy.
