Skip to content

Commit 14bbd39

Browse files
committed
Add documentation for ask_followup_question tool and its functionality
1 parent 1a4bf0f commit 14bbd39

File tree

1 file changed

+169
-0
lines changed

1 file changed

+169
-0
lines changed
Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
# ask_followup_question
2+
3+
The `ask_followup_question` tool enables interactive communication by asking specific questions to gather additional information needed to complete tasks effectively.
4+
5+
## Parameters
6+
7+
The tool accepts these parameters:
8+
9+
- `question` (required): The specific question to ask the user
10+
- `follow_up` (optional): A list of 2-4 suggested answers that help guide user responses, each within `<suggest>` tags
11+
12+
## What It Does
13+
14+
This tool creates a conversational interface between Roo and the user, allowing for gathering clarification, additional details, or user preferences when facing ambiguities or decision points. Each question can include suggested responses to streamline the interaction.
15+
16+
## When is it used?
17+
18+
- When critical information is missing from the original request
19+
- When Roo needs to choose between multiple valid implementation approaches
20+
- When technical details or preferences are required to proceed
21+
- When Roo encounters ambiguities that need resolution
22+
- When additional context would significantly improve the solution quality
23+
24+
## Key Features
25+
26+
- Provides a structured way to gather specific information without breaking workflow
27+
- Includes suggested answers to reduce user typing and guide responses
28+
- Maintains conversation history and context across interactions
29+
- Supports responses containing images and code snippets
30+
- Available in all modes as part of the "always available" tool set
31+
- Enables direct user guidance on implementation decisions
32+
- Formats responses with `<answer>` tags to distinguish them from regular conversation
33+
- Resets consecutive error counter when used successfully
34+
35+
## Limitations
36+
37+
- Limited to asking one specific question per tool use
38+
- Presents suggestions as selectable options in the UI
39+
- Cannot force structured responses – users can still respond freely
40+
- Excessive use can slow down task completion and create a fragmented experience
41+
- Suggested answers must be complete, with no placeholders requiring user edits
42+
- No built-in validation for user responses
43+
- Contains no mechanism to enforce specific answer formats
44+
45+
## How It Works
46+
47+
When the `ask_followup_question` tool is invoked, it follows this process:
48+
49+
1. **Parameter Validation**: Validates the required `question` parameter and checks for optional suggestions
50+
- Ensures question text is provided
51+
- Parses any suggested answers from the `follow_up` parameter using the `fast-xml-parser` library
52+
- Normalizes suggestions into an array format even if there's only one suggestion
53+
54+
2. **JSON Transformation**: Converts the XML structure into a standardized JSON format for UI display
55+
```typescript
56+
{
57+
question: "User's question here",
58+
suggest: [
59+
{ answer: "Suggestion 1" },
60+
{ answer: "Suggestion 2" }
61+
]
62+
}
63+
```
64+
65+
3. **UI Integration**:
66+
- Passes the JSON structure to the UI layer via the `ask("followup", ...)` method
67+
- Displays selectable suggestion buttons to the user in the interface
68+
- Creates an interactive experience for selecting or typing a response
69+
70+
4. **Response Collection and Processing**:
71+
- Captures user text input and any images included in the response
72+
- Wraps user responses in `<answer>` tags when returning to the assistant
73+
- Preserves any images included in the user's response
74+
- Maintains the conversational context by adding the response to the history
75+
- Resets the consecutive error counter when the tool is used successfully
76+
77+
5. **Error Handling**:
78+
- Tracks consecutive mistakes using a counter
79+
- Resets the counter when the tool is used successfully
80+
- Provides specific error messages:
81+
- For missing parameters: "Missing required parameter 'question'"
82+
- For XML parsing: "Failed to parse operations: [error message]"
83+
- For invalid format: "Invalid operations xml format"
84+
- Contains safeguards to prevent tool execution when required parameters are missing
85+
- Increments consecutive mistake count when errors occur
86+
87+
## Workflow Sequence
88+
89+
The question-answer cycle follows this sequence:
90+
91+
1. **Information Gap Recognition**: Roo identifies missing information needed to proceed
92+
2. **Specific Question Creation**: Roo formulates a clear, targeted question
93+
3. **Suggestion Development**: Roo creates relevant suggested answers (optional but recommended)
94+
4. **Tool Invocation**: Assistant invokes the tool with question and optional suggestions
95+
5. **UI Presentation**: Question and suggestions are displayed to the user as interactive elements
96+
6. **User Response**: The user selects a suggestion or provides a custom answer
97+
7. **Message Handling**: System handles both partial and complete messages
98+
- For streaming responses, processes chunks as they arrive
99+
- For complete messages, processes the entire response at once
100+
- Maintains state consistency regardless of message chunking
101+
8. **Response Processing**: System wraps the response in `<answer>` tags and preserves images
102+
9. **Context Integration**: Response is added to the conversation history
103+
10. **Task Continuation**: Roo proceeds with the task using the new information
104+
105+
## Examples When Used
106+
107+
- When developing a web application, Roo might ask about preferred styling frameworks (Bootstrap, Tailwind, custom CSS)
108+
- When creating an API, Roo might ask about authentication methods (JWT, OAuth, API keys)
109+
- When refactoring code, Roo might ask about prioritizing performance vs. readability
110+
- When setting up a database, Roo might ask about specific schema design preferences
111+
- When creating a custom feature, Roo might ask about specific behavior expectations
112+
- When troubleshooting errors, Roo might ask about specific environment details
113+
114+
## Response Format
115+
116+
When a user responds to a question, the response is formatted with `<answer>` tags for clarity and consistency. This format helps clearly separate the user's answer from other conversation elements.
117+
118+
Example response format:
119+
```
120+
<answer>
121+
Use Tailwind CSS for utility-first styling with maximum flexibility
122+
</answer>
123+
```
124+
125+
Key characteristics of the response format:
126+
- Surrounded by `<answer>` tags
127+
- Preserves formatting of the original response
128+
- Maintains images if included in the response
129+
- Returns the complete text, even for long responses
130+
131+
## Usage Examples
132+
133+
Asking about implementation preferences:
134+
```
135+
<ask_followup_question>
136+
<question>Which styling approach would you prefer for this web application?</question>
137+
<follow_up>
138+
<suggest>Use Bootstrap for rapid development with consistent components</suggest>
139+
<suggest>Use Tailwind CSS for utility-first styling with maximum flexibility</suggest>
140+
<suggest>Use vanilla CSS with custom styling for complete control and minimal dependencies</suggest>
141+
</follow_up>
142+
</ask_followup_question>
143+
```
144+
145+
146+
Requesting technical clarification:
147+
```
148+
<ask_followup_question>
149+
<question>What database should this application use for storing user data?</question>
150+
<follow_up>
151+
<suggest>MongoDB for flexible schema and document-based storage</suggest>
152+
<suggest>PostgreSQL for relational data with strong consistency guarantees</suggest>
153+
<suggest>Firebase for real-time updates and simplified backend management</suggest>
154+
<suggest>SQLite for lightweight local storage without external dependencies</suggest>
155+
</follow_up>
156+
</ask_followup_question>
157+
```
158+
159+
Addressing ambiguity in requirements:
160+
```
161+
<ask_followup_question>
162+
<question>How should the application handle user authentication?</question>
163+
<follow_up>
164+
<suggest>Implement email/password authentication with account verification</suggest>
165+
<suggest>Use social login providers (Google, GitHub, etc.) for quick signup</suggest>
166+
<suggest>Implement both email/password and social login options</suggest>
167+
</follow_up>
168+
</ask_followup_question>
169+
```

0 commit comments

Comments
 (0)