Docs > Getting started
How Dex works
# How Dex works Dex connects three layers into one loop: a **context layer** that turns raw company activity into a structured, permissioned knowledge graph; a **Factory layer** that versions agents, skills, views, and ontology definitions as files; and an **execution layer** that runs agents interactively or on schedules while gating external writes behind human review or explicit policies. ```mermaid flowchart TD Sources["Connected sources<br/>(Slack, Gmail, Linear, Attio, ...)"] --> Datasets["Synced Datasets &<br/>Ontology Mappings"] Datasets --> Graph["Knowledge Graph & Nexus<br/>(Objects, links, observations)"] Factory["Factory (Git)<br/>(AGENT.md, TEAM.md, SKILL.md,<br/>automations, views, ontology)"] --> Apply["Commit & Apply<br/>(validation & projection)"] Graph --> Runtime["Agent Runtime<br/>(dex / claude / codex harness)"] Apply --> Runtime Runtime --> Gate{"Write approval<br/>or Auto Mode?"} Gate -->|Human review| Cards["Pending Actions<br/>(Inbox, Slack, Webhook)"] Gate -->|Policy allows| External["External tools &<br/>Knowledge Graph"] Cards -->|Approved| External External --> Improve["Runs, feedback &<br/>Self-improvement"] Improve -.-> Factory ``` ## 1. Context flows from sources into the knowledge graph When you connect an integration and enable context indexing, Dex syncs selected channels, labels, calendars, repositories, or pages into read-only **Datasets**. Your workspace [ontology](/context/ontology/) maps those dataset rows into typed **Object** records (such as `person`, `company`, or custom types) and timestamped **observations** linked to those records. - **Identity resolution is deterministic.** Cluster keys (for example, normalized email address or domain) merge evidence across tools into one record and fail closed on collisions rather than silently merging unrelated entities. - **Human edits are preserved.** When you or an agent edits a field on a synced record, Dex records a cell edit so future syncs do not overwrite your change. - **Permissions travel with the data.** Every record belongs to a Data Scope (personal, Space, or workspace), and sources like Slack and Notion propagate channel/page reader lists so users and agents only see records they are authorized to read. Agents query this layer directly through the `dex zeta` CLI, read-only SQL views (`o_<object>` and `d_<dataset>`), or saved Views—and fall back to live integration tools when fresh or unsynced data is needed. ## 2. Configuration lives in Factory as versioned files Durable workspace definitions live in [Factory](/factory/), a single Git-backed repository per organization: - **Shared definitions** live under `workspace/` (shared agents, shared skills, ontology YAML files, saved views, source descriptors, and shared knowledge). - **Personal definitions** live under `users/<slug>--<user-id>/` (personal agents, personal skills, memory, knowledge, and lightweight **links** to shared workspace agents or skills). Every edit—whether made in the web UI, by an agent in chat, or via `dex factory` in the CLI—passes through a two-phase **Commit and Apply** pipeline. Commits validate schemas, permissions, and move rules first, then project the committed tree into live runtime tables. OAuth tokens, Access Scopes, run histories, and pending actions never live in Git; they stay in Postgres. ## 3. Agents execute interactively or in the background Every chat turn and automation run executes through a unified, durable turn runtime supporting three selectable [harnesses](/agents/working-with-agents/#harnesses): - **`dex` (default)** — Native multi-agent loop with orchestrator/subagent delegation, deferred tool discovery, and support for browser/desktop tools in interactive sessions. - **`claude`** and **`codex`** — Sandboxed agent harnesses running in E2B sandboxes with direct access to `/workspace/factory`, the `dex` CLI, and durable checkpointing. During a run, Dex assembles only the capabilities authorized for that actor: 1. **Standing instructions** from `AGENT.md` (and `TEAM.md` for a coordinated shared agent). 2. **Skills** resolved in precedence order: agent-scoped skills, then personal skills, then enabled workspace skill links, then built-in system skills. 3. **Tools** filtered by the user's connected integrations, active MCP servers, per-tool permissions, and the run's **Access Scope**. 4. **Context** from the Knowledge Graph, saved Views, Knowledge files, and personal memory. For [shared agents](/agents/shared-agents/), each scheduled trigger either fans out one isolated run per active member (**fan-out mode**) or starts a single **coordinator** run that delegates to members with `agent(prompt, { agent, user })`. In both cases, every member run executes strictly as that member with their own credentials and Access Scope. ## 4. Where your team stays in charge Dex pauses before consequential actions unless you explicitly authorize automation: - **Write approval cards (Pending Actions)** — By default (`requireWriteApproval: true`), integration writes from automations pause as durable approval cards in the Nexus Inbox, a Slack DM, a shared Slack channel, or a webhook. Reviewers can inspect proposed payloads, edit fields before approving, or reject with feedback that triggers a follow-up revision run. - **Drift detection** — Before executing an approved card, Dex checks whether the target external record changed since the proposal was drafted. If it drifted, execution stops until a person confirms the override. - **Auto Mode** — When you want low-risk writes to execute without manual clicks, enable `autoMode: true` or write a plain-language policy in `AGENT.md`. A dedicated reviewer evaluates each proposed write and auto-executes only writes that satisfy the policy with high confidence; anything ambiguous still becomes an approval card. - **Credential boundaries** — Approving a teammate's pending action card executes under the **card owner's** credentials and Access Scope—never the approving admin's. Factory roles (`read`, `write`, `admin`) control who can view or edit files, never who can access someone else's OAuth accounts. ## 5. How agents improve over time Every automation run records its transcript, tool calls, skill attribution, and pending action outcomes (including edits and rejection feedback). You can: - Inspect individual and nested coordinator/member runs from the Runs view or CLI (`dex agents runs`, `dex runs get`). - Export full trajectories in JSON or ATIF format (`dex chats transcript`). - Run dry-run checks that simulate external mutations without writing to production systems. - Enable the optional daily **self-improvement** meta-agent (`agent_improvers`), which inspects recent runs and card rejections in an isolated dry-run sandbox and tracks recurring failure patterns as structured [Agent Issues](/factory/measure-and-improve/#agent-issues-and-self-improvement). ## Related pages - [Dex quickstart](/getting-started/quickstart/) - Connect a source and ship your first workflow - [Core concepts](/getting-started/core-concepts/) - Exact boundaries between agents, skills, ontology, knowledge graph, and Factory - [Shared agents](/agents/shared-agents/) - Fan-out, coordinator mode, and team credential boundaries - [Factory definition as code](/factory/workspace-structure/) - File layout and schema reference - [Tools, scopes, and approvals](/agents/tools-and-approvals/) - Pending actions, drift detection, and Auto ModeUnderstand how Dex connects company sources, builds a permissioned knowledge graph, runs personal and shared agents from Factory definitions, and keeps people in control of writes.
Dex connects three layers into one loop: a context layer that turns raw company activity into a structured, permissioned knowledge graph; a Factory layer that versions agents, skills, views, and ontology definitions as files; and an execution layer that runs agents interactively or on schedules while gating external writes behind human review or explicit policies.
flowchart TD
Sources["Connected sources<br/>(Slack, Gmail, Linear, Attio, ...)"] --> Datasets["Synced Datasets &<br/>Ontology Mappings"]
Datasets --> Graph["Knowledge Graph & Nexus<br/>(Objects, links, observations)"]
Factory["Factory (Git)<br/>(AGENT.md, TEAM.md, SKILL.md,<br/>automations, views, ontology)"] --> Apply["Commit & Apply<br/>(validation & projection)"]
Graph --> Runtime["Agent Runtime<br/>(dex / claude / codex harness)"]
Apply --> Runtime
Runtime --> Gate{"Write approval<br/>or Auto Mode?"}
Gate -->|Human review| Cards["Pending Actions<br/>(Inbox, Slack, Webhook)"]
Gate -->|Policy allows| External["External tools &<br/>Knowledge Graph"]
Cards -->|Approved| External
External --> Improve["Runs, feedback &<br/>Self-improvement"]
Improve -.-> Factory
1. Context flows from sources into the knowledge graph
Section titled “1. Context flows from sources into the knowledge graph”When you connect an integration and enable context indexing, Dex syncs selected channels, labels, calendars, repositories, or pages into read-only Datasets. Your workspace ontology maps those dataset rows into typed Object records (such as person, company, or custom types) and timestamped observations linked to those records.
- Identity resolution is deterministic. Cluster keys (for example, normalized email address or domain) merge evidence across tools into one record and fail closed on collisions rather than silently merging unrelated entities.
- Human edits are preserved. When you or an agent edits a field on a synced record, Dex records a cell edit so future syncs do not overwrite your change.
- Permissions travel with the data. Every record belongs to a Data Scope (personal, Space, or workspace), and sources like Slack and Notion propagate channel/page reader lists so users and agents only see records they are authorized to read.
Agents query this layer directly through the dex zeta CLI, read-only SQL views (o_<object> and d_<dataset>), or saved Views—and fall back to live integration tools when fresh or unsynced data is needed.
2. Configuration lives in Factory as versioned files
Section titled “2. Configuration lives in Factory as versioned files”Durable workspace definitions live in Factory, a single Git-backed repository per organization:
- Shared definitions live under
workspace/(shared agents, shared skills, ontology YAML files, saved views, source descriptors, and shared knowledge). - Personal definitions live under
users/<slug>--<user-id>/(personal agents, personal skills, memory, knowledge, and lightweight links to shared workspace agents or skills).
Every edit—whether made in the web UI, by an agent in chat, or via dex factory in the CLI—passes through a two-phase Commit and Apply pipeline. Commits validate schemas, permissions, and move rules first, then project the committed tree into live runtime tables. OAuth tokens, Access Scopes, run histories, and pending actions never live in Git; they stay in Postgres.
3. Agents execute interactively or in the background
Section titled “3. Agents execute interactively or in the background”Every chat turn and automation run executes through a unified, durable turn runtime supporting three selectable harnesses:
dex(default) — Native multi-agent loop with orchestrator/subagent delegation, deferred tool discovery, and support for browser/desktop tools in interactive sessions.claudeandcodex— Sandboxed agent harnesses running in E2B sandboxes with direct access to/workspace/factory, thedexCLI, and durable checkpointing.
During a run, Dex assembles only the capabilities authorized for that actor:
- Standing instructions from
AGENT.md(andTEAM.mdfor a coordinated shared agent). - Skills resolved in precedence order: agent-scoped skills, then personal skills, then enabled workspace skill links, then built-in system skills.
- Tools filtered by the user’s connected integrations, active MCP servers, per-tool permissions, and the run’s Access Scope.
- Context from the Knowledge Graph, saved Views, Knowledge files, and personal memory.
For shared agents, each scheduled trigger either fans out one isolated run per active member (fan-out mode) or starts a single coordinator run that delegates to members with agent(prompt, { agent, user }). In both cases, every member run executes strictly as that member with their own credentials and Access Scope.
4. Where your team stays in charge
Section titled “4. Where your team stays in charge”Dex pauses before consequential actions unless you explicitly authorize automation:
- Write approval cards (Pending Actions) — By default (
requireWriteApproval: true), integration writes from automations pause as durable approval cards in the Nexus Inbox, a Slack DM, a shared Slack channel, or a webhook. Reviewers can inspect proposed payloads, edit fields before approving, or reject with feedback that triggers a follow-up revision run. - Drift detection — Before executing an approved card, Dex checks whether the target external record changed since the proposal was drafted. If it drifted, execution stops until a person confirms the override.
- Auto Mode — When you want low-risk writes to execute without manual clicks, enable
autoMode: trueor write a plain-language policy inAGENT.md. A dedicated reviewer evaluates each proposed write and auto-executes only writes that satisfy the policy with high confidence; anything ambiguous still becomes an approval card. - Credential boundaries — Approving a teammate’s pending action card executes under the card owner’s credentials and Access Scope—never the approving admin’s. Factory roles (
read,write,admin) control who can view or edit files, never who can access someone else’s OAuth accounts.
5. How agents improve over time
Section titled “5. How agents improve over time”Every automation run records its transcript, tool calls, skill attribution, and pending action outcomes (including edits and rejection feedback). You can:
- Inspect individual and nested coordinator/member runs from the Runs view or CLI (
dex agents runs,dex runs get). - Export full trajectories in JSON or ATIF format (
dex chats transcript). - Run dry-run checks that simulate external mutations without writing to production systems.
- Enable the optional daily self-improvement meta-agent (
agent_improvers), which inspects recent runs and card rejections in an isolated dry-run sandbox and tracks recurring failure patterns as structured Agent Issues.
Related pages
Section titled “Related pages”- Dex quickstart - Connect a source and ship your first workflow
- Core concepts - Exact boundaries between agents, skills, ontology, knowledge graph, and Factory
- Shared agents - Fan-out, coordinator mode, and team credential boundaries
- Factory definition as code - File layout and schema reference
- Tools, scopes, and approvals - Pending actions, drift detection, and Auto Mode