All posts

A Guide to LangChain Deep Agents for Multi-Step Workflows

Sarah
A Guide to LangChain Deep Agents for Multi-Step Workflows

The first generation of AI agents followed a simple blueprint: the ReAct (Reason + Act) loop. You gave an LLM a tool, and it called that tool until it reached an answer. While effective for simple queries, this “flat” architecture fails when tasks scale. Whether it’s conducting deep market research or managing a complex codebase, the agent’s context window eventually fills with intermediate search results, partial code, and “noise,” leading to errors and lost focus.

LangChain Deep Agents: this isn’t just another agent framework, it’s an “agent harness” built on top of LangGraph. It provides a structured environment where agents can manage their own context, delegate work to specialized sub-units, and maintain a persistent plan of action.

What Exactly is a “Deep Agent”?

A Deep Agent is a meta-toolkit designed for long-horizon tasks. Instead of wiring up prompts and memory manually, the Deep Agents SDK (deepagents) provides an opinionated, production-ready environment out of the box.

Think of it as the difference between a lone developer and a project manager with a team. A standard agent acts like the lone developer; a Deep Agent acts like the manager, utilizing a virtual filesystem as a “desk” and spawning sub-agents as “junior developers” to keep the main workspace clean.

The 4 Pillars of Deep Agent Architecture

To handle complex work, Deep Agents rely on four core capabilities that separate them from basic chatbots.

Explicit Planning

Deep Agents don’t just “act step-by-step” through prompting magic. They use a built-in write_todos tool to maintain a structured, stateful checklist. This list is persisted in the agent’s state, allowing it to track progress, mark tasks as completed or in_progress, and adapt its plan as new information arrives.

Native Context Management

One of the biggest breakthroughs in the Deep Agents SDK is the Virtual Filesystem. When an agent performs a search that returns 50,000 tokens of data, a normal agent would crash the context window.

A Deep Agent automatically offloads this data to a file (e.g., research_results.txt) and only keeps a 10-line preview in its active prompt. It can then use tools like read_file, grep, or edit_file to interact with that data selectively.

Sub-Agent Spawning

Context hygiene is vital. When the main agent needs to “go deep” on a specific sub-problem, it uses the task tool to spawn a specialized sub-agent. This sub-agent has its own clean context window. Once the sub-task is complete, the sub-agent returns only the final result to the main agent, keeping the primary conversation history free of clutter.

Shell & Sandbox Execution

For technical workflows, Deep Agents can be equipped with an execute tool. When running in a sandboxed environment (like Modal or Daytona), the agent can safely run shell commands, install dependencies, and execute code to verify its own work before presenting it to you.

Building Your First Deep Agent

Getting started with Deep Agents is streamlined. Since the harness is built on LangGraph, it inherits durable execution and “human-in-the-loop” capabilities.

from deepagents import create_deep_agent
from langchain.chat_models import init_chat_model

# 1. Initialize your preferred model (e.g., GPT-4o or Claude 3.5 Sonnet)
model = init_chat_model("openai:gpt-4o")

# 2. Create the agent harness with built-in planning and filesystem tools
agent = create_deep_agent(
    model=model,
    system_prompt="You are a senior research engineer focused on AI architecture."
)

# 3. Invoke the agent on a long-horizon task
result = agent.invoke({
    "messages": [{"role": "user", "content": "Research the top 5 vector databases and write a technical comparison file."}]
})

Adding Custom Sub-Agents

You can also define specialized sub-agents to handle specific parts of your workflow:

from deepagents import Subagent

# Define a specialized sub-agent for code review
reviewer = Subagent(
    name="code-reviewer",
    system_prompt="Analyze code for security vulnerabilities and performance bottlenecks.",
    tools=[] # Add specific security scanning tools here
)

# Attach the sub-agent to the main harness
agent = create_deep_agent(
    model=model,
    subagents=[reviewer]
)

Why Deep Agents?

The shift from simple chat loops to Deep Agents marks a turning point in AI productivity. We are moving away from “prompt engineering” toward “Agentic Systems Engineering.” By leveraging planning, filesystems, and delegation, Deep Agents solve the reliability problems that have plagued autonomous systems. They allow us to stop treating AI as a chatbot and start treating it as a digital workforce.

MULTI-MODEL INTELLIGENCE Orush CHAT WITHOUT LIMITS OrushMULTI-MODEL INTELLIGENCE Orush CHAT WITHOUT LIMITS OrushMULTI-MODEL INTELLIGENCE Orush CHAT WITHOUT LIMITS OrushMULTI-MODEL INTELLIGENCE Orush CHAT WITHOUT LIMITS OrushMULTI-MODEL INTELLIGENCE Orush CHAT WITHOUT LIMITS OrushMULTI-MODEL INTELLIGENCE Orush CHAT WITHOUT LIMITS OrushMULTI-MODEL INTELLIGENCE Orush CHAT WITHOUT LIMITS OrushMULTI-MODEL INTELLIGENCE Orush CHAT WITHOUT LIMITS OrushMULTI-MODEL INTELLIGENCE Orush CHAT WITHOUT LIMITS OrushMULTI-MODEL INTELLIGENCE Orush CHAT WITHOUT LIMITS Orush
ORUSH AI

One chat. Infinite intelligence.

The multi-model platform built for thinkers, creators,
and teams who move faster than the future.

ORUSH AI

© 2026 Orush AI Technologies. All rights reserved