Module 2 · Part C of 3

Deep Agents

Module 2 treats workflow scope as a control surface. Part A introduced a harness that decides what context crosses each boundary, what can branch, and how results move through a pipeline. Part B applied that control to a developer-defined retrieval pipeline and its bounded context bundle.

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 → 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 cells isolate one implementation layer at a time, beginning with the model adapter and ending with the complete research agent. Each cell runs independently.

The implementation cells use the vendored browser bundle. They import the exact same-origin bundle recorded in the browser dependency inventory. CI blocks publication when the bundle, lock, license evidence, or source references drift.
Applied · BuildBuild 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 · Assemble the research agent

Each stage runs as its own node, and shared files remain visible between delegation and synthesis. 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?
Deep · SourcesTrace the deep-research implementation sources?

References

Comprehensive list at Going Further · References.

← Module 2b: The Index Agent