Orchestrating Large-Scale Sub-agents with Dynamic Workflows
Blog

Orchestrating Large-Scale Sub-agents with Dynamic Workflows

2026.05.29
·Web·by Mineru
#Agent#Automation#Claude Code#JavaScript#Workflow

Key Points

  • 1Dynamic workflows are JavaScript scripts coordinated by Claude to orchestrate numerous sub-agents at scale, codifying complex, repeatable multi-step tasks that surpass single-turn interaction capabilities.
  • 2They are designed for large-scale operations such as comprehensive code audits, extensive migrations, or research requiring cross-validation, allowing tens to hundreds of agents to run in the background with pause and resume functionality.
  • 3Users can execute bundled workflows, prompt Claude to generate custom workflow scripts, or enable `ultracode` for automatic workflow planning, then manage their execution and save them for reuse across sessions or projects.

Dynamic Workflows in Claude Code represent a sophisticated paradigm for orchestrating multi-agent tasks at scale. Unlike traditional sub-agents or skills where Claude maintains the operational plan and holds intermediate results within its context window, dynamic workflows externalize the orchestration logic into a re-executable JavaScript script generated by Claude. This shifts the control flow from Claude's real-time conversational context to a predefined, structured program.

The core methodology of dynamic workflows involves Claude generating a JavaScript script that encapsulates the sequence, branching logic, and parallel execution of numerous sub-agents. This script is then executed by a dedicated workflow runtime environment, isolated from the conversational session. Key technical distinctions include:

  1. Plan Codification: The operational plan, encompassing sequences, loops, and conditional branches, is explicitly coded in JavaScript. This allows for rigorous, repeatable execution patterns and complex logical flows that are difficult to manage within a conversational context. For instance, processes involving adversarial review (where independent agents cross-validate findings) or comparative analysis (generating multiple plans and evaluating them) are greatly facilitated.
  2. State Management: Intermediate results generated by sub-agents within a workflow are stored as variables within the workflow script's runtime environment, rather than being passed back into Claude's context window. This reduces context window pressure on Claude and allows for more complex stateful operations across a prolonged execution.
  3. Asynchronous and Background Execution: Workflows run in the background, ensuring the main conversational session remains responsive. Users can monitor progress via a dedicated /workflows interface, which displays execution statistics such as agent count, token usage, and elapsed time per step.
  4. Resumability: The workflow runtime tracks the results of each agent, enabling the ability to pause and resume a workflow within the same Claude Code session. Completed agent tasks are cached, allowing the workflow to pick up exactly where it left off, which is crucial for long-running, multi-step processes.
  5. Agent Orchestration: While the workflow script dictates the overall orchestration, the actual task execution (e.g., file system access, shell commands, web fetches) is delegated to individual sub-agents generated by the workflow. The workflow script itself does not directly interact with the file system or shell; it orchestrates the agents that do. Each agent operates within an acceptEdits mode and inherits the session's tool allowlist.

Workflows can be initiated either by explicitly including the "workflow" keyword in a prompt, which instructs Claude to generate a script for the given task, or by activating "ultracode" mode (/effort ultracode), where Claude intelligently decides whether a task warrants a workflow-based approach. Pre-bundled workflows, such as /deep-research, serve as examples of complex, multi-agent operations (e.g., extensive web searching, cross-validation, and report synthesis) that leverage this framework.

Constraints on workflow execution include a maximum of 16 concurrent agents (adjusted for CPU cores) and a total of 1,000 agents per run, designed to prevent resource exhaustion and runaway processes. While interactive prompts for tool permissions can occur during a run if tools are not allowlisted, advanced permission modes (claude -p, Agent SDK) can bypass these interactive confirmations, relying on pre-configured rules. This structured, code-driven approach to multi-agent orchestration enables higher scalability, repeatability, and control over complex AI-driven tasks within the Claude Code environment.