Skip to content

Commit fc019e5

Browse files
committed
Add documentation for the switch_mode tool and its functionality
1 parent 25b6a39 commit fc019e5

File tree

1 file changed

+151
-0
lines changed

1 file changed

+151
-0
lines changed

docs/features/tools/switch-mode.md

Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
# switch_mode
2+
3+
The `switch_mode` tool enables Roo to change between different operational modes, each with specialized capabilities for specific types of tasks. This allows seamless transitions between modes like Code, Architect, Ask, or Debug when the current task requires different expertise.
4+
5+
## Parameters
6+
7+
The tool accepts these parameters:
8+
9+
- `mode_slug` (required): The slug of the mode to switch to (e.g., "code", "ask", "architect")
10+
- `reason` (optional): The reason for switching modes, providing context for the user
11+
12+
## What It Does
13+
14+
This tool requests a mode change when the current task would be better handled by another mode's capabilities. It maintains context while shifting Roo's focus and available toolsets to match the requirements of the new task phase.
15+
16+
## When is it used?
17+
18+
- When transitioning from information gathering to code implementation
19+
- When shifting from coding to architecture or design
20+
- When the current task requires capabilities only available in a different mode
21+
- When specialized expertise is needed for a particular phase of a complex project
22+
23+
## Key Features
24+
25+
- Maintains context continuity across mode transitions
26+
- Provides clear reasoning for mode switch recommendations
27+
- Requires user approval for all mode changes
28+
- Enforces tool group restrictions specific to each mode
29+
- Seamlessly adapts tool availability based on the selected mode
30+
- Works with both standard and custom modes
31+
- Displays the mode switch and reasoning in the UI
32+
- Uses XML-style formatting for parameter specification
33+
- Handles file type restrictions specific to certain modes
34+
35+
## Limitations
36+
37+
- Cannot switch to modes that don't exist in the system
38+
- Requires explicit user approval for each mode transition
39+
- Cannot use tools specific to a mode until the switch is complete
40+
- Applies a 500ms delay after mode switching to allow the change to take effect
41+
- Some modes have file type restrictions (e.g., Architect mode can only edit markdown files)
42+
- Mode preservation for resumption applies only to the `new_task` functionality, not general mode switching
43+
44+
## How It Works
45+
46+
When the `switch_mode` tool is invoked, it follows this process:
47+
48+
1. **Request Validation**:
49+
- Validates that the requested mode exists in the system
50+
- Checks that the `mode_slug` parameter is provided and valid
51+
- Verifies the user isn't already in the requested mode
52+
- Ensures the `reason` parameter (if provided) is properly formatted
53+
54+
2. **Mode Transition Preparation**:
55+
- Packages the mode change request with the provided reason
56+
- Presents the change request to the user for approval
57+
58+
3. **Mode Activation (Upon User Approval)**:
59+
- Updates the UI to reflect the new mode
60+
- Adjusts available tools based on the mode's tool group configuration
61+
- Applies the mode-specific prompt and behavior
62+
- Applies a 500ms delay to allow the change to take effect before executing next tool
63+
- Enforces any file restrictions specific to the mode
64+
65+
4. **Continuation**:
66+
- Proceeds with the task using the capabilities of the new mode
67+
- Retains relevant context from the previous interaction
68+
69+
## Tool Group Association
70+
71+
The `switch_mode` tool belongs to the "modes" tool group but is also included in the "always available" tools list. This means:
72+
73+
- It can be used in any mode regardless of the mode's configured tool groups
74+
- It's available alongside other core tools like `ask_followup_question` and `attempt_completion`
75+
- It allows mode transitions at any point in a workflow when task requirements change
76+
77+
## Mode Structure
78+
79+
Each mode in the system has a specific structure:
80+
81+
- `slug`: Unique identifier for the mode (e.g., "code", "ask")
82+
- `name`: Display name for the mode (e.g., "Code", "Ask")
83+
- `roleDefinition`: The specialized role and capabilities of the mode
84+
- `customInstructions`: Optional mode-specific instructions that guide behavior
85+
- `groups`: Tool groups available to the mode with optional restrictions
86+
87+
## Mode Capabilities
88+
89+
The core modes provide these specialized capabilities:
90+
91+
- **Code Mode**: Focused on coding tasks with full access to code editing tools
92+
- **Architect Mode**: Specialized for system design and architecture planning, limited to editing markdown files only
93+
- **Ask Mode**: Optimized for answering questions and providing information
94+
- **Debug Mode**: Equipped for systematic problem diagnosis and resolution
95+
96+
## Custom Modes
97+
98+
Beyond the core modes, the system supports custom project-specific modes:
99+
100+
- Custom modes can be defined with specific tool groups enabled
101+
- They can specify custom role definitions and instructions
102+
- The system checks custom modes first before falling back to core modes
103+
- Custom mode definitions take precedence over core modes with the same slug
104+
105+
## File Restrictions
106+
107+
Different modes may have specific file type restrictions:
108+
109+
- **Architect Mode**: Can only edit files matching the `.md` extension
110+
- Attempting to edit restricted file types results in a `FileRestrictionError`
111+
- These restrictions help enforce proper separation of concerns between modes
112+
113+
## Examples When Used
114+
115+
- When discussing a new feature, Roo switches from Ask mode to Architect mode to help design the system structure.
116+
- After completing architecture planning in Architect mode, Roo switches to Code mode to implement the designed features.
117+
- When encountering bugs during development, Roo switches from Code mode to Debug mode for systematic troubleshooting.
118+
119+
## Usage Examples
120+
121+
Switching to Code mode for implementation:
122+
```
123+
<switch_mode>
124+
<mode_slug>code</mode_slug>
125+
<reason>Need to implement the login functionality based on the architecture we've discussed</reason>
126+
</switch_mode>
127+
```
128+
129+
Switching to Architect mode for design:
130+
```
131+
<switch_mode>
132+
<mode_slug>architect</mode_slug>
133+
<reason>Need to design the system architecture before implementation</reason>
134+
</switch_mode>
135+
```
136+
137+
Switching to Debug mode for troubleshooting:
138+
```
139+
<switch_mode>
140+
<mode_slug>debug</mode_slug>
141+
<reason>Need to systematically diagnose the authentication error</reason>
142+
</switch_mode>
143+
```
144+
145+
Switching to Ask mode for information:
146+
```
147+
<switch_mode>
148+
<mode_slug>ask</mode_slug>
149+
<reason>Need to answer questions about the implemented feature</reason>
150+
</switch_mode>
151+
```

0 commit comments

Comments
 (0)