# shahriyarr/deepagents architecture

> Architecture diagram of the GitHub repository shahriyarr/deepagents, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-04-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/shahriyarr/deepagents
- Repository: https://github.com/shahriyarr/deepagents

## Overview

1. **Repository shape**
This is a Python monorepo for the “Deep Agents” ecosystem. The core runtime lives in `libs/deepagents`, the terminal product in `libs/cli`, the protocol/server layer in `libs/acp`, evaluation tooling in `libs/evals`, and several partner adapters in `libs/partners/*`. The top-level `examples/` directory shows how the pieces are assembled in real applications.

2. **Core SDK: `libs/deepagents`**
`deepagents` is the reusable agent harness. Its main job is to build a LangGraph-based agent with opinionated defaults: planning, filesystem access, shell execution, sub-agent delegation, memory/summarization, and skill loading. The package exposes the `create_deep_agent` entry point and the graph/middleware that define how an LLM turns messages into tool calls and state updates.

3. **Execution model**
The runtime flow is: user messages enter the agent graph, the model plans, middleware injects or restricts capabilities, tools are invoked, and results feed back into the conversation state. Long-running conversations are managed by summarization middleware, while file and shell operations are routed through backend abstractions so the same agent logic can run locally, in sandboxes, or against remote environments.

4. **Tool and capability boundaries**
The architecture is intentionally tool-centered. File system tools, shell execution, memory, skills, and subagents are separate middleware layers rather than hard-coded behavior. The repo’s security model assumes the model is untrusted and enforcement happens at the tool/sandbox boundary, which is why there are explicit backends, permissions, and allowlists throughout the core library.

5. **CLI product: `libs/cli`**
`deepagents_cli` is a full terminal application built on top of the SDK. It provides the interactive TUI, command registry, message rendering, model selection, approval flows, session tracking, and non-interactive/headless modes. It also integrates built-in skills, MCP tools, clipboard/editor/file helpers, and update checks, making it the “batteries-included” end user interface.

6. **CLI runtime integrations**
The CLI can run against local execution or external sandboxes and can connect to remote agents/servers. The `server.py`, `server_manager.py`, `remote_client.py`, and `integrations/` modules show that the UI is not tied to one execution backend; instead it brokers between chat input, model calls, sandbox providers, and tool output formatting.

7. **ACP server package: `libs/acp`**
`deepagents_acp` packages the agent harness behind an ACP-facing server interface. This is the integration boundary for running Deep Agents as a service rather than an interactive CLI or library call. The package includes server utilities, a demo agent, and tests around model switching and command safety, indicating a separate deployment surface from the CLI.

8. **Evaluation stack: `libs/evals`**
`deepagents_evals` and `deepagents_harbor` provide the measurement layer for the project. They define benchmark catalogs, radar generation, LangSmith/Harbor integration, failure analysis, and benchmark fixtures. Architecturally, this layer wraps the agent runtime to score behaviors like tool use, memory, skills, subagents, summarization, and file operations.

9. **Partner adapters: `libs/partners/*`**
The partner packages are thin integration layers for external sandbox or runtime providers such as Daytona, Modal, Runloop, and QuickJS. These packages adapt provider-specific execution environments to the same agent/sandbox abstraction used by the core libraries, keeping provider concerns isolated from the agent logic.

10. **REPL and specialized runtime packages**
`libs/repl` is a smaller, specialized package for an interactive interpreter-like experience with foreign-function support and middleware. It sits alongside the main agent harness as another runtime flavor, showing that the repo supports multiple execution styles rather than one monolithic app.

11. **Examples as architecture references**
The `examples/` directory is a catalog of end-to-end compositions: research agents, content writers, text-to-SQL, deployable coding agents, async subagent servers, GPU/NVIDIA-oriented agents, and harness experiments. These examples demonstrate the intended system boundaries—model + tools + skills + sandbox + deployment config—without changing the core packages.

