Skip to content

fix: make built-in tool injection configurable#167

Open
yashhzd wants to merge 1 commit intomesa:mainfrom
yashhzd:fix/configurable-builtin-tools-90
Open

fix: make built-in tool injection configurable#167
yashhzd wants to merge 1 commit intomesa:mainfrom
yashhzd:fix/configurable-builtin-tools-90

Conversation

@yashhzd
Copy link
Contributor

@yashhzd yashhzd commented Mar 6, 2026

Summary

Fixes #90

Every ToolManager instance automatically copies the global tool registry (_GLOBAL_TOOL_REGISTRY), so all agents receive move_one_step, teleport_to_location, and speak_to regardless of whether those capabilities make sense for the agent. This causes:

  • Capability leakage — static entities gain movement tools
  • Tool noise — LLMs waste reasoning on irrelevant tools
  • Hard-to-debug conflicts — custom tools can shadow built-ins
  • No local permission reasoning — cannot restrict agent capabilities

Changes

tool_manager.py:

  • Add include_builtins parameter to ToolManager.__init__() (default True for full backward compatibility)
  • When False, the manager starts with an empty tool set — only extra_tools (if provided) are registered
  • Add remove_tool(name) method for fine-grained per-instance tool removal

llm_agent.py:

  • Add include_builtin_tools parameter to LLMAgent.__init__() that passes through to ToolManager

Tests (5 new):

  • test_include_builtins_false_starts_empty — verifies no global tools when disabled
  • test_include_builtins_true_includes_global_tools — verifies default behavior preserved
  • test_include_builtins_false_with_extra_tools — verifies only extras are available
  • test_remove_tool — verifies removal works
  • test_remove_tool_missing_is_silent — verifies no error on missing tool

Usage Example

# Agent WITHOUT spatial tools (e.g., dining philosopher)
class Philosopher(LLMAgent):
    def __init__(self, model, **kwargs):
        super().__init__(model, include_builtin_tools=False, **kwargs)
        # Only register tools relevant to this agent
        self.tool_manager.register(pick_up_fork)
        self.tool_manager.register(put_down_fork)

# Agent WITH default tools (backward compatible, no change needed)
class Explorer(LLMAgent):
    def __init__(self, model, **kwargs):
        super().__init__(model, **kwargs)  # gets all built-ins

Test Plan

  • All 267 existing tests pass (5 new)
  • Pre-commit hooks pass (ruff, codespell)
  • Fully backward compatible (default include_builtins=True)

Every ToolManager instance automatically copies the global tool
registry, so agents that should not have spatial or communication
capabilities (e.g., static entities in a dining philosophers
simulation) still receive move_one_step, teleport_to_location, and
speak_to.

Add include_builtins parameter to ToolManager (default True for
backward compatibility).  When False, the manager starts with an
empty tool set so only explicitly provided tools are available.

Also add remove_tool() for fine-grained per-instance removal and
expose include_builtin_tools on LLMAgent.__init__ for convenience.
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 6, 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: 410232f1-eb94-4339-864f-59c5b28ca122

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
  • Post copyable unit tests in a comment

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


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.

@codecov
Copy link

codecov bot commented Mar 6, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.09%. Comparing base (4c0549e) to head (56b4af3).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #167      +/-   ##
==========================================
+ Coverage   90.08%   90.09%   +0.01%     
==========================================
  Files          19       19              
  Lines        1503     1505       +2     
==========================================
+ Hits         1354     1356       +2     
  Misses        149      149              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

Global Built-in Tool Injection Prevents Strict ToolManager Isolation In Advanced Simulations

1 participant