AGENT INCOME .IO

AI agents, agentic coding, and passive income.

LangChain Deep Agents Tutorial: When You Need More Than a Tool-Calling Loop


This LangChain Deep Agents tutorial is for the moment when a normal agent stops being enough. A simple tool-calling loop is fine when the task is short and the context stays small. It starts to fall apart when the agent has to plan, juggle big tool outputs, delegate subtasks, write files, and keep going without drowning in its own context window.

That is the problem Deep Agents is trying to solve. LangChain describes it as an agent harness built on LangGraph, with planning, filesystem tools, subagent spawning, and long-term memory baked in. In plain English: it gives you a more opinionated starting point for long-running agents, especially if your current stack feels like prompt glue held together with retries.

If you want the positioning first, Deep Agents sits somewhere between the leaner OpenAI Agents SDK tutorial approach and the explicit workflow engineering you get with Google ADK tutorial. Under the hood it still leans on LangGraph, which matters if you’ve been weighing graph-based orchestration after reading LangGraph vs CrewAI.

Why Deep Agents matters right now

The timing is good.

This week, Deep Agents picked up a real momentum spike. LangChain’s own GTM agent write-up says they used Deep Agents for a long-running workflow that had to research leads, manage large amounts of context, and hand drafts to humans for approval. NVIDIA also published a walkthrough showing Deep Agents inside its AI-Q blueprint for deep research and enterprise search. That combination matters because it shows two things:

  • LangChain is pushing Deep Agents beyond toy demos
  • other vendors are starting to treat it as real infrastructure, not just a repo experiment

That creates the exact kind of search window worth targeting. When developers start seeing a new runtime show up in official blog posts, examples, and integrations, they go looking for practical tutorials before the keyword gets crowded.

What LangChain Deep Agents actually is

Deep Agents is not a new model and not a completely separate framework. It is a higher-level harness built on top of LangChain and the LangGraph runtime.

The official docs call out a few built-in capabilities:

  • planning and task decomposition via a write_todos tool
  • filesystem tools like ls, read_file, write_file, and edit_file
  • subagent spawning through a built-in task tool
  • pluggable backends for memory, local disk, or sandboxed execution
  • long-term memory support when you wire it into LangGraph persistence

That feature mix tells you what Deep Agents is for: tasks where context is messy, the work takes multiple steps, and you do not want to hand-build every orchestration primitive yourself.

If your agent only calls two APIs and returns JSON, this is probably overkill. If your agent researches, writes, revises, delegates, and needs to survive variable tool outputs, it starts to make more sense.

LangChain Deep Agents tutorial: your first working agent

Start with a clean Python environment and install the package:

python -m venv .venv
source .venv/bin/activate
pip install -U deepagents langchain

Now create a tiny agent with one tool:

from deepagents import create_deep_agent


def get_server_status(service: str) -> str:
    """Return a fake health summary for a service."""
    services = {
        "api": "API is healthy with 99.97% uptime this week.",
        "billing": "Billing has one degraded dependency but is serving requests.",
        "dashboard": "Dashboard is healthy with normal response times.",
    }
    return services.get(service, "Service not found.")


agent = create_deep_agent(
    tools=[get_server_status],
    system_prompt="You are an operations assistant. Use tools before making claims about system health.",
)

result = agent.invoke(
    {
        "messages": [
            {"role": "user", "content": "Check the API and billing services and summarize the risks."}
        ]
    }
)

print(result)

This is the basic Deep Agents mental model: you are still building an agent, but the harness comes with more structure than the average one-file example. You are not just handing a model some tools. You are giving it a runtime that expects planning, file operations, and delegation when the task calls for it.

What makes it different from a normal agent loop

The biggest practical difference is context management.

Most basic agent setups keep shoving everything back into the conversation. Tool results get longer, model outputs get longer, and eventually you either blow out the context window or start trimming useful information. Deep Agents takes a different approach: it can offload large intermediate artifacts into a virtual filesystem and let the agent work against those files.

That is more important than it sounds.

If you are building a research agent, a content agent, a support analyst, or anything that needs to inspect lots of raw material, the bottleneck is not usually the model itself. It is context discipline. Deep Agents gives you tools that make the model behave more like a worker handling documents than a chatbot trying to remember a giant transcript.

The second big difference is subagents. Instead of one agent trying to do everything in one context window, Deep Agents can spawn specialized subagents with narrower jobs. That reduces context pollution and makes runs easier to reason about.

This is the same general lesson behind graph-based systems: the more responsibilities you pile into one loop, the harder it gets to debug, evaluate, and control.

A more realistic pattern: research agent with files and delegation

Here is the kind of pattern where Deep Agents starts earning its keep:

from deepagents import create_deep_agent


def search_docs(query: str) -> str:
    """Pretend this searches your docs or knowledge base."""
    return f"Search results for: {query}"


