Skip to content

allow use five tools in one call #3840

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

qdaxb
Copy link

@qdaxb qdaxb commented May 22, 2025

Related GitHub Issue

Closes: #3839

Description

  1. Changed didAlreadyUseTool to an integer type, and updated the corresponding logic for setting and checking it.
  2. Modified the prompts for the system and some tools.
  3. Made targeted changes to new_task and attempt_completion_task.

Based on my testing, the LLM generally does not overuse tool calls, and it performs well in scenarios where multiple tool calls are genuinely needed.

Test Procedure

Type of Change

  • 🐛 Bug Fix: Non-breaking change that fixes an issue.
  • [x ] ✨ New Feature: Non-breaking change that adds functionality.
  • 💥 Breaking Change: Fix or feature that would cause existing functionality to not work as expected.
  • ♻️ Refactor: Code change that neither fixes a bug nor adds a feature.
  • 💅 Style: Changes that do not affect the meaning of the code (white-space, formatting, etc.).
  • 📚 Documentation: Updates to documentation files.
  • ⚙️ Build/CI: Changes to the build process or CI configuration.
  • 🧹 Chore: Other changes that don't modify src or test files.

Pre-Submission Checklist

  • Issue Linked: This PR is linked to an approved GitHub Issue (see "Related GitHub Issue" above).
  • Scope: My changes are focused on the linked issue (one major feature/fix per PR).
  • Self-Review: I have performed a thorough self-review of my code.
  • Code Quality:
    • My code adheres to the project's style guidelines.
    • There are no new linting errors or warnings (npm run lint).
    • All debug code (e.g., console.log) has been removed.
  • Testing:
    • New and/or updated tests have been added to cover my changes.
    • All tests pass locally (npm test).
    • The application builds successfully with my changes.
  • Branch Hygiene: My branch is up-to-date (rebased) with the main branch.
  • Documentation Impact: I have considered if my changes require documentation updates (see "Documentation Updates" section below).
  • Changeset: A changeset has been created using npm run changeset if this PR includes user-facing changes or dependency updates.
  • Contribution Guidelines: I have read and agree to the Contributor Guidelines.

Screenshots / Videos

image

Documentation Updates

Additional Notes

Get in Touch


Important

Allows up to five tool uses per message, updates tool usage logic, and modifies related prompts and functions.

  • Behavior:
    • didAlreadyUseTool changed to integer in Task class to track tool usage count.
    • Allows up to five tool uses per message in presentAssistantMessage().
    • Restricts attempt_completion tool from being used with others in presentAssistantMessage().
  • Prompts:
    • Updated getSharedToolUseSection() to reflect new tool usage limit.
    • Added note in getNewTaskDescription() that new_task can only be called once per message.
  • Tools:
    • In newTaskTool(), increments didAlreadyUseTool by 5 to prevent further tool use after creating a new task.

This description was created by Ellipsis for 55e6c13. You can customize this summary. It will automatically update as commits are pushed.

// Ignore any content after a tool has already been used.
cline.userMessageContent.push({
type: "text",
text: `Tool [${block.name}] was not executed because a tool has already been used in this message. Only one tool may be used per message. You must assess the first tool's result before proceeding to use the next tool.`,
text: `Tool [${block.name}] was not executed because too many tools has already been used in this message. Only five tool may be used per message. You must assess the first tool's result before proceeding to use the next tool.`,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typographical error: The phrase too many tools has already been used should be too many tools have already been used, and Only five tool may be used should be Only five tools may be used.

@@ -3,6 +3,7 @@ import { ToolArgs } from "./types"
export function getNewTaskDescription(_args: ToolArgs): string {
return `## new_task
Description: This will let you create a new task instance in the chosen mode using your provided message.
IMPORTANT: This tool could only called once per message.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo: In the sentence IMPORTANT: This tool could only called once per message., please change it to IMPORTANT: This tool can only be called once per message.

Suggested change
IMPORTANT: This tool could only called once per message.
IMPORTANT: This tool can only be called once per message.

assistantMessage +=
"\n\n[Response interrupted by a tool use result. Only one tool may be used at a time and should be placed at the end of the message.]"
"\n\n[Response interrupted by a tool use result. Only five tool may be used at a time and should be placed at the end of the message.]"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo: In the message string, consider changing "Only five tool may be used" to "Only five tools may be used" for grammatical correctness.

Suggested change
"\n\n[Response interrupted by a tool use result. Only five tool may be used at a time and should be placed at the end of the message.]"
"\n\n[Response interrupted by a tool use result. Only five tools may be used at a time and should be placed at the end of the message.]"

@Ruakij
Copy link

Ruakij commented May 22, 2025

Hey, i also have a version for multi-tool-calling, though yours is much cleaner.
Limiting the amount of tools used is pretty good, mine is unlimited so far :)

I also see you limited attempt_completion to be called alone, very nice.

Some things to consider maybe:

  • Models probably perform better when allowing their chain of through process, so explaining what they are about to do, then calling the tool, and then explaining about the next action they are about to take. So instructing it to move the tools to the bottom might hurt quality.
    • The new Sonnet 4 does this alot, even on the same file
  • A slider in settings, how many tools to allow, instead of hard-coded could be good and easy
  • some models like to ignore specifics once context grows, sometimes trying attempt-completion while using other tools many times
    • In some cases sonnet 3.5 tried attempt_completion and then another command to run tests, not sure if that bugs out with you too, but probably needs to be filtered if not already handled
  • Its probably a good idea to block writing files that were just read, specially with sonnet models i found them getting confused from previous read_files and immediately start making diffs. Blocking helped avoiding many clashes.
    • This also applies to duplicated or overlapping tool-calls (though i have never observed this)
  • The UI code needs some update, because while waiting for user-input the response is still streaming, we should reflect that and display next know output and tools. Am unsure about the design.

You can check out my glued-together PoC version here: https://github.com/Ruakij/Roo-Code/tree/feat/multiple-tool-calls

@wwicak
Copy link

wwicak commented May 23, 2025

why limit to 5? why not make it adjustable?

@hannesrudolph hannesrudolph moved this from New to PR [Pre Approval Review] in Roo Code Roadmap May 23, 2025
@samhvw8
Copy link
Collaborator

samhvw8 commented May 24, 2025

The current implementation has the potential to introduce bugs when tools are executed in complex sequences (e.g., read → write → read → write → search → write) or when specialized tools like attempt_completion are used. This essentially creates race conditions where the timing and order of tool execution can lead to unpredictable behavior. To mitigate these issues, tools should be categorized into functional groups that support parallel execution, enabling multiple tools to operate simultaneously without conflicts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: PR [Pre Approval Review]
Development

Successfully merging this pull request may close these issues.

support multi tool invoke
4 participants