Instead of using Continue, just use the presence of tool calls for multi-turn

This commit is contained in:
Amar Sood (tekacs) 2025-04-11 12:05:19 -04:00
parent 888bf095ba
commit 4339c73774
2 changed files with 20 additions and 24 deletions

View file

@ -255,8 +255,8 @@ class NavigatorCoder(Coder):
return True
original_content = content # Keep the original response
# Process tool commands: returns content with tool calls removed, results, and continue flag
processed_content, result_messages, continue_requested = self._process_tool_commands(content)
# Process tool commands: returns content with tool calls removed, results, and flag if any tool calls were found
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.
# 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
self._process_file_mentions(processed_content)
# If continue was requested and we haven't exceeded reflection limits, set up for another iteration
if continue_requested and self.num_reflections < self.max_reflections:
# If any tool calls were found and we haven't exceeded reflection limits, set up for another iteration
# 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
self.tool_call_count = 0
# Clear exploration files for the next round
@ -341,10 +342,11 @@ class NavigatorCoder(Coder):
def _process_tool_commands(self, 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 = []
modified_content = content # Start with original content
continue_requested = False
tool_calls_found = False
call_count = 0
max_calls = self.max_tool_calls
@ -380,13 +382,9 @@ class NavigatorCoder(Coder):
args_str = match.group(2) or ""
full_match_str = match.group(0)
# Handle Continue separately
if tool_name.lower() == 'continue':
continue_requested = 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
# We no longer need to handle Continue separately, as we'll continue if any tool calls exist
# Just track that a tool call was found
tool_calls_found = True
# Extract parameters
params = {}
@ -488,7 +486,7 @@ class NavigatorCoder(Coder):
# Update internal counter
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):
"""

View file

@ -65,9 +65,8 @@ Act as an expert software engineer with the ability to autonomously navigate and
Execute a shell command. Requires user confirmation.
**Do NOT use this for aider commands starting with `/` (like `/add`, `/run`, `/diff`).**
- **Continue**: `[tool_call(Continue)]`
Continue exploration in the next round with the current files.
This enables multi-turn exploration.
### Multi-Turn Exploration
When you include any tool call, the system will automatically continue to the next round.
</context>
<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`
3. **Context Management**: Remove irrelevant files with `Remove` to maintain focus
4. **Preparation for Editing**: Convert files to editable with `MakeEditable` when needed
5. **Continued Exploration**: Add `[tool_call(Continue)]` to perform another exploration round
6. **Final Response**: Omit `Continue` when you have sufficient information to answer
5. **Continued Exploration**: Include any tool call to automatically continue to the next round
6. **Final Response**: Omit all tool calls when you have sufficient information to provide a final answer
### Tool Usage Best Practices
- 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",
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(Continue)]""",
[tool_call(Grep, pattern="login|auth|password|session", file_pattern="*.py")]""",
),
dict(
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/views.py")]
[tool_call(Add, file_path="users/authentication.py")]
[tool_call(Continue)]""",
[tool_call(Add, file_path="users/authentication.py")]""",
),
dict(
role="user",
@ -211,8 +208,8 @@ Here are summaries of some files present in this repo:
## Tool Command Reminder
- To execute a tool, use: `[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)]`
- For final answers, do NOT include `[tool_call(Continue)]`
- Including ANY tool call will automatically continue to the next round
- For final answers, do NOT include any tool calls
## Context Features
- 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 be more selective about which files to add to context
- 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.
"""