…
Module 2 · Part C of 3

Deep Agents

A deep research agent applies the same idea to a question whose evidence would outgrow one conversation. At run time, a planner chooses independent branches and gives each worker only the original question, its assigned task, and the tools it needs. Sibling histories stay outside. A final stage synthesizes the evidence that the workers preserve. Run the pattern first, then inspect its implementation.

How the workflow boundary changes

The outer workflow owns scope and data flow throughout Module 2. Retrieval and deep research place the boundary differently.

Either workflow can place a ReAct loop inside a stage that must adapt to intermediate results.

Why a shared context breaks down

A single ReAct loop keeps every instruction and observation in one history, so earlier evidence competes with each new tool result. Eventually the history itself becomes part of the problem.

One coordinator assigns focused work. Independent workers return evidence through shared storage, and a final step combines it.

How research moves through the workflow

1 · Plan

The orchestrator turns the question into independent tasks, making the intended scope inspectable before work begins.

2 · Investigate

Each sub-agent receives one task in a fresh context that excludes the histories of other branches.

3 · Preserve

Workers write findings to a shared virtual filesystem, where evidence survives after their contexts end.

4 · Synthesize

The orchestrator reads the saved evidence and produces one answer whose claims remain traceable to their branches.

Fresh context is not a sandbox. Context isolation separates the branches' reasoning, while a sandbox limits operating-system access. The browser artifact below has no shell; the later hand-rolled example uses an in-memory filesystem to make shared state visible.

Try it · plan, investigate, and synthesize

Ask a research question and watch the agent create branches that run in parallel across curated external materials and this course before writing one cited answer. Each worker streams into its own focusable panel, so you can inspect active operations instead of waiting for the entire fan-out to finish.

Inspect the implementation

The next three independent examples connect a model client, build a clock-tool graph, and save worker drafts in shared files. The last example isolates file exchange without retrieving external evidence.

The implementation cells use the vendored browser bundle. They import the exact same-origin bundle recorded in the browser dependency inventory, where you can inspect its version and source.
Build the planner, workers, and shared state?

1 · Connect the model

ChatOpenAI wraps any OpenAI-compatible endpoint. The cell reads the active URL and credential from helpers.getConfig(), so the rest of the graph does not depend on where the model runs.

.invoke() returns a complete message; .stream() yields partial messages. Both satisfy LangChain's Runnable interface.

2 · Turn the loop into a graph

createReactAgent({llm, tools}) turns the Module 1 ReAct loop into explicit model and tool nodes. The compiled graph can run alone or become one node inside a larger workflow.

Use a graph once a simple loop can no longer express the required control flow.

3 · Save and combine worker drafts

This example drafts from model knowledge: workers have file tools but no retrieval tool or supplied sources. Files preserve their drafts, not independently checked evidence. The workers run sequentially and share saved files. The deepagents package wraps a similar pattern for Node.js applications.

Check your understanding

  1. What enters each sub-agent's context, and what stays out?
  2. Why preserve findings instead of passing one growing transcript?
  3. How do context isolation and operating-system sandboxing prevent different failures?
Trace the deep-research implementation sources?

References

Comprehensive list at Going Further · References.

← Module 2b: The Index Agent