|
| 1 | +--- |
| 2 | +sidebar_position: 9 |
| 3 | +--- |
| 4 | + |
| 5 | +# Sub-Agent Workflow Modes |
| 6 | + |
| 7 | +MyCoder supports different modes for working with sub-agents, giving you flexibility in how tasks are distributed and executed. You can configure the sub-agent workflow mode based on your specific needs and resource constraints. |
| 8 | + |
| 9 | +## Available Modes |
| 10 | + |
| 11 | +MyCoder supports three distinct sub-agent workflow modes: |
| 12 | + |
| 13 | +### 1. Disabled Mode |
| 14 | + |
| 15 | +In this mode, sub-agent functionality is completely disabled: |
| 16 | + |
| 17 | +- No sub-agent tools are available to the main agent |
| 18 | +- All tasks must be handled by the main agent directly |
| 19 | +- Useful for simpler tasks or when resource constraints are a concern |
| 20 | +- Reduces memory usage and API costs for straightforward tasks |
| 21 | + |
| 22 | +### 2. Synchronous Mode ("sync") |
| 23 | + |
| 24 | +In synchronous mode, the parent agent waits for sub-agents to complete before continuing: |
| 25 | + |
| 26 | +- Uses the `agentExecute` tool for synchronous execution |
| 27 | +- Parent agent waits for sub-agent completion before continuing its own workflow |
| 28 | +- Useful for tasks that require sequential execution |
| 29 | +- Simpler to reason about as there's no parallel execution |
| 30 | +- Good for tasks where later steps depend on the results of earlier steps |
| 31 | + |
| 32 | +### 3. Asynchronous Mode ("async") - Default |
| 33 | + |
| 34 | +In asynchronous mode, sub-agents run in parallel with the parent agent: |
| 35 | + |
| 36 | +- Uses `agentStart`, `agentMessage`, and `listAgents` tools |
| 37 | +- Sub-agents run in the background while the parent agent continues its work |
| 38 | +- Parent agent can check status and provide guidance to sub-agents |
| 39 | +- Useful for complex tasks that can benefit from parallelization |
| 40 | +- More efficient for tasks that can be executed concurrently |
| 41 | +- Allows the parent agent to coordinate multiple sub-agents |
| 42 | + |
| 43 | +## Configuration |
| 44 | + |
| 45 | +You can set the sub-agent workflow mode in your `mycoder.config.js` file: |
| 46 | + |
| 47 | +```javascript |
| 48 | +// mycoder.config.js |
| 49 | +export default { |
| 50 | + // Sub-agent workflow mode: 'disabled', 'sync', or 'async' |
| 51 | + subAgentMode: 'async', // Default value |
| 52 | + |
| 53 | + // Other configuration options... |
| 54 | +}; |
| 55 | +``` |
| 56 | + |
| 57 | +You can also specify the mode via the command line: |
| 58 | + |
| 59 | +```bash |
| 60 | +mycoder --subAgentMode disabled "Implement a simple React component" |
| 61 | +``` |
| 62 | + |
| 63 | +## Choosing the Right Mode |
| 64 | + |
| 65 | +Consider these factors when choosing a sub-agent workflow mode: |
| 66 | + |
| 67 | +- **Task Complexity**: For complex tasks that can be broken down into independent parts, async mode is often best. For simpler tasks, disabled mode may be sufficient. |
| 68 | + |
| 69 | +- **Resource Constraints**: Disabled mode uses fewer resources. Async mode can use more memory and API tokens but may complete complex tasks faster. |
| 70 | + |
| 71 | +- **Task Dependencies**: If later steps depend heavily on the results of earlier steps, sync mode ensures proper sequencing. |
| 72 | + |
| 73 | +- **Coordination Needs**: If you need to coordinate multiple parallel workflows, async mode gives you more control. |
| 74 | + |
| 75 | +## Example: Using Different Modes |
| 76 | + |
| 77 | +### Disabled Mode |
| 78 | + |
| 79 | +Best for simple, focused tasks: |
| 80 | + |
| 81 | +```javascript |
| 82 | +// mycoder.config.js |
| 83 | +export default { |
| 84 | + subAgentMode: 'disabled', |
| 85 | + // Other settings... |
| 86 | +}; |
| 87 | +``` |
| 88 | + |
| 89 | +### Synchronous Mode |
| 90 | + |
| 91 | +Good for sequential, dependent tasks: |
| 92 | + |
| 93 | +```javascript |
| 94 | +// mycoder.config.js |
| 95 | +export default { |
| 96 | + subAgentMode: 'sync', |
| 97 | + // Other settings... |
| 98 | +}; |
| 99 | +``` |
| 100 | + |
| 101 | +### Asynchronous Mode |
| 102 | + |
| 103 | +Ideal for complex projects with independent components: |
| 104 | + |
| 105 | +```javascript |
| 106 | +// mycoder.config.js |
| 107 | +export default { |
| 108 | + subAgentMode: 'async', // This is the default |
| 109 | + // Other settings... |
| 110 | +}; |
| 111 | +``` |
| 112 | + |
| 113 | +## How It Works Internally |
| 114 | + |
| 115 | +- In **disabled mode**, no agent tools are added to the available tools list. |
| 116 | +- In **sync mode**, only the `agentExecute` and `agentDone` tools are available, ensuring synchronous execution. |
| 117 | +- In **async mode**, the full suite of agent tools (`agentStart`, `agentMessage`, `listAgents`, and `agentDone`) is available, enabling parallel execution. |
| 118 | + |
| 119 | +This implementation allows MyCoder to adapt to different task requirements while maintaining a consistent interface for users. |
0 commit comments