Skip to content

[ROB-2379] fixed issue not using model list from cli - #1096

Merged
Avi-Robusta merged 8 commits into
masterfrom
fix_model_list_cli
Nov 25, 2025
Merged

Avi-Robusta merged 8 commits into
masterfrom
fix_model_list_cli

Conversation

@Avi-Robusta

Copy link
Copy Markdown
Collaborator

you can now use model list from the cli to support advanced model configuration
example model list file

azure-4o: # how to refer to the model in the cli
  api_base: ...
  api_key: ...
  api_version: 2025-01-01-preview
  model: azure/gpt-4o
  temperature: 0
# args:  # optional completion args
#    ssl_verify: false
sonnet:
  aws_access_key_id: '...'
  aws_region_name: us-east-1
  aws_secret_access_key: '...'
  model: bedrock/us.anthropic.claude-sonnet-4-5
  temperature: 1
  thinking:
    budget_tokens: 10000
    type: enabled

run:
export MODEL_LIST_FILE_LOCATION=/path/to/model_list.yaml
then you can run commands like
poetry run holmes ask "how many pods are available and list all kubernetes tools" --model=sonnet --no-interactive
or
poetry run holmes ask "how many pods are available and list all kubernetes tools" --model=azure-4o --no-interactive

@Avi-Robusta Avi-Robusta changed the title [ROB-2379] fixed issue not loading model list from cli [ROB-2379] fixed issue not using model list from cli Nov 2, 2025
@coderabbitai

coderabbitai Bot commented Nov 2, 2025 •

Copy link
Copy Markdown
Contributor

Walkthrough

Changes add optional model_name parameter support to LLM factory methods in config, implement duplicate model-loading prevention in the LLM core, and propagate the model selection parameter through investigation commands in the main CLI, enabling explicit model selection across the AI analysis flows.

Changes

Cohort / File(s) Summary
Factory methods with model selection
holmes/config.py
Updated create_console_toolcalling_llm() and create_console_issue_investigator() signatures to accept optional model_name parameter; passed as model_key to _get_llm() calls. Minor formatting in _get_llm().
Model loading control
holmes/core/llm.py
Modified _should_load_config_model() to return False when config.model is set and model already exists in loaded models mapping, preventing duplicate/conflicting model entries.
Command parameter propagation
holmes/main.py
Added model_name propagation to investigate commands (alertmanager, jira, ticket, github, pagerduty, opsgenie); extended ticket command signature with new model option parameter and wired it to create_console_issue_investigator(model_name=model) calls.

Sequence Diagram

sequenceDiagram
    participant CLI as Command Handler
    participant Config as Config Factory
    participant LLM as LLM Core
    participant Models as Models Store

    CLI->>+CLI: Parse model parameter (new)
    CLI->>+Config: create_console_issue_investigator(model_name=model)
    Config->>+LLM: _get_llm(model_key=model_name)
    LLM->>+LLM: _should_load_config_model()
    LLM->>Models: Check if model exists
    alt Model already loaded
        Models-->>LLM: Model found
        LLM-->>Config: Use existing model (return False)
    else Model not loaded
        LLM->>Models: Load and add new model
        Models-->>LLM: Model loaded
    end
    LLM-->>Config: LLM instance
    Config-->>CLI: IssueInvestigator ready
    CLI->>CLI: Execute investigation with selected model
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • holmes/core/llm.py may warrant closer attention to verify the duplicate-prevention logic is correct and doesn't inadvertently skip legitimate model loading scenarios
  • Confirm parameter threading through multiple investigate command paths is consistent across alertmanager, jira, ticket, github, pagerduty, and opsgenie commands

Possibly related PRs

Suggested reviewers

  • mainred
  • nherment

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 53.85% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title Check ✅ Passed The pull request title "[ROB-2379] fixed issue not using model list from cli" directly describes the main objective of the changeset. The PR's core purpose is to enable CLI users to select models from a model list file by propagating the model_name parameter through the configuration and command initialization logic across holmes/config.py, holmes/core/llm.py, and holmes/main.py. The title is specific, concise, and clearly communicates the primary change without being vague or misleading.
Description Check ✅ Passed The pull request description is highly relevant to the changeset, providing a clear explanation of the feature being implemented with concrete examples. It explains that users can now use a model list from the CLI to support advanced model configuration, includes a detailed YAML example showing multiple provider configurations, and demonstrates the specific CLI usage patterns with the --model flag. The description directly relates to all the changes across the three modified files and provides helpful context for understanding how the new functionality should be used.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix_model_list_cli

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.

@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/llm.py (1)

552-554: Clarify the comment for accuracy.

