Skip to content

fix: add include_default_tools parameter to LLMAgent to prevent unwanted inbuilt tool calls#289

Closed
saakshisinghal14 wants to merge 2 commits intomesa:mainfrom
saakshisinghal14:fix/allow-opting-out-of-default-tools
Closed

fix: add include_default_tools parameter to LLMAgent to prevent unwanted inbuilt tool calls#289
saakshisinghal14 wants to merge 2 commits intomesa:mainfrom
saakshisinghal14:fix/allow-opting-out-of-default-tools

Conversation

@saakshisinghal14
Copy link
Copy Markdown
Contributor

Fixes #254

Summary

When an agent registers only domain-specific tools (e.g. adopt_opinion), the LLM executor can still call inbuilt tools like move_one_step — even when the simulation has nothing to do with movement.

This happens because ToolManager auto-registers inbuilt tools globally, with no way to opt out. When the executor must choose a tool, it may select these unintended defaults.

Changes

  • Added INBUILT_TOOL_NAMES (frozenset) in inbuilt_tools.py to centrally define default tool names
  • Added include_default_tools: bool = True parameter to LLMAgent.__init__()
    • True (default): preserves existing behavior (fully backward compatible)
    • False: filters out inbuilt tools (move_one_step, teleport_to_location, speak_to) from the agent’s ToolManager, leaving only user-registered tools
  • Added tests covering:
    • default behavior (inbuilt tools present)
    • opt-out behavior (inbuilt tools removed)
    • preservation of user-defined tools

Implementation Note

Filtering is applied after tool registration, ensuring compatibility with the existing tool registration flow while allowing selective removal of default tools per agent.

Usage

agent = LLMAgent(
    model=model,
    reasoning=CoTReasoning,
    include_default_tools=False,  # only domain tools visible to LLM
)

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 5, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b024c973-b477-41f1-a0ba-e699421f3774

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@BhoomiAgrawal12
Copy link
Copy Markdown
Contributor

Hey @saakshisinghal14, PR #167 by @yashhzd addresses the same issue in the same way. It also adds an opt-out flag to LLMAgent.init and passes it through to ToolManager.

I would suggest since PR #167 was first and has similar intent, it might be worth either closing this one in its favor, or leaving a comment on #167 discussing the differences so the maintainers can make an informed call. Thanks for putting in the work on this!

@saakshisinghal14
Copy link
Copy Markdown
Contributor Author

Thanks for pointing this out @BhoomiAgrawal12 . I wasn't aware of PR #167 when I opened this — it predates my involvement with the repo.

Looking at it, #167 takes a more thorough approach by adding the flag to ToolManager itself and including a remove_tool() method, which is cleaner than my post-creation filtering. I'm happy to defer to #167 if the maintainers prefer that approach.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Inbuilt move_one_step tool called unexpectedly when only domain tool is registered

2 participants