How shahriyarr/deepagents works
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: deepagents/__init__.py Public API · app.py TUI app · middleware/__init__.py Middleware · backends/__init__.py Backends
Components 21
Core runtime
Reusable agent harness and execution boundaries
- Public API · Entry points and model/profile surface for the reusable Deep Agents library
libs/deepagents/deepagents/__init__.py - Agent graph · LangGraph-based agent assembly and execution flow
libs/deepagents/deepagents/graph.py - Middleware · Planning-adjacent layers for filesystem, memory, skills, permissions, subagents, and summarization
libs/deepagents/deepagents/middleware/__init__.py - Backends · Filesystem, shell, sandbox, state, store, and protocol abstractions
libs/deepagents/deepagents/backends/__init__.py - Profiles · 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 · Interactive chat interface, rendering, and session experience
libs/cli/deepagents_cli/app.py - CLI agent · CLI-specific agent assembly, prompts, and tool wiring
libs/cli/deepagents_cli/agent.py - Tools · Clipboard, file ops, MCP tools, subagents, and shared tool presentation
libs/cli/deepagents_cli/tools.py - Server bridge · Local server, remote client, server manager, and sandbox integration
libs/cli/deepagents_cli/server.py - Skills · Built-in and external skill loading, commands, and invocation flow
libs/cli/deepagents_cli/skills/load.py - Deploy tools · 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 · 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 · Benchmark catalog, radar generation, LangSmith/Harbor integration, and failure analysis
libs/evals/deepagents_harbor/__init__.py - Eval catalog · Catalog and category data used to organize benchmark coverage
libs/evals/deepagents_evals/categories.json
Partner adapters
Provider-specific sandbox/runtime integrations
- Daytona · Provider adapter for Daytona-backed execution environments
libs/partners/daytona/langchain_daytona/sandbox.py - Modal · Provider adapter for Modal-backed execution environments
libs/partners/modal/langchain_modal/sandbox.py - Runloop · Provider adapter for Runloop-backed execution environments
libs/partners/runloop/langchain_runloop/sandbox.py - QuickJS · Foreign-function and middleware adapter for the QuickJS runtime
libs/partners/quickjs/langchain_quickjs/middleware.py - REPL · Interpreter-like runtime flavor with foreign-function support
libs/repl/langchain_repl/interpreter.py
Examples
End-to-end compositions and reference apps
- Examples · End-to-end example compositions for research, writing, coding, and deployment
examples/README.md
Other components
- Repo ops · CI, release automation, linting, and validation scripts for the monorepo
.github/workflows/ci.yml
Connections 25
- 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