Delegation Patterns
Delegation lets Mona spawn child agents for parallel work. These patterns show when and how to use it effectively.
Pattern 1: Parallel research
Research multiple topics simultaneously:
I need to compare three database options for our project:
1. PostgreSQL — check features, licensing, hosted options
2. MongoDB — check features, licensing, hosted options
3. SQLite — check features, licensing, hosted options
Delegate each research task to a separate agent, then synthesize the results into a comparison table.
Pattern 2: Multi-file code review
Review multiple files in parallel:
Review these files for security issues:
- src/auth.ts
- src/middleware.ts
- src/routes/users.ts
- src/routes/payments.ts
Delegate one agent per file, then summarize all findings.
Pattern 3: Batch data processing
Process multiple data files:
I have 10 CSV files in data/2024/. For each file:
1. Validate the schema
2. Check for anomalies
3. Generate a summary
Delegate one agent per file, then combine the summaries into a report.
Pattern 4: A/B analysis
Compare two approaches:
I'm considering two architectures for our API:
Approach A: REST with OpenAPI
Approach B: GraphQL with Apollo
Delegate one agent to analyze Approach A, another to analyze Approach B. Compare pros, cons, and trade-offs. Recommend one with justification.
Pattern 5: Multi-step pipeline
Chain dependent tasks:
I need to:
1. Scrape https://example.com/products
2. Extract product names and prices
3. Compare with our pricing
4. Generate a competitive analysis
Step 1 can be delegated. Steps 2-4 depend on its output, so run sequentially after.
Pattern 6: Error recovery
Retry failed tasks with different parameters:
Try to build the project. If it fails:
1. Delegate an agent to diagnose the error
2. Delegate another agent to find a fix
3. Apply the fix and retry
When NOT to delegate
Don't delegate when:
- The task is simple and quick (< 30 seconds)
- The subtasks are highly dependent on each other
- You're hitting API rate limits
- Context window is already constrained
Configuration for delegation
# ~/.monoclaw/config.yaml
delegation:
max_agents: 5
default_timeout: 300
share_memory: true
retry_failed: true
Monitoring delegated tasks
monoclaw delegation status
Output:
Active delegations: 3
- Agent #1: Researching PostgreSQL (45s elapsed)
- Agent #2: Researching MongoDB (42s elapsed)
- Agent #3: Researching SQLite (40s elapsed)
Best practices
- Keep tasks independent — Agents work best in parallel
- Set timeouts — Prevent runaway agents
- Limit concurrency — 3-5 agents is usually optimal
- Synthesize results — Don't just concatenate outputs; combine them meaningfully
- Handle failures — One failed agent shouldn't crash the whole task