12. **Build, test, and release structure**
The repo is managed as a multi-package Python project using `uv`, with per-package `pyproject.toml` and lockfiles. GitHub Actions handle linting, tests, version checks, release automation, and benchmark/eval workflows. This matters architecturally because the packages are versioned and validated independently while still sharing common patterns and safety checks.

Main entry points: [`libs/deepagents/deepagents/__init__.py`](https://github.com/shahriyarr/deepagents/blob/main/libs/deepagents/deepagents/__init__.py) (Public API), [`libs/cli/deepagents_cli/app.py`](https://github.com/shahriyarr/deepagents/blob/main/libs/cli/deepagents_cli/app.py) (TUI app), [`libs/deepagents/deepagents/middleware/__init__.py`](https://github.com/shahriyarr/deepagents/blob/main/libs/deepagents/deepagents/middleware/__init__.py) (Middleware), [`libs/deepagents/deepagents/backends/__init__.py`](https://github.com/shahriyarr/deepagents/blob/main/libs/deepagents/deepagents/backends/__init__.py) (Backends)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_core["Core runtime"]
  node_deepagents_api["Public API<br/>sdk entry<br/>[__init__.py]"]
  node_deepagents_graph(("Agent graph<br/>runtime graph<br/>[graph.py]"))
  node_deepagents_middleware{{"Middleware<br/>capability layers<br/>[__init__.py]"}}
  node_deepagents_backends[("Backends<br/>tool boundary<br/>[__init__.py]")]
  node_deepagents_profiles["Profiles<br/>model presets<br/>[__init__.py]"]
end

subgraph group_cli["Terminal app"]
  node_cli_app["TUI app<br/>terminal UI<br/>[app.py]"]
  node_cli_agent(("CLI agent<br/>agent wrapper<br/>[agent.py]"))
  node_cli_tools{{"Tools<br/>tooling<br/>[tools.py]"}}
  node_cli_server[("Server bridge<br/>execution bridge<br/>[server.py]")]
  node_cli_skills["Skills<br/>skill loader<br/>[load.py]"]
  node_cli_deploy["Deploy tools<br/>packaging helpers<br/>[bundler.py]"]
end

subgraph group_service["Service layer"]
  node_acp_server[("ACP server<br/>service wrapper<br/>[server.py]")]
end

subgraph group_quality["Evaluation"]
  node_eval_harbor["Evals & harbor<br/>measurement layer<br/>[__init__.py]"]
  node_eval_catalog["Eval catalog<br/>benchmark definitions<br/>[categories.json]"]
end

subgraph group_partners["Partner adapters"]
  node_partner_daytona[("Daytona<br/>sandbox adapter<br/>[sandbox.py]")]
  node_partner_modal[("Modal<br/>sandbox adapter<br/>[sandbox.py]")]
  node_partner_runloop[("Runloop<br/>sandbox adapter<br/>[sandbox.py]")]
  node_partner_quickjs{{"QuickJS<br/>runtime adapter<br/>[middleware.py]"}}
  node_repl_runtime(("REPL<br/>interactive runtime<br/>[interpreter.py]"))
end

subgraph group_examples["Examples"]
  node_example_apps["Examples<br/>reference apps<br/>[README.md]"]
end

node_repo_ops["Repo ops<br/>automation<br/>[ci.yml]"]

node_deepagents_api -->|"exports"| node_deepagents_graph
node_deepagents_api -->|"configures"| node_deepagents_middleware
node_deepagents_api -->|"uses"| node_deepagents_backends
node_deepagents_api -->|"selects"| node_deepagents_profiles
node_deepagents_graph -->|"invokes"| node_deepagents_middleware
node_deepagents_middleware -->|"mediates"| node_deepagents_backends
node_cli_app -->|"drives"| node_cli_agent
node_cli_agent -->|"builds on"| node_deepagents_api
node_cli_agent -->|"calls"| node_cli_tools
node_cli_app -->|"brokers"| node_cli_server
node_cli_app -->|"loads"| node_cli_skills
node_cli_app -->|"packages"| node_cli_deploy
node_acp_server -->|"wraps"| node_deepagents_api
node_eval_harbor -->|"scores"| node_deepagents_api
node_eval_harbor -->|"indexes"| node_eval_catalog
node_partner_daytona -->|"adapts"| node_deepagents_backends
node_partner_modal -->|"adapts"| node_deepagents_backends
node_partner_runloop -->|"adapts"| node_deepagents_backends
node_partner_quickjs -->|"extends"| node_deepagents_middleware
node_repl_runtime -->|"reuses"| node_deepagents_middleware
node_example_apps -->|"demonstrates"| node_deepagents_api
node_example_apps -->|"references"| node_cli_agent
node_repo_ops -.->|"validates"| node_deepagents_api
node_repo_ops -.->|"validates"| node_cli_app
node_repo_ops -.->|"validates"| node_eval_harbor

click node_deepagents_api "https://github.com/shahriyarr/deepagents/blob/main/libs/deepagents/deepagents/__init__.py"
click node_deepagents_graph "https://github.com/shahriyarr/deepagents/blob/main/libs/deepagents/deepagents/graph.py"
click node_deepagents_middleware "https://github.com/shahriyarr/deepagents/blob/main/libs/deepagents/deepagents/middleware/__init__.py"
click node_deepagents_backends "https://github.com/shahriyarr/deepagents/blob/main/libs/deepagents/deepagents/backends/__init__.py"
click node_deepagents_profiles "https://github.com/shahriyarr/deepagents/blob/main/libs/deepagents/deepagents/profiles/__init__.py"
click node_cli_app "https://github.com/shahriyarr/deepagents/blob/main/libs/cli/deepagents_cli/app.py"
click node_cli_agent "https://github.com/shahriyarr/deepagents/blob/main/libs/cli/deepagents_cli/agent.py"
click node_cli_tools "https://github.com/shahriyarr/deepagents/blob/main/libs/cli/deepagents_cli/tools.py"
click node_cli_server "https://github.com/shahriyarr/deepagents/blob/main/libs/cli/deepagents_cli/server.py"
click node_cli_skills "https://github.com/shahriyarr/deepagents/blob/main/libs/cli/deepagents_cli/skills/load.py"
click node_cli_deploy "https://github.com/shahriyarr/deepagents/blob/main/libs/cli/deepagents_cli/deploy/bundler.py"
click node_acp_server "https://github.com/shahriyarr/deepagents/blob/main/libs/acp/deepagents_acp/server.py"
click node_eval_harbor "https://github.com/shahriyarr/deepagents/blob/main/libs/evals/deepagents_harbor/__init__.py"
click node_eval_catalog "https://github.com/shahriyarr/deepagents/blob/main/libs/evals/deepagents_evals/categories.json"
click node_partner_daytona "https://github.com/shahriyarr/deepagents/blob/main/libs/partners/daytona/langchain_daytona/sandbox.py"
click node_partner_modal "https://github.com/shahriyarr/deepagents/blob/main/libs/partners/modal/langchain_modal/sandbox.py"
click node_partner_runloop "https://github.com/shahriyarr/deepagents/blob/main/libs/partners/runloop/langchain_runloop/sandbox.py"
click node_partner_quickjs "https://github.com/shahriyarr/deepagents/blob/main/libs/partners/quickjs/langchain_quickjs/middleware.py"
click node_repl_runtime "https://github.com/shahriyarr/deepagents/blob/main/libs/repl/langchain_repl/interpreter.py"
click node_example_apps "https://github.com/shahriyarr/deepagents/blob/main/examples/README.md"
click node_repo_ops "https://github.com/shahriyarr/deepagents/blob/main/.github/workflows/ci.yml"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_deepagents_api,node_deepagents_graph,node_deepagents_middleware,node_deepagents_backends,node_deepagents_profiles toneBlue
class node_cli_app,node_cli_agent,node_cli_tools,node_cli_server,node_cli_skills,node_cli_deploy toneAmber
class node_acp_server toneMint
class node_eval_harbor,node_eval_catalog toneRose
class node_partner_daytona,node_partner_modal,node_partner_runloop,node_partner_quickjs,node_repl_runtime toneIndigo
class node_example_apps toneTeal
class node_repo_ops toneNeutral
```

## Components

### Core runtime

Reusable agent harness and execution boundaries

- [Public API](https://github.com/shahriyarr/deepagents/blob/main/libs/deepagents/deepagents/__init__.py): sdk entry · Entry points and model/profile surface for the reusable Deep Agents library · `libs/deepagents/deepagents/__init__.py`
- [Agent graph](https://github.com/shahriyarr/deepagents/blob/main/libs/deepagents/deepagents/graph.py): runtime graph · LangGraph-based agent assembly and execution flow · `libs/deepagents/deepagents/graph.py`
- [Middleware](https://github.com/shahriyarr/deepagents/blob/main/libs/deepagents/deepagents/middleware/__init__.py): capability layers · Planning-adjacent layers for filesystem, memory, skills, permissions, subagents, and summarization · `libs/deepagents/deepagents/middleware/__init__.py`
- [Backends](https://github.com/shahriyarr/deepagents/blob/main/libs/deepagents/deepagents/backends/__init__.py): tool boundary · Filesystem, shell, sandbox, state, store, and protocol abstractions · `libs/deepagents/deepagents/backends/__init__.py`
- [Profiles](https://github.com/shahriyarr/deepagents/blob/main/libs/deepagents/deepagents/profiles/__init__.py): model presets · Provider/profile adapters used to configure the agent runtime · `libs/deepagents/deepagents/profiles/__init__.py`

### Terminal app

Interactive product built on the SDK

- [TUI app](https://github.com/shahriyarr/deepagents/blob/main/libs/cli/deepagents_cli/app.py): terminal UI · Interactive chat interface, rendering, and session experience · `libs/cli/deepagents_cli/app.py`
- [CLI agent](https://github.com/shahriyarr/deepagents/blob/main/libs/cli/deepagents_cli/agent.py): agent wrapper · CLI-specific agent assembly, prompts, and tool wiring · `libs/cli/deepagents_cli/agent.py`
- [Tools](https://github.com/shahriyarr/deepagents/blob/main/libs/cli/deepagents_cli/tools.py): tooling · Clipboard, file ops, MCP tools, subagents, and shared tool presentation · `libs/cli/deepagents_cli/tools.py`
- [Server bridge](https://github.com/shahriyarr/deepagents/blob/main/libs/cli/deepagents_cli/server.py): execution bridge · Local server, remote client, server manager, and sandbox integration · `libs/cli/deepagents_cli/server.py`
- [Skills](https://github.com/shahriyarr/deepagents/blob/main/libs/cli/deepagents_cli/skills/load.py): skill loader · Built-in and external skill loading, commands, and invocation flow · `libs/cli/deepagents_cli/skills/load.py`
- [Deploy tools](https://github.com/shahriyarr/deepagents/blob/main/libs/cli/deepagents_cli/deploy/bundler.py): packaging helpers · Bundling and deployment commands for shipping the CLI as an app · `libs/cli/deepagents_cli/deploy/bundler.py`

### Service layer

Server-facing packaging and runtime bridges

- [ACP server](https://github.com/shahriyarr/deepagents/blob/main/libs/acp/deepagents_acp/server.py): service wrapper · ACP-facing server packaging for running Deep Agents as a service · `libs/acp/deepagents_acp/server.py`

### Evaluation

Benchmarking, radar, and failure analysis

- [Evals & harbor](https://github.com/shahriyarr/deepagents/blob/main/libs/evals/deepagents_harbor/__init__.py): measurement layer · Benchmark catalog, radar generation, LangSmith/Harbor integration, and failure analysis · `libs/evals/deepagents_harbor/__init__.py`
- [Eval catalog](https://github.com/shahriyarr/deepagents/blob/main/libs/evals/deepagents_evals/categories.json): benchmark definitions · Catalog and category data used to organize benchmark coverage · `libs/evals/deepagents_evals/categories.json`

### Partner adapters

Provider-specific sandbox/runtime integrations

- [Daytona](https://github.com/shahriyarr/deepagents/blob/main/libs/partners/daytona/langchain_daytona/sandbox.py): sandbox adapter · Provider adapter for Daytona-backed execution environments · `libs/partners/daytona/langchain_daytona/sandbox.py`
- [Modal](https://github.com/shahriyarr/deepagents/blob/main/libs/partners/modal/langchain_modal/sandbox.py): sandbox adapter · Provider adapter for Modal-backed execution environments · `libs/partners/modal/langchain_modal/sandbox.py`
- [Runloop](https://github.com/shahriyarr/deepagents/blob/main/libs/partners/runloop/langchain_runloop/sandbox.py): sandbox adapter · Provider adapter for Runloop-backed execution environments · `libs/partners/runloop/langchain_runloop/sandbox.py`
- [QuickJS](https://github.com/shahriyarr/deepagents/blob/main/libs/partners/quickjs/langchain_quickjs/middleware.py): runtime adapter · Foreign-function and middleware adapter for the QuickJS runtime · `libs/partners/quickjs/langchain_quickjs/middleware.py`
- [REPL](https://github.com/shahriyarr/deepagents/blob/main/libs/repl/langchain_repl/interpreter.py): interactive runtime · Interpreter-like runtime flavor with foreign-function support · `libs/repl/langchain_repl/interpreter.py`

### Examples

End-to-end compositions and reference apps

- [Examples](https://github.com/shahriyarr/deepagents/blob/main/examples/README.md): reference apps · End-to-end example compositions for research, writing, coding, and deployment · `examples/README.md`

### Other components

- [Repo ops](https://github.com/shahriyarr/deepagents/blob/main/.github/workflows/ci.yml): automation · CI, release automation, linting, and validation scripts for the monorepo · `.github/workflows/ci.yml`

## Connections

- Public API → Agent graph: exports · The public package exposes the graph-driven agent entry points
- Public API → Middleware: configures · Agent construction is assembled from middleware layers
- Public API → Backends: uses · Tool and state operations are routed through backend abstractions
- Public API → Profiles: selects · Profiles choose model/provider defaults for the agent runtime
- Agent graph → Middleware: invokes · The graph coordinates planning, tools, memory, skills, and subagents
- Middleware → Backends: mediates · Middleware enforces permissions and capability boundaries at the tool layer
- TUI app → CLI agent: drives · The terminal UI drives the CLI-specific agent loop
- CLI agent → Public API: builds on · The CLI agent is assembled on top of the shared SDK
- CLI agent → Tools: calls · Agent turns are projected into file, MCP, and utility tools
- TUI app → Server bridge: brokers · The UI can speak to local, remote, or sandboxed backends through server bridges
- TUI app → Skills: loads · Skill discovery and invocation are integrated into the user workflow
- TUI app → Deploy tools: packages · Deployment commands support turning the CLI into distributable artifacts
- ACP server → Public API: wraps · ACP service mode wraps the shared runtime as a server surface
- Evals & harbor → Public API: scores · Evaluation utilities wrap the agent runtime to measure behavior
- Evals & harbor → Eval catalog: indexes · Catalog metadata feeds benchmark and radar generation
- Daytona → Backends: adapts · Provider implementation plugs into the common sandbox boundary
- Modal → Backends: adapts · Provider implementation plugs into the common sandbox boundary
- Runloop → Backends: adapts · Provider implementation plugs into the common sandbox boundary
- QuickJS → Middleware: extends · QuickJS adds runtime-specific middleware and foreign-function support
- REPL → Middleware: reuses · The REPL is another runtime flavor built around middleware patterns
- Examples → Public API: demonstrates · Examples show how to compose the shared SDK into full applications
- Examples → CLI agent: references · Some examples mirror the terminal product's tool and skill patterns
- Repo ops → Public API: validates · CI and release automation verify the core library and adjacent packages
- Repo ops → TUI app: validates · Monorepo automation covers the terminal product and its tests
- Repo ops → Evals & harbor: validates · Benchmark and eval workflows are part of repository automation
