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.
- Index workflow. The developer defines the pipeline, and generation receives the bounded retrieval bundle from Part B.
- Deep-research workflow. The planner creates branches at run time. Workers receive task-specific context and store evidence for synthesis.
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.
- Overflow: evidence and tool output exceed the context window.
- Context rot: relevant evidence is present but under-weighted (Liu et al.).
- Interference: reasoning for one branch distracts the next branch.
How research moves through the workflow
The orchestrator turns the question into independent tasks, making the intended scope inspectable before work begins.
Each sub-agent receives one task in a fresh context that excludes the histories of other branches.
Workers write findings to a shared virtual filesystem, where evidence survives after their contexts end.
The orchestrator reads the saved evidence and produces one answer whose claims remain traceable to their branches.
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.
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
- What enters each sub-agent's context, and what stays out?
- Why preserve findings instead of passing one growing transcript?
- How do context isolation and operating-system sandboxing prevent different failures?
Deep · SourcesTrace the deep-research implementation sources?
References
- Liu et al., Lost in the Middle. Evidence for context-position failures.
- LangChain, Deep Agents and the JavaScript implementation.
- NVIDIA AI-Q deep research skill and its blueprint.
- Kosmos. A multi-agent scientific-research example.
Comprehensive list at Going Further · References.