Exploring Deep Agents: An Open‑Source Alternative to Claude Code for Coding AI Agents
Deep Agents, an open‑source framework built on LangChain and LangGraph, provides a ready‑to‑use agent harness with planning, file‑system tools, sandboxed shell access, sub‑agents, automatic context management, and built‑in observability for Python and TypeScript developers seeking a flexible replacement for Claude Code.
What Is an Agent Harness?
Every team building a coding agent connects the same primitives—file access, shell execution, task planning, context management, and sub‑agents for parallel work. Deep Agents packages these primitives as sensible defaults, delivering a functional agent out of the box that can be customized.
Built‑In Features
Planning ( write_todos )
Before taking action, the agent uses write_todos to structure tasks, track progress, and decide next steps, mirroring Claude Code’s task‑tracking capability.
File System Tools
read_file("src/api/handlers.py")
write_file("src/api/handlers.py", new_content)
edit_file("src/api/handlers.py", old_str, new_str)
ls("src/api/")
glob("**/*.py")
grep("class.*Handler", "src/")These six commands enable reading, writing, editing, directory listing, glob pattern search, and regex content search within a codebase.
Shell Access ( execute )
execute("pytest tests/")
execute("pip install -r requirements.txt")
execute("git diff HEAD~1")The sandboxed shell lets agents run tests, install dependencies, and inspect git history without exposing a root shell.
Sub‑Agents ( task )
Each task call spawns an independent sub‑agent with its own context window, containing only the task description. Example calls:
task("Research the deepagents API and summarize key interfaces")
task("Write unit tests for the new FileProcessor class")A sub‑agent is defined by a JSON object such as:
{
"name": "researcher",
"description": "Researches topics and returns summaries",
"system_prompt": "You are a research assistant...",
"tools": [read_file, grep, glob]
}Sub‑agents can also be wrapped as CompiledSubAgent objects for more complex behavior.
Smart Defaults: Prompt Guidance
Deep Agents ships with system prompts that teach the model to plan before acting, search before writing, and delegate to sub‑agents for parallel work, eliminating the need for manual configuration.
Zero‑Config Context Management
Introduced in v0.2, automatic summarization runs as middleware, compressing old conversation history and offloading oversized tool outputs to files while keeping references in the context.
Out‑of‑the‑Box Observability
LangSmith tracing is enabled with just two environment variables:
export LANGSMITH_API_KEY=your_key
export LANGSMITH_TRACING_V2=trueEvery run logs planning steps, tool calls, tool results, and failures without additional instrumentation. MCP tool support follows the standard mcp_server_tools bridge pattern, allowing any compatible MCP server (databases, APIs, custom services) to be used.
Python and TypeScript Support
Installation commands:
pip install deepagents
deepagentsFor TypeScript:
npm install deepagents
import { createDeepAgent } from "deepagents";
const agent = createDeepAgent({ tools: [...] });The same harness architecture works in both ecosystems.
Comparison with Claude Code
Both projects converge on the same set of primitives, but differ in orientation:
Model: Deep Agents works with any LangChain provider (hundreds); Claude Code is limited to Anthropic’s Claude models.
Planning: Deep Agents uses write_todos; Claude Code provides a built‑in task tracker.
File System: Deep Agents offers six dedicated tools; Claude Code bundles read, write, edit, glob, grep.
Shell: Deep Agents’ execute runs in a sandbox; Claude Code’s Bash is also sandboxed but less extensible.
Sub‑Agents: Deep Agents’ task creates independent context windows; Claude Code lacks this feature.
Context Management: Deep Agents adds automatic summarization and file offloading; Claude Code relies on automatic compression.
Observability: Deep Agents integrates LangSmith; Claude Code provides its own tracing hooks.
Extensibility: Deep Agents leverages MCP + LangGraph; Claude Code uses proprietary hooks.
License: Deep Agents is MIT‑licensed; Claude Code is proprietary.
Teams focused on Anthropic may prefer Claude Code, while those wanting multi‑model flexibility, open‑stack transparency, or an extensible open‑source base should consider Deep Agents.
Why Read This Project Even If You Don’t Use It
Deep Agents serves as a clear open‑source reference for how coding agents like Claude Code, Cursor, or Devin are built. It demonstrates:
How the planning loop operates
How tool‑calling cycles are constructed
Practical handling of context compression
Implementation of sub‑agent delegation patterns
As tooling around coding agents converges on the same primitives, studying Deep Agents’ code reveals the essential building blocks.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
