Lesson 25: Subagents in Action: 4 Engines Compared
Benchmark the same objective and subagent profiles across FOUR orchestration engines: Naive Session, DAG Workflow, StateMachine, and MAA, plus background detached subagents.
1. Why This Feature Exists
Choosing the right orchestrator is critical. Running the exact same objective and profiles through all four architectures demonstrates the unique strengths, token efficiencies, and error resilience of each approach.
2. Key Symbols and Exports
3. Implementation Walkthrough
import {
ProviderType,
initializeClient,
loadCredentials,
withTaskAgents,
DiscussionSession,
StateMachine
} from 'merci-sdk';
import { WorkflowExecutor } from 'merci-sdk/planning';
import { resolveExample } from '../_shared/example-utils.mjs';
const { provider, defaultModel, toolModel } = resolveExample();
const { client } = await initializeClient({ provider, options: loadCredentials({ provider }) });
const PROFILES = [
{ name: 'researcher', model: toolModel, systemPrompt: 'Conduct detailed domain research.' },
{ name: 'writer', model: toolModel, systemPrompt: 'Draft clear, actionable documentation.' },
{ name: 'checker', model: toolModel, systemPrompt: 'Audit content for accuracy and completeness.' }
];
withTaskAgents(client, PROFILES, { maxDepth: 1 });
const OBJECTIVE = 'Plan a 3-day motorcycle trip from Prague to Dubrovnik in summer 2026.';
// Benchmark across all 4 engines
console.log('--- Engine A: Naive ---');
console.log('--- Engine B: DAG ---');
console.log('--- Engine C: StateMachine ---');
console.log('--- Engine D: MAA ---');4. Wire and Telemetry Mechanics
All four engines utilize the identical task tool registration and event bus, allowing direct side-by-side comparison of turn count, tokens, and output fidelity.
5. Run the Example
Execute the runnable example directly from the repository root:
node examples/15_delegation.mjsRead the full example: examples/15_delegation.mjs →