$ show langchain-ai/deepagents
This repository is a comprehensive, multi-package AI agent framework developed by LangChain, known as 'Deep Agents'. It provides a production-ready SDK ('deepagents') built on LangGraph for creating stateful, middleware-driven agents with capabilities such as filesystem manipulation, shell execution, memory, sub-agents, skills, human-in-the-loop, and summarization. The primary client is a high-quality CLI/TUI application ('deepagents-code') that offers an interactive coding assistant with a rich Textual terminal interface, plugin system, MCP OAuth integration, and sandboxed execution via multiple providers (Daytona, Modal, Runloop, Vercel). A deployment CLI ('deepagents-cli') manages agent lifecycle on LangSmith, and an experimental persistent runtime ('talon') supports cron jobs, voice, and channels like Telegram/WhatsApp. A comprehensive evaluation suite ('evals') includes benchmarks (FRAMES, Nexus, BFCL, tau2, MemoryAgentBench, Context-Bench, DRBench) with LLM-as-judge, trajectory scoring, and LangSmith reporting. The architecture emphasizes modularity: middleware stack, hooks system, backend protocols, and profile system. While primarily an application, the evals and dataset curation give it a hybrid character.
The LLM identified 6 files worth highlighting for reuse:
Defines `SandboxBackendProtocol` and related types (`ReadResult`, `FileType`, `FileInfo`) that abstract filesystem and shell operations. The protocol is minimal and fully async‑compatible, with automatic async wrapper generation. Any sandbox provider (local, remote, sandbox) that implements this protocol can be plugged into the agent. This is a clean, reusable interface for filesystem‑backed agent execution.
Provides functions for parsing and formatting unified diffs with careful handling of line boundaries (avoids Python's `splitlines()` due to Unicode line‑break characters). Includes `DiffStats` named tuple for change counts, file header detection, and truncation markers. This module has no internal dependencies and can be extracted for any application needing robust diff processing.
Implements `ResumeStateMiddleware` that captures and restores agent state (token counts, model spec, context tokens) from LangGraph checkpoint channels. Demonstrates the middleware pattern (`wrap_model_call`) for injecting state tracking without modifying the agent graph. The logic for extracting `PrivateStateAttr` and writing back to config is isolated and testable.
Implements a custom LangGraph `MessagesReducer` that keeps message IDs stable across resume by issuing `DeltaChannel` updates only for new messages. This prevents duplicate messages when resuming from checkpoints. The reducer is self‑contained and can be reused in any LangGraph application needing idempotent message appends.
Core hooks execution engine that manages immutable snapshots, concurrent handlers, ordered reduction, and plugin hook dispatch. Uses frozen dataclasses and `MappingProxyType` for immutability. The engine can run handlers in a subprocess with timeout and output truncation. This pattern can be reused for any event‑driven system requiring safe concurrent hook execution.
Translates detailed permission decisions (allow, deny, ask, auto‑approve) from tools/filesystem rules into a concise `PermissionDecision` enum with optional reason. Centralizes the mapping between filesystem rule metadata and interrupt conditions. The logic is self‑contained and could be extracted for any agent permission model that needs to convert rule‑based policies to user‑facing decisions.