The comment states "model already loaded from file," but self._llms can contain models from multiple sources (model list file, Robusta AI models, or previously loaded config models). The comment should be more generic to avoid confusion.

Consider updating the comment to reflect the actual behavior:

             if self._llms and self.config.model in self._llms:
-                # model already loaded from file
+                # model already exists in loaded models, skip re-loading
                 return False
holmes/config.py (2)

288-296: Consider consistent parameter naming across similar methods.

The parameter is named model_name here, but other similar factory methods in this class use model (see create_agui_toolcalling_llm at line 302, create_toolcalling_llm at line 315, and create_issue_investigator at line 328). This inconsistency may confuse users of the API.

Consider renaming for consistency:

     def create_console_toolcalling_llm(
         self,
         dal: Optional["SupabaseDal"] = None,
         refresh_toolsets: bool = False,
         tracer=None,
-        model_name: Optional[str] = None,
+        model: Optional[str] = None,
     ) -> "ToolCallingLLM":
         tool_executor = self.create_console_tool_executor(dal, refresh_toolsets)
         from holmes.core.tool_calling_llm import ToolCallingLLM
 
         return ToolCallingLLM(
             tool_executor,
             self.max_steps,
-            self._get_llm(tracer=tracer, model_key=model_name),
+            self._get_llm(tracer=tracer, model_key=model),
         )

And update all call sites in holmes/main.py accordingly.


349-368: Consider adding tracer support for consistency.

The create_console_issue_investigator method doesn't accept or pass a tracer parameter to _get_llm, while the similar create_console_toolcalling_llm method (line 288) does support tracing. This inconsistency may limit observability for console-based issue investigations.

If tracing should be supported, update the method signature and call:

     def create_console_issue_investigator(
-        self, dal: Optional["SupabaseDal"] = None, model_name: Optional[str] = None
+        self, dal: Optional["SupabaseDal"] = None, model_name: Optional[str] = None, tracer=None
     ) -> "IssueInvestigator":
         all_runbooks = load_builtin_runbooks()
         for runbook_path in self.custom_runbooks:
             all_runbooks.extend(load_runbooks_from_file(runbook_path))
 
         from holmes.core.runbooks import RunbookManager
 
         runbook_manager = RunbookManager(all_runbooks)
         tool_executor = self.create_console_tool_executor(dal=dal)
         from holmes.core.tool_calling_llm import IssueInvestigator
 
         return IssueInvestigator(
             tool_executor=tool_executor,
             runbook_manager=runbook_manager,
             max_steps=self.max_steps,
-            llm=self._get_llm(model_key=model_name),
+            llm=self._get_llm(model_key=model_name, tracer=tracer),
             cluster_name=self.cluster_name,
         )

Then update call sites in holmes/main.py if tracing is needed for those commands.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between db836ae and 8dc6d4d.

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

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.py: Use Ruff for formatting and linting (configured in pyproject.toml) for all Python code
Type hints are required; code should pass mypy (configured in pyproject.toml)
ALWAYS place Python imports at the top of the file, not inside functions or methods

Files:

  • holmes/main.py
  • holmes/core/llm.py
  • holmes/config.py
🧬 Code graph analysis (2)
holmes/main.py (1)
holmes/config.py (1)
  • create_console_issue_investigator (349-368)
holmes/config.py (1)
holmes/core/tool_calling_llm.py (1)
  • ToolCallingLLM (165-1013)
⏰ 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). (5)
  • GitHub Check: build (3.12)
  • GitHub Check: build (3.11)
  • GitHub Check: build (3.10)
  • GitHub Check: llm_evals
  • GitHub Check: build
🔇 Additional comments (1)
holmes/main.py (1)

264-264: LGTM! Model parameter propagation is correct.

The changes consistently propagate the model parameter through all CLI commands to enable explicit model selection. The pattern is uniform across ask, investigate alertmanager, investigate jira, investigate ticket, investigate github, investigate pagerduty, and investigate opsgenie commands.

Also applies to: 417-417, 546-546, 622-622, 663-663, 738-738, 822-822, 908-908

mainred
mainred previously approved these changes Nov 18, 2025

@mainred mainred left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for fixing the issue.

@Avi-Robusta
Avi-Robusta enabled auto-merge (squash) November 25, 2025 15:54
@github-actions

Copy link
Copy Markdown
Contributor

Results of HolmesGPT evals

  • ask_holmes: 28/36 test cases were successful, 6 regressions, 2 setup failures
Test suite Test case Status
ask 01_how_many_pods ✅
ask 02_what_is_wrong_with_pod ✅
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_oom_kill_from_issues_history ✅
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 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
  • :minus: 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 was throttled by API rate limits/overload
  • ❌ the test failed and should be fixed before merging the PR

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.

3 participants