Skip to content

fix(toolset): fix toolset override in config - #512

Merged
moshemorad merged 3 commits into
HolmesGPT:masterfrom
mainred:fix-toolset-override-in-config
Jun 11, 2025
Merged

moshemorad merged 3 commits into
HolmesGPT:masterfrom
mainred:fix-toolset-override-in-config

Conversation

@mainred

@mainred mainred commented Jun 11, 2025 •

Copy link
Copy Markdown
Collaborator

before this change, disabling the built-in toolset from the toolset from config or custom toolset don't work. Fix this by setting the built-in enablement before it is override by custom or config toolset.

Test

This config

toolsets:
  servicenow:
    enabled: false

will give

Name                              Status    Enabled    Type      Path                                 Error
--------------------------------  --------  ---------  --------  -----------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------
confluence                        failed    True       built-in                                       Environment variable CONFLUENCE_BASE_URL was not set
docker/core                       enabled   True       built-in
helm/core                         enabled   True       built-in
kubernetes/logs                   enabled   True       built-in
servicenow                        disabled  False      built-in
aks/node-health                   enabled   True       built-in

@coderabbitai

coderabbitai Bot commented Jun 11, 2025 •

Copy link
Copy Markdown
Contributor

Walkthrough

The changes revise the logic for enabling toolsets in the toolset manager. Comments and docstrings were updated for clarity, and the timing of enabling toolsets was adjusted so that built-in toolsets are enabled earlier in the process. Tests were added and modified to verify the new enabling and disabling logic for both built-in and custom toolsets.

Changes

File(s) Change Summary
holmes/core/tools.py Removed two explanatory comment lines about toolset enabling conditions.
holmes/core/toolset_manager.py Updated docstrings, adjusted logic to enable built-in toolsets earlier, set custom toolsets enabled by default, and removed redundant code.
tests/core/test_toolset_manager.py Added import, modified an existing test, and introduced two new tests to cover toolset enabling/disabling scenarios.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant ToolsetManager
    participant BuiltinLoader
    participant ConfigLoader

    User->>ToolsetManager: _list_all_toolsets()
    ToolsetManager->>BuiltinLoader: Load built-in toolsets
    BuiltinLoader-->>ToolsetManager: Built-in toolsets
    ToolsetManager->>ToolsetManager: Enable all built-in toolsets if enable_all_toolsets is True
    ToolsetManager->>ConfigLoader: Load custom toolsets from config
    ConfigLoader-->>ToolsetManager: Custom toolsets
    ToolsetManager->>ToolsetManager: Set custom toolsets enabled by default unless explicitly disabled
    ToolsetManager->>ToolsetManager: Merge and filter toolsets as needed
    ToolsetManager-->>User: List of toolsets with correct enabled/disabled status
Loading
✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (3)
holmes/core/toolset_manager.py (1)

142-147: Reduce branching – streamline default-enable handling
The four-line if/else block can be collapsed without altering semantics:

-                if toolset_config.get("enabled", True) is False:
-                    toolset_config["enabled"] = False
-                else:
-                    toolset_config["enabled"] = True
+                # enabled by default unless explicitly set to False
+                toolset_config["enabled"] = toolset_config.get("enabled", True) is not False

Fewer branches → simpler reasoning, same result.

tests/core/test_toolset_manager.py (2)

9-15: Keep tests independent of concrete YAMLToolset implementation
Importing and instantiating YAMLToolset ties the test suite to an internal helper class. A plain MagicMock (or namedtuple) would exercise the manager just as well while decoupling the test from future refactors inside holmes.core.tools.


76-94: Prefer YAML for temporary custom-toolset file
The file is parsed via a YAML loader; writing JSON works (YAML ⊇ JSON) but hurts readability. Tiny tweak:

-        data = {"toolsets": {"builtin": {"enabled": False}}}
-        json.dump(data, tmpfile, indent=2)
+        yaml.safe_dump({"toolsets": {"builtin": {"enabled": False}}}, tmpfile)

Keeps format consistent with expected input and avoids the extra json import.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3ae5942 and 7c51e77.

📒 Files selected for processing (3)
  • holmes/core/tools.py (0 hunks)
  • holmes/core/toolset_manager.py (2 hunks)
  • tests/core/test_toolset_manager.py (2 hunks)
💤 Files with no reviewable changes (1)
  • holmes/core/tools.py
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: build (3.11)
  • GitHub Check: build (3.10)
  • GitHub Check: build (3.12)
  • GitHub Check: build (3.12)
🔇 Additional comments (3)
holmes/core/toolset_manager.py (1)

82-85: Good relocation of enable_all_toolsets logic
Enabling every built-in as soon as they’re loaded makes the enable_all_toolsets switch deterministic and prevents late overrides from silently re-enabling a toolset. The later config merge still has the authority to flip enabled=False, so behaviour is preserved.

tests/core/test_toolset_manager.py (2)

52-52: Test data change is sensible
Switching from an enabled flag to a benign field (description) removes accidental side-effects and focuses the test on merge behaviour. Looks good.


59-74: Solid regression test for builtin override
The new case correctly verifies that user config can disable a built-in toolset. Mocking keeps the scope narrow and fast.

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.

2 participants