🟡 🤝 Agents Published: · 2 min read ·

LangChain: Dynamic Subagents in Deep Agents — Agent Writes Code That Dispatches Hundreds of Subagents in Parallel

Editorial illustration: Dynamic Subagents in Deep Agents — agent writes code that dispatches hundreds of subagents in parallel, without text or faces

Dynamic Subagents is an orchestration architecture within the LangChain Deep Agents framework that enables a model to write a JavaScript script for parallel dispatch of hundreds of subagents. A QuickJS interpreter executes the script deterministically, eliminating 300+ sequential tool invocations. The system defines six orchestration patterns — from classify-and-act to loop-until-done.

🤖

This article was generated using artificial intelligence from primary sources.

LangChain has released Dynamic Subagents within its Deep Agents framework — an orchestration architecture that radically changes how AI agents coordinate complex tasks. Instead of sequential tool calls, the model now writes a JavaScript script executed by QuickJS — a lightweight, deterministic interpreter embedded directly in the pipeline. That script dispatches hundreds of subagents in parallel, without waiting for sequence.

Classic Agent vs. Dynamic Orchestration

Classic agents go through 300+ individual tool invocations and are prone to random scope truncation: they estimate 75 of 500 items and stop. Dynamic Subagents eliminate that problem. LangChain guarantees deterministic coverage of the entire dataset because the Deep Agents framework runs all subagents in parallel — not sequentially. Writing code for dispatch is fundamentally different from classic tool calling: the agent gets control structures (loops, branching, parallelism) that tool invocations simply cannot offer.

The task() Function and QuickJS Runtime

The heart of the system is the global task() function within the QuickJS interpreter. It takes three parameters: description (task description), subagentType (specialist type for routing), and optional responseSchema (typed output ready for filtering). A script can call task() hundreds of times in a single pass — all calls run in parallel. Installation: pip install -U "deepagents[quickjs]", with CodeInterpreterMiddleware activating the QuickJS runtime in the pipeline.

Six Orchestration Patterns for Every Scenario

Deep Agents defines six orchestration patterns: classify-and-act (classify and route to specialists), fanout-and-synthesize (parallel work, merged results), adversarial verification (two independent verifiers), generate-and-filter (multiple solutions and scoring), tournament (elimination rounds), and loop-until-done (repeat until no new findings).

Why Is Writing Code Better Than Sequential Calls?

The conceptual basis is Recursive Language Models — models that write code that dispatches more models. Dynamic Subagents in the LangChain Deep Agents framework turn that idea into a production tool: complex workflows that previously required hundreds of sequential steps now run deterministically and in parallel, with full data coverage regardless of dataset size.

Frequently Asked Questions

What is QuickJS and why does LangChain use it in the Dynamic Subagents architecture?
QuickJS is a lightweight, deterministic JavaScript interpreter that within the Deep Agents framework executes orchestration scripts. It enables safe and predictable code execution without external dependencies, making the dispatch of hundreds of subagents reliable and reproducible.
How do Dynamic Subagents differ from classic tool calling?
Classic agents execute tool calls sequentially — one at a time — and are prone to scope truncation (e.g., estimating 75 instead of 500 items and stopping). Dynamic Subagents write a script that in one pass dispatches hundreds of subagents in parallel with deterministic coverage of the entire dataset.