def get_pricing(page: str) -> str:
    """Pretend this fetches pricing or package data."""
    return f"Pricing data from {page}"


agent = create_deep_agent(
    tools=[search_docs, get_pricing],
    system_prompt=(
        "You are a SaaS research assistant. Break large tasks into steps, "
        "save intermediate findings to files, and delegate focused subtasks when useful."
    ),
)

agent.invoke(
    {
        "messages": [
            {
                "role": "user",
                "content": (
                    "Research three competitors, compare their pricing, "
                    "and draft a recommendation memo for a founder."
                ),
            }
        ]
    }
)

In a normal tool-calling agent, you would often end up building your own scratchpad, your own artifact storage, your own delegation logic, and your own conventions for when to summarize or trim context. Deep Agents gives you a bunch of that up front.

That does not mean it magically becomes correct. It means you spend less time building scaffolding and more time tuning the actual workflow.

Where it fits in a real product

The most useful use cases are boring, which is a good sign.

Deep Agents fits products where the agent has to:

  • inspect a lot of information
  • maintain a working plan
  • create intermediate artifacts
  • split work across specialists
  • hand something auditable back to a user or internal team

Think about a few examples:

  • a sales research agent that reads CRM notes, web results, and call summaries before drafting outreach
  • a support analyst that investigates logs, docs, and recent incidents before proposing a fix
  • a publishing pipeline that researches sources, drafts content, and saves artifacts for later editing
  • a code or ops assistant that needs shell access, file edits, and structured subtasks

That is why the recent LangChain GTM agent example matters. It is not just a benchmark story. It is a pretty normal business workflow with enough moving parts to break simpler agents.

The production tradeoffs you should care about

Deep Agents is interesting, but you should be honest about the cost.

First, the power comes from giving the agent more capability. File access, shell access, subagents, memory, and sandboxes are useful. They also widen the blast radius if you are careless. The Deep Agents repo is explicit about its security posture: enforce boundaries at the tool and sandbox layer, not by hoping the model behaves itself.

That means you should treat tools as permissions, not conveniences.

If you let the agent read from disk, decide which directories matter. If you let it execute commands, use a sandbox. If you let it write files, make those writes observable and reviewable. If you need external integrations, using something like an MCP server tutorial style setup can keep tool boundaries cleaner than a random pile of direct wrappers.

Second, opinionated harnesses save time until you need something they did not anticipate. Deep Agents is faster than rolling your own runtime, but there will be moments where dropping lower into LangGraph gives you more explicit control. That is not a flaw. It is just the tradeoff between convenience and total ownership.

Third, you still need evals. LangChain’s own GTM post makes this point clearly: trace runs, measure outcomes, and treat unexplained behavior drift like a bug. Deep Agents helps with execution. It does not remove the need for testing.

Should you use Deep Agents or something else?

Use Deep Agents if you want:

  • an opinionated starting point for long-running tasks
  • built-in planning, file tools, and delegation
  • LangGraph under the hood without wiring every primitive yourself
  • a path toward memory, sandboxes, and more durable execution

Use something simpler if:

  • your agent is basically one prompt plus two tools
  • you do not need file-backed context
  • you want very explicit control over every node and edge
  • your main problem is UI or app integration, not orchestration

My rough take in March 2026:

  • use the OpenAI Agents SDK for lighter single-flow apps
  • use Google ADK if you want structured multi-agent composition with Google’s ecosystem story
  • use Deep Agents when your main pain is long-running work, context sprawl, and task delegation
  • use raw LangGraph when you want maximum control and are willing to pay for it in complexity

That last point matters. Deep Agents is not a replacement for understanding orchestration. It is a shortcut to a better default.

A practical way to ship with it

If I were using Deep Agents for something revenue-linked this week, I would keep the first version narrow:

  1. pick one workflow with obvious business value
  2. keep the tool set small and explicit
  3. store intermediate artifacts so runs are inspectable
  4. add human review before any external action
  5. trace everything from day one

For an indie hacker, that could mean a lead research assistant, a support triage worker, a reporting agent, or a content pipeline. You do not need a giant multi-agent company simulation. You need one workflow that is too messy for a toy agent and valuable enough to justify the extra runtime.

That is where Deep Agents feels strongest.

Final verdict

Deep Agents is one of the more useful additions to the LangChain stack in a while because it targets a real pain point: agents that need to stay useful after the demo.

The pitch is not that it is magical. The pitch is that planning, files, delegation, and memory should not be afterthoughts once your agent starts doing real work. If your current setup keeps collapsing into prompt soup, Deep Agents is worth learning.

Start small. Give it a constrained job. Put hard boundaries around its tools. Then see if the harness saves you enough engineering time to justify the abstraction.

For a lot of practical agent products in 2026, it probably will.

Sources