Skip to content

Run prerequisite for each cache toolset - #909

Merged
moshemorad merged 1 commit into
masterfrom
ROB-1990-loading-toolset-configuration-issue
Aug 25, 2025
Merged

moshemorad merged 1 commit into
masterfrom
ROB-1990-loading-toolset-configuration-issue

Conversation

@moshemorad

@moshemorad moshemorad commented Aug 25, 2025 •

Copy link
Copy Markdown
Collaborator

When running refresh toolset the tools are still eventually loaded from cache and hence we need to still run the prerequisite checks.

@coderabbitai

coderabbitai Bot commented Aug 25, 2025 •

Copy link
Copy Markdown
Contributor

Walkthrough

load_toolset_with_status no longer gates collection of enabled toolsets on the using_cached flag. Enabled toolsets are now derived solely from toolset.enabled and status == ENABLED, regardless of cache usage. Prerequisite checks proceed for these toolsets; other control flow and outputs remain unchanged.

Changes

Cohort / File(s) Summary
Toolset loading flow
holmes/core/toolset_manager.py
In load_toolset_with_status, removed using_cached condition from enabled-toolset collection. Enabled set now built when toolset.enabled and status == ENABLED, independent of cache. Prerequisite checks and reporting logic unchanged. No public API/signature changes.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant Caller
  participant ToolsetManager
  participant StatusStore as Status/Cache
  participant Prereq as PrerequisiteChecker

  Caller->>ToolsetManager: load_toolset_with_status(...)
  ToolsetManager->>StatusStore: Fetch toolset statuses (may be cached or refreshed)
  StatusStore-->>ToolsetManager: statuses + using_cached flag

  note over ToolsetManager: Build enabled set where<br/>toolset.enabled && status == ENABLED<br/>(ignores using_cached)

  ToolsetManager->>Prereq: Check prerequisites for enabled toolsets
  Prereq-->>ToolsetManager: Results
  ToolsetManager-->>Caller: Final status + enabled toolsets
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • mainred
  • nherment
  • aantn
  • arikalon1

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch ROB-1990-loading-toolset-configuration-issue

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.
    • 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.
  • 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 the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

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

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

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

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • 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 (5)
holmes/core/toolset_manager.py (5)

267-271: Comment/code mismatch and potential double prerequisite runs after refresh

The new condition now schedules prerequisite checks regardless of whether we just refreshed or are using cached statuses. However, the preceding comment still states "only when the toolset is loaded from cache," which is no longer accurate. Also, when refresh_status=True (or when the cache file doesn't exist), prerequisites will be checked in refresh_toolset_status(...) and then checked again here, possibly doubling work and side effects.

If "always check" is intentional (aligns with PR title), update the comment and rename the variable to avoid confusion. Otherwise, gate on using_cached to avoid duplicate checks.

Apply Option A (keep new behavior; clarify intent and naming):

-        enabled_toolsets_from_cache: List[Toolset] = []
+        # Collect toolsets whose prerequisites we want to (re)check.
+        # Note: We (re)check prerequisites for enabled toolsets with cached status "enabled"
+        # regardless of whether we just refreshed or are using cached statuses.
+        # This ensures prerequisites run for every non-CLI toolset on each load.
+        enabled_toolsets_to_check: List[Toolset] = []

@@
-            # check prerequisites for only enabled toolset when the toolset is loaded from cache. When the toolset is
-            # not loaded from cache, the prerequisites are checked in the refresh_toolset_status method.
-            if toolset.enabled and toolset.status == ToolsetStatusEnum.ENABLED:
-                enabled_toolsets_from_cache.append(toolset)
-        self.check_toolset_prerequisites(enabled_toolsets_from_cache)
+            # Check prerequisites for enabled toolsets whose cached status is ENABLED.
+            if toolset.enabled and toolset.status == ToolsetStatusEnum.ENABLED:
+                enabled_toolsets_to_check.append(toolset)
+        self.check_toolset_prerequisites(enabled_toolsets_to_check)

Option B (avoid duplicate checks when we just refreshed):

-            if toolset.enabled and toolset.status == ToolsetStatusEnum.ENABLED:
+            if using_cached and toolset.enabled and toolset.status == ToolsetStatusEnum.ENABLED:
                 enabled_toolsets_from_cache.append(toolset)

34-36: Redundant assignment of self.toolsets

self.toolsets = toolsets is immediately overwritten by self.toolsets = toolsets or {}. Remove the first assignment.

-        self.toolsets = toolsets
         self.toolsets = toolsets or {}

439-441: Duplicate assignment when adding a new toolset

existing_toolsets_by_name[new_toolset.name] = new_toolset is executed twice. Keep a single assignment.

             else:
                 existing_toolsets_by_name[new_toolset.name] = new_toolset
-                existing_toolsets_by_name[new_toolset.name] = new_toolset

135-144: Exceptions from prerequisite checks are swallowed

as_completed(futures) is iterated without calling future.result(). Exceptions raised in check_prerequisites won't be surfaced or logged, which can hide real failures.

-        with concurrent.futures.ThreadPoolExecutor(max_workers=10) as executor:
+        with concurrent.futures.ThreadPoolExecutor(max_workers=10) as executor:
             futures = []
             for toolset in toolsets:
                 futures.append(executor.submit(toolset.check_prerequisites))

-            for _ in concurrent.futures.as_completed(futures):
-                pass
+            for future in concurrent.futures.as_completed(futures):
+                try:
+                    # Ensure exceptions are raised and not silently ignored
+                    future.result()
+                except Exception:
+                    logging.exception("Toolset prerequisite check failed")

42-44: Potential misuse of pydantic FilePath

FilePath(...) is a pydantic type intended for model validation, not for direct instantiation as a path value. Depending on your pydantic version, calling it can raise a TypeError. Prefer pathlib.Path (runtime) for constructing paths.

If confirmed, switch to Path and add the import at the top:

@@
-import os
+import os
+from pathlib import Path
@@
-        if toolset_status_location is None:
-            toolset_status_location = FilePath(DEFAULT_TOOLSET_STATUS_LOCATION)
+        if toolset_status_location is None:
+            toolset_status_location = Path(DEFAULT_TOOLSET_STATUS_LOCATION)

Note: If mypy complains about the annotation Optional[FilePath], consider changing the parameter and attribute types to Optional[Path] | Optional[str], or keep Path while relying on runtime checks in this class.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 3521d33 and 1caa08d.

📒 Files selected for processing (1)
  • holmes/core/toolset_manager.py (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.py

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.py: Always place Python imports at the top of the file, not inside functions or methods
Type hints are required (mypy is configured in pyproject.toml)

Files:

  • holmes/core/toolset_manager.py
🧬 Code graph analysis (1)
holmes/core/toolset_manager.py (1)
holmes/core/tools.py (1)
  • ToolsetStatusEnum (103-106)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: llm_evals
  • GitHub Check: Pre-commit checks
  • GitHub Check: Pre-commit checks

@github-actions

Copy link
Copy Markdown
Contributor

Results of HolmesGPT evals

  • ask_holmes: 33/38 test cases were successful, 1 regressions, 2 skipped, 2 setup failures
Test suite Test case Status
ask 01_how_many_pods ✅
ask 02_what_is_wrong_with_pod ✅
ask 03_what_is_the_command_to_port_forward ❌
ask 04_related_k8s_events ↪️
ask 05_image_version ✅
ask 09_crashpod ✅
ask 10_image_pull_backoff ✅
ask 110_k8s_events_image_pull ✅
ask 11_init_containers ✅
ask 13a_pending_node_selector_basic ✅
ask 14_pending_resources ✅
ask 15_failed_readiness_probe ✅
ask 17_oom_kill ✅
ask 18_crash_looping_v2 ✅
ask 19_detect_missing_app_details ✅
ask 20_long_log_file_search ✅
ask 24_misconfigured_pvc ✅
ask 24a_misconfigured_pvc_basic ✅
ask 28_permissions_error 🚧
ask 29_events_from_alert_manager ↪️
ask 39_failed_toolset ✅
ask 41_setup_argo ✅
ask 42_dns_issues_steps_new_tools ✅
ask 43_current_datetime_from_prompt ✅
ask 45_fetch_deployment_logs_simple ✅
ask 51_logs_summarize_errors ✅
ask 53_logs_find_term ✅
ask 54_not_truncated_when_getting_pods ✅
ask 59_label_based_counting ✅
ask 60_count_less_than 🚧
ask 61_exact_match_counting ✅
ask 63_fetch_error_logs_no_errors ✅
ask 79_configmap_mount_issue ✅
ask 83_secret_not_found ✅
ask 86_configmap_like_but_secret ✅
ask 93_calling_datadog[0] ✅
ask 93_calling_datadog[1] ✅
ask 93_calling_datadog[2] ✅

Legend

  • ✅ the test was successful
  • ↪️ the test was skipped
  • ⚠️ the test failed but is known to be flaky or known to fail
  • 🚧 the test had a setup failure (not a code regression)
  • 🔧 the test failed due to mock data issues (not a code regression)
  • ❌ the test failed and should be fixed before merging the PR

@moshemorad
moshemorad merged commit 73b63fa into master Aug 25, 2025
10 of 11 checks passed
@moshemorad
moshemorad deleted the ROB-1990-loading-toolset-configuration-issue branch August 25, 2025 16:36
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