mirror of
https://github.com/Aider-AI/aider.git
synced 2025-06-08 21:55:00 +00:00
Instead of using Continue, just use the presence of tool calls for multi-turn
This commit is contained in:
parent
888bf095ba
commit
4339c73774
2 changed files with 20 additions and 24 deletions
|
@ -255,8 +255,8 @@ class NavigatorCoder(Coder):
|
||||||
return True
|
return True
|
||||||
original_content = content # Keep the original response
|
original_content = content # Keep the original response
|
||||||
|
|
||||||
# Process tool commands: returns content with tool calls removed, results, and continue flag
|
# Process tool commands: returns content with tool calls removed, results, and flag if any tool calls were found
|
||||||
processed_content, result_messages, continue_requested = self._process_tool_commands(content)
|
processed_content, result_messages, tool_calls_found = self._process_tool_commands(content)
|
||||||
|
|
||||||
# Since we are no longer suppressing, the partial_response_content IS the final content.
|
# Since we are no longer suppressing, the partial_response_content IS the final content.
|
||||||
# We might want to update it to the processed_content (without tool calls) if we don't
|
# We might want to update it to the processed_content (without tool calls) if we don't
|
||||||
|
@ -267,8 +267,9 @@ class NavigatorCoder(Coder):
|
||||||
# Process implicit file mentions using the content *after* tool calls were removed
|
# Process implicit file mentions using the content *after* tool calls were removed
|
||||||
self._process_file_mentions(processed_content)
|
self._process_file_mentions(processed_content)
|
||||||
|
|
||||||
# If continue was requested and we haven't exceeded reflection limits, set up for another iteration
|
# If any tool calls were found and we haven't exceeded reflection limits, set up for another iteration
|
||||||
if continue_requested and self.num_reflections < self.max_reflections:
|
# This is implicit continuation when any tool calls are present, rather than requiring Continue explicitly
|
||||||
|
if tool_calls_found and self.num_reflections < self.max_reflections:
|
||||||
# Reset tool counter for next iteration
|
# Reset tool counter for next iteration
|
||||||
self.tool_call_count = 0
|
self.tool_call_count = 0
|
||||||
# Clear exploration files for the next round
|
# Clear exploration files for the next round
|
||||||
|
@ -341,10 +342,11 @@ class NavigatorCoder(Coder):
|
||||||
def _process_tool_commands(self, content):
|
def _process_tool_commands(self, content):
|
||||||
"""
|
"""
|
||||||
Process tool commands in the `[tool_call(name, param=value)]` format within the content.
|
Process tool commands in the `[tool_call(name, param=value)]` format within the content.
|
||||||
|
Returns processed content, result messages, and a flag indicating if any tool calls were found.
|
||||||
"""
|
"""
|
||||||
result_messages = []
|
result_messages = []
|
||||||
modified_content = content # Start with original content
|
modified_content = content # Start with original content
|
||||||
continue_requested = False
|
tool_calls_found = False
|
||||||
call_count = 0
|
call_count = 0
|
||||||
max_calls = self.max_tool_calls
|
max_calls = self.max_tool_calls
|
||||||
|
|
||||||
|
@ -380,13 +382,9 @@ class NavigatorCoder(Coder):
|
||||||
args_str = match.group(2) or ""
|
args_str = match.group(2) or ""
|
||||||
full_match_str = match.group(0)
|
full_match_str = match.group(0)
|
||||||
|
|
||||||
# Handle Continue separately
|
# We no longer need to handle Continue separately, as we'll continue if any tool calls exist
|
||||||
if tool_name.lower() == 'continue':
|
# Just track that a tool call was found
|
||||||
continue_requested = True
|
tool_calls_found = True
|
||||||
# Remove this specific call from the content
|
|
||||||
modified_content = modified_content.replace(full_match_str, "", 1)
|
|
||||||
processed_indices.add((match.start(), match.end()))
|
|
||||||
continue # Don't process further, just note the request
|
|
||||||
|
|
||||||
# Extract parameters
|
# Extract parameters
|
||||||
params = {}
|
params = {}
|
||||||
|
@ -488,7 +486,7 @@ class NavigatorCoder(Coder):
|
||||||
# Update internal counter
|
# Update internal counter
|
||||||
self.tool_call_count += call_count
|
self.tool_call_count += call_count
|
||||||
|
|
||||||
return modified_content, result_messages, continue_requested
|
return modified_content, result_messages, tool_calls_found
|
||||||
|
|
||||||
def _apply_edits_from_response(self):
|
def _apply_edits_from_response(self):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -65,9 +65,8 @@ Act as an expert software engineer with the ability to autonomously navigate and
|
||||||
Execute a shell command. Requires user confirmation.
|
Execute a shell command. Requires user confirmation.
|
||||||
**Do NOT use this for aider commands starting with `/` (like `/add`, `/run`, `/diff`).**
|
**Do NOT use this for aider commands starting with `/` (like `/add`, `/run`, `/diff`).**
|
||||||
|
|
||||||
- **Continue**: `[tool_call(Continue)]`
|
### Multi-Turn Exploration
|
||||||
Continue exploration in the next round with the current files.
|
When you include any tool call, the system will automatically continue to the next round.
|
||||||
This enables multi-turn exploration.
|
|
||||||
</context>
|
</context>
|
||||||
|
|
||||||
<context name="workflow_guidance">
|
<context name="workflow_guidance">
|
||||||
|
@ -78,8 +77,8 @@ Act as an expert software engineer with the ability to autonomously navigate and
|
||||||
2. **Focused Investigation**: Add promising files to context with `Add`
|
2. **Focused Investigation**: Add promising files to context with `Add`
|
||||||
3. **Context Management**: Remove irrelevant files with `Remove` to maintain focus
|
3. **Context Management**: Remove irrelevant files with `Remove` to maintain focus
|
||||||
4. **Preparation for Editing**: Convert files to editable with `MakeEditable` when needed
|
4. **Preparation for Editing**: Convert files to editable with `MakeEditable` when needed
|
||||||
5. **Continued Exploration**: Add `[tool_call(Continue)]` to perform another exploration round
|
5. **Continued Exploration**: Include any tool call to automatically continue to the next round
|
||||||
6. **Final Response**: Omit `Continue` when you have sufficient information to answer
|
6. **Final Response**: Omit all tool calls when you have sufficient information to provide a final answer
|
||||||
|
|
||||||
### Tool Usage Best Practices
|
### Tool Usage Best Practices
|
||||||
- Use the exact syntax `[tool_call(ToolName, param1=value1, param2="value2")]` for execution
|
- Use the exact syntax `[tool_call(ToolName, param1=value1, param2="value2")]` for execution
|
||||||
|
@ -139,8 +138,7 @@ Always reply to the user in {language}.
|
||||||
role="assistant",
|
role="assistant",
|
||||||
content="""I'll help you understand the authentication system in this project. Let me explore the codebase first to find all relevant files.
|
content="""I'll help you understand the authentication system in this project. Let me explore the codebase first to find all relevant files.
|
||||||
|
|
||||||
[tool_call(Grep, pattern="login|auth|password|session", file_pattern="*.py")]
|
[tool_call(Grep, pattern="login|auth|password|session", file_pattern="*.py")]""",
|
||||||
[tool_call(Continue)]""",
|
|
||||||
),
|
),
|
||||||
dict(
|
dict(
|
||||||
role="user",
|
role="user",
|
||||||
|
@ -152,8 +150,7 @@ Always reply to the user in {language}.
|
||||||
|
|
||||||
[tool_call(Add, file_path="auth/models.py")]
|
[tool_call(Add, file_path="auth/models.py")]
|
||||||
[tool_call(Add, file_path="auth/views.py")]
|
[tool_call(Add, file_path="auth/views.py")]
|
||||||
[tool_call(Add, file_path="users/authentication.py")]
|
[tool_call(Add, file_path="users/authentication.py")]""",
|
||||||
[tool_call(Continue)]""",
|
|
||||||
),
|
),
|
||||||
dict(
|
dict(
|
||||||
role="user",
|
role="user",
|
||||||
|
@ -211,8 +208,8 @@ Here are summaries of some files present in this repo:
|
||||||
## Tool Command Reminder
|
## Tool Command Reminder
|
||||||
- To execute a tool, use: `[tool_call(ToolName, param1=value1)]`
|
- To execute a tool, use: `[tool_call(ToolName, param1=value1)]`
|
||||||
- To show tool examples without executing: `\\[tool_call(ToolName, param1=value1)]`
|
- To show tool examples without executing: `\\[tool_call(ToolName, param1=value1)]`
|
||||||
- For multi-turn exploration, end with `[tool_call(Continue)]`
|
- Including ANY tool call will automatically continue to the next round
|
||||||
- For final answers, do NOT include `[tool_call(Continue)]`
|
- For final answers, do NOT include any tool calls
|
||||||
|
|
||||||
## Context Features
|
## Context Features
|
||||||
- Use enhanced context blocks (directory structure and git status) to orient yourself
|
- Use enhanced context blocks (directory structure and git status) to orient yourself
|
||||||
|
@ -242,6 +239,7 @@ Let me explore the codebase more strategically this time:
|
||||||
- I'll use more specific search patterns
|
- I'll use more specific search patterns
|
||||||
- I'll be more selective about which files to add to context
|
- I'll be more selective about which files to add to context
|
||||||
- I'll remove irrelevant files more proactively
|
- I'll remove irrelevant files more proactively
|
||||||
|
- I'll use tool calls to automatically continue exploration until I have enough information
|
||||||
|
|
||||||
I'll start exploring again with improved search strategies to find exactly what we need.
|
I'll start exploring again with improved search strategies to find exactly what we need.
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue