Dynamic Workflows and Ultracode NEW
Delegate 100 agents sequentially and your context collapses first. Dynamic workflows solve this by keeping the plan in script variables rather than in Claude’s context — intermediate results stay in the script, and only the final result returns to the session. It is where tokenomics meets loop engineering: enabling massive fan-out while containing context cost.
InfoOne-line summary: Dynamic workflows are automation scripts written in JavaScript that orchestrate dozens to hundreds of agents in parallel. Ultracode is triggered by/effort ultracodeor theultracodekeyword.
Platform basicsBackground on the platform layer is in Dynamic Workflows. This page is the MoAI-ADK account of it.
MoAI-ADK provides 3 orchestration primitives, and the selection criterion is “who holds the plan.”
MoAI’s default mode — delegating one agent per turn, in sequence.
| Characteristic | Description |
|---|---|
| Plan location | Claude’s context (turn-by-turn judgment) |
| Intermediate results | Accumulate in Claude’s context window |
| Parallelism | Sequential execution (1 agent per turn) |
| Scale | Typically 3-5 agents |
| Context cost | Every agent result consumes context |
When to use:
- Simple 1-5 agent tasks
- Coding-centric run-phase work
- When agents have many inter-dependencies
A mode where multiple teammates collaborate via a shared TaskList.
| Characteristic | Description |
|---|---|
| Plan location | Shared TaskList (cross-team coordination) |
| Intermediate results | TaskList + each teammate’s context |
| Parallelism | 3-5 concurrent (Anthropic recommendation) |
| Scale | Small teams (3-5 members) |
| Context cost | Independent context per teammate |
When to use:
- Multiple teammates working in parallel
- Cross-layer dependencies (backend ↔ frontend)
- Collaboration and review between teammates needed
WarningIn v3.0, MoAI’s Agent Teams static orchestration layer was retired. Forcing--teamfalls back to sub-agent mode. The native Claude Code teammate runtime (e.g. the GLM panes ofmoai cg) continues to operate.
Automation scripts written in JavaScript orchestrate many agents.
| Characteristic | Description |
|---|---|
| Plan location | Script code (declarative plan) |
| Intermediate results | Script variables (no context accumulation) |
| Parallelism | Up to 16 concurrent (up to 1000 total) |
| Scale | Very large (dozens to hundreds of agents) |
| Context cost | Only the final result consumes context |
When to use:
- Large-scale parallel work (dozens to hundreds of agents)
- Whole-codebase scans
- Large migrations
- Cross-source verification
A flowchart for deciding which primitive to choose.
flowchart TD
START[Assess task characteristics] --> Q1{How many independent
agents needed?}
Q1 -->|1-5| Q2{Parallel execution
required?}
Q1 -->|5-10| Q3{Very
complex?}
Q1 -->|10+| WORKFLOW["Choose Dynamic Workflow
Optimal for parallel scripts"]
Q2 -->|No| SUBAGENT["Sequential Sub-agent
Sequential delegation"]
Q2 -->|Yes| TEAMS["Agent Teams
Team collaboration"]
Q3 -->|Yes| TEAMS
Q3 -->|No| SUBAGENT
SUBAGENT --> DONE["✓ Selection complete"]
TEAMS --> DONE
WORKFLOW --> DONE/effort ultracodeEnables automatic workflow generation for all substantive work in the current session.
Effects:
- Reasoning effort: set to
xhigh - Automatic workflow generation enabled
- The optimal orchestration primitive is chosen per task
When to use:
- Very complex multi-phase work
- Large projects that need automatic orchestration
If you want to trigger a workflow for a single request rather than the whole session, use the keyword.
> Find and classify all TODO comments in our codebase.
> (Without the ultracode keyword, runs as a regular sub-agent)
VS
> ultracode: Find and classify all TODO comments in our codebase.
> (Automatically generates a workflow)// Workflow script: classify TODOs across the entire codebase
const packages = [
"internal/auth",
"internal/api",
"internal/db",
"pkg/utils"
];
const results = [];
for (const pkg of packages) {
// Create an independent agent for each package
const result = await agent({
agentType: "Explore",
model: "sonnet",
effort: "low",
prompt: `
Find and classify all TODO comments in the ${pkg} package.
Format: [file] [line] [category] [content]
`
});
results.push({ pkg, todos: result });
}
// Final consolidation
const summary = {
total_packages: packages.length,
package_summaries: results,
grand_total_todos: results.reduce((sum, r) => sum + r.todos.length, 0)
};
return summary;| Item | Description |
|---|---|
| Agent creation | Dynamically created in a loop (await agent({...})) |
| Intermediate results | Stored in script variables (no context accumulation) |
| Parallel execution | Independent tasks auto-parallelized (up to 16 concurrent) |
| Final return | Only the consolidated result returns to the current session |
Workflow agents cannot interact with the user directly.
✗ A workflow agent raising a question to the user → not possible
✓ The MoAI orchestrator collects all choices up front → then runs the workflowResolution:
- The MoAI orchestrator calls
AskUserQuestion - Collects the user’s responses
- Runs the workflow with the responses included in its input
Workflow execution requires user approval just like any run phase. A massive fan-out does not make the human gate disappear.
/moai run --workflow SPEC-XXX
→ MoAI: "Running this SPEC as a workflow. Proceed?"
→ AskUserQuestion approval requiredDynamic workflows save context, but total token consumption can be large. The fan-out scale is the cost.
| Task | Agent count | Expected cost |
|---|---|---|
| Small package scan | 5 | Low |
| Mid-size codebase | 20 | Medium |
| Full repo scan | 100+ | High |
Cost controls:
- Model: use
sonnetlow effort (read-only extraction) - Agent count: limit scope (
packages.slice(0, 20)) - Parallelism: manually tune down from the max of 16
Dynamic workflows run only under the following conditions.
- Claude Code v2.1.154+
- A paid plan (Pro or Team)
"disableWorkflows": falsein/config
Can be disabled at the organization or user level.
/config
# Turn off the dynamic workflows toggle
OR
export CLAUDE_CODE_DISABLE_WORKFLOWS=1- Builder Agents and Harness v4 - dynamic team creation
- Agent Guide - agent system overview
- SPEC-Based Development - integrated workflow
InfoTip: For small workloads, Sequential Sub-agents suffice. Use dynamic workflows only when you need to “orchestrate dozens to hundreds of independent tasks in parallel” — and remember that the fan-out itself is the cost.