AI Employees

How AI Employees Actually Work: The 3-Layer Architecture

A technical deep dive into the 3-layer architecture: Executive planning, Reasoning specialists, and persistent Context memory.

By Hitank Shah • 7 min read • Updated 2026-11-08

Direct Answer (Quick Summary)

An AI employee works through a coordinated 3-layer architecture: an Executive Layer that plans and scopes tasks, a Reasoning Layer that invokes MCP tools and executes code inside isolated Docker sandboxes, and a Memory Layer that retrieves institutional context and persists session outcomes.

Key Takeaways

  • 3-layer decoupled design: Executive (strategy), Reasoning (execution), and Memory (state).
  • Execution isolation inside dedicated Docker sandboxes guarantees zero host side-effects.
  • Model Context Protocol (MCP) provides universal, authenticated tool discovery and execution.
  • Approval pitstops interrupt runtime execution before high-risk external state mutations.
  • Strict token metering and per-session USD circuit breakers prevent cost blowouts.
  • The durable state lives outside the model: Postgres, the queue, the encrypted vault, the vector store and the cost ledger.

Beyond the Single Prompt-Response Loop

A standard LLM like Claude or GPT-4 is a stateless mathematical function: you send input tokens, it returns output tokens, and immediately forgets everything that happened.

To turn that foundation model into a dependable AI Employee, you have to build an engineering control plane around it. In OneCo, that control plane is the 3-Layer Execution Runtime.

┌────────────────────────────────────────────────────────────────────────┐
│                        AI EMPLOYEE CONTROL PLANE                       │
├────────────────────────────────────────────────────────────────────────┤
│                                                                        │
│   ┌────────────────────────────────────────────────────────────────┐   │
│   │ 1. EXECUTIVE LAYER                                             │   │
│   │    • Deconstructs high-level business goals into sub-tasks     │   │
│   │    • Synthesizes skills, policies, and organizational hierarchy │   │
│   │    • Sets iteration budgets and selects primary models         │   │
│   └────────────────────────────────┬───────────────────────────────┘   │
│                                    │                                   │
│   ┌────────────────────────────────▼───────────────────────────────┐   │
│   │ 2. REASONING & EXECUTION LAYER                                 │   │
│   │    • Claude Code / OESA tool-use iterative loop                │   │
│   │    • Invokes MCP connectors (Stripe, GitHub, PostgreSQL)       │   │
│   │    • Runs bash & code in isolated Docker Sandboxes             │   │
│   │    • Triggers Approval Pitstops on risky commands              │   │
│   └────────────────────────────────┬───────────────────────────────┘   │
│                                    │                                   │
│   ┌────────────────────────────────▼───────────────────────────────┐   │
│   │ 3. PERSISTENT CONTEXT & MEMORY LAYER                           │   │
│   │    • Hybrid vector search over company wikis and Notion docs   │   │
│   │    • Episodic session summarization & institutional memory     │   │
│   │    • Token usage metering & wallet balance reconciliation      │   │
│   └────────────────────────────────────────────────────────────────┘   │
│                                                                        │
└────────────────────────────────────────────────────────────────────────┘

Why all three? Because each one solves a problem the model cannot solve by itself. This is the short version of why models alone are not enough for enterprise AI.


Layer 1: The Executive Planning Engine

When a task arrives — "Audit Q3 cloud spending and file Jira tickets for any cluster exceeding $5,000/mo" — an AI employee does not immediately fire off API requests.

The Executive Layer:

  1. Assembles the execution context: fetches the employee's role instructions, active skill definitions, organizational policies, and relevant credentials from the encrypted vault.
  2. Generates an execution DAG: outlines the sequential and parallel tasks required to achieve the outcome.
  3. Applies policy filters: enforces organizational boundaries, such as "read-only access to AWS production; human approval required before filing public Jira tickets."

This layer is what makes assigning work to AI employees a management activity rather than a prompt-authoring activity. It is also where the hierarchy lives — an executive employee delegates to reasoning employees, exactly as a department head delegates to analysts.


Layer 2: The Reasoning Engine and Docker Sandboxes

Once the plan exists, control transitions to the Reasoning Layer.

Unlike web chatbots running in shared browser threads, an enterprise AI employee operates inside an isolated Docker container:

  • Ephemeral workspaces — each run provisions a dedicated filesystem container mounted with only the directories that run requires.
  • Safe bash execution — the employee can compile code, run tests, install packages, and inspect logs.
  • Regex-hardened safety boundaries — every command is evaluated against strict safety rules before execution. Destructive operations (rm -rf, sudo privilege escalation, outbound socket creation) halt execution and trigger an Approval Gate.

Tool integration is managed universally through the Model Context Protocol, letting the worker interact with GitHub, Supabase, Salesforce, and custom REST APIs over standard JSON-RPC. That is covered in detail in what MCP is and why it matters, and the practical implications for an enterprise rollout are in how MCP connections change enterprise AI.


Layer 3: Persistent Memory and Financial Governance

What turns an agent into an employee is the ability to remember past work and stop asking the same question twice.

  1. Episodic summarization — at the end of every session, an automated pass extracts key learnings, resolved ambiguities, and configuration state into the employee's permanent memory store.
  2. Semantic knowledge retrieval — vector embeddings match historical resolutions, so future tasks reuse past context immediately.
  3. Hard USD budgeting — every model call records prompt and completion tokens against a central pricing ledger. If an agent hits a recursive failure mode, execution halts cleanly before breaching the assigned ceiling.

The distinction between a memory layer and a long context window is the subject of persistent context for AI employees.


A Full Run, Step by Step

Here is the trace for a real assignment: "Chase the three invoices over 30 days, propose settlement terms for anything over $2,000, and do not send anything without approval."

#LayerWhat happens
1ExecutiveLoads role, skills, policies, and the Stripe credential handle from the vault
2ExecutiveProduces a DAG: query AR ageing → classify each invoice → draft terms → stage drafts
3ReasoningOpens an MCP session to the billing database, runs a read-only ageing query
4ReasoningResults land in the sandbox; the model reasons over them and drafts three settlement notes
5MemoryRetrieves last quarter's settlement outcomes so the offers match precedent
6ReasoningAny write crosses the approval gate — execution pauses, ticket posted with full diff
7ExecutiveHuman approves two, rejects one with feedback
8MemorySession summary written back; approved terms become precedent for next quarter

Every line in that table is inspectable afterwards. That is what execution observability means in practice.


Where the State Actually Lives

Architecture claims are cheap. Here is the substrate:

StoreHoldsWhy it is separate
Postgres (RLS-scoped)Employees, roles, policies, skills, projects, sessionsDurable, auditable, tenant-isolated
Redis + queueJob payloads, run state, pub/sub events for live streamingEphemeral throughput, survives worker restarts
Encrypted vaultConnector credentialsNever enters the prompt; injected at call time
Vector storeEmbeddings of docs and past sessionsRetrieval by meaning, not keyword
Cost ledgerPer-session token counts and USDReconciles against provider invoices

The reasoning layer is deliberately the least important part of that list. Swapping the model on an employee should be a configuration change, not a rewrite — which is the argument in AI models versus AI operating systems.


Failure Modes and What the Runtime Does

Real systems fail. These are the ones that matter and the behaviour they produce:

FailureDetectionRuntime response
Tool API 500 or timeoutHTTP status from MCP callRetry with exponential backoff, then re-plan around the missing step
Malformed tool responseSchema validation on the JSON-RPC payloadAsk the model to re-issue; log the bad payload for the trace
Recursive retry loopRun-level iteration counterHard stop before the USD ceiling is reached
Destructive or privileged commandPre-execution command matcherHalt and raise an approval ticket
Hallucinated identifierReconciliation against the source recordTask fails loudly rather than writing a plausible wrong value

That last row is the one teams underestimate. The failure you must engineer against is not an error message — it is a confident, well-formatted, wrong value.


Why the Layers Are Decoupled at All

An obvious alternative is a single agent that plans, executes, and remembers in one context. It is simpler to build and it is why most prototypes stop where enterprise work does not.

Decoupling buys three specific things:

  • Independent failure. A crashed reasoning run does not lose the plan or the institutional memory.
  • Independent substitution. A cheap model can run bulk reasoning while an expensive one handles the executive layer. See when to use one AI employee versus multiple.
  • Independent permissioning. Memory reads and tool writes are not the same privilege level, so they cannot share a credential.

If you are evaluating whether to build or buy this layer yourself, building an AI employee runtime sets out the parts you can reasonably assemble and the parts that quietly become your second product.


The Layer People Ask About Last

Access control is not the reasoning layer's problem. It sits above all three: which employees exist, which permissions each one holds, which connections it may open, and what its spending limit is per run. That control surface is what turns a model into something a security team will approve — see what infrastructure AI employees need for the procurement view.

Sources and further reading

Frequently Asked Questions

Can an AI employee execute malicious code on the host server?

No. Execution happens inside isolated Docker containers running as non-root, with only the specific directories a run requires mounted and outbound network calls restricted to declared connectors. Before any command executes it is matched against safety rules, and destructive operations such as recursive deletes or privilege escalation halt the run and raise an approval ticket instead of continuing.

What happens if a tool API fails or times out during execution?

The reasoning loop catches the error, registers it in the execution trace, and autonomously attempts a fallback or retries with exponential backoff. If the failure repeats, the executive layer re-plans around the missing step rather than retrying the same call forever. A run-level iteration counter stops the loop before the USD ceiling is reached, and a persistent blocker is escalated with the failing payload attached.

How are third-party API keys and secrets protected?

They are stored in an AES-256-GCM encrypted vault and never enter the prompt. The worker resolves a credential handle at call time and injects the value into the outgoing request, so the model sees an identifier rather than a secret. Rotation is a vault operation rather than a code change, and access is scoped per employee, so one employee cannot read another employee's credentials.

Why not just build one agent with a much longer context window?

Because context length is not persistence. A long window still forgets between runs, still has no independent permission boundary between reading company memory and writing to a production system, and still gives you no way to swap a cheap model for an expensive one without rewriting the agent. Decoupling the layers keeps the plan after a crash, separates permissions by layer, and makes cost manageable per role.

Where does an AI employee cost actually get metered?

At the model call. Every request records prompt tokens, completion tokens, and the provider and model used, against the session that triggered it. That ledger is what makes a per-run USD ceiling enforceable rather than aspirational, and it is what lets you reconcile internal spend against the provider invoice instead of trusting either one.

Can a human inspect what an AI employee actually did?

Yes, and it is a design requirement rather than a bonus. Each run keeps an execution trace: the plan, every tool call with arguments and response, retrieved context, any approval requested with the decision and reason, and the final result against the target. Streaming that trace live is what makes long runs tolerable, because you are not watching a black box for twenty minutes.

Related reading