Skip to content

[STORY] Claude Model Selection for Jobs #76

@jsbattig

Description

@jsbattig

Part of: #71

Feature: Model Configuration

Story: Claude Model Selection for Jobs

Overview

Objective: Add configurable model selection (Opus/Sonnet) for Claude jobs, exposed in web UI.

User Value: As an admin, I want to select which Claude model (Opus or Sonnet) is used for self-monitoring and golden repo analysis so that I can balance cost and quality based on my needs.

Acceptance Criteria

AC1: SelfMonitoringConfig Model Field

Given SelfMonitoringConfig dataclass
When model field is defined
Then it is a string with default value "opus"
And valid values are "opus" or "sonnet"
And it is persisted to config.json

AC2: GoldenReposConfig Model Field

Given GoldenReposConfig dataclass
When analysis_model field is added
Then it is a string with default value "opus"
And valid values are "opus" or "sonnet"
And it is persisted to config.json

AC3: Self-Monitoring Web UI Model Selector

Given the Self-Monitoring configuration section
When the model selector is displayed
Then it is a dropdown with options: "Opus", "Sonnet"
And "Opus" is selected by default
And changing selection and saving persists the choice

AC4: Golden Repos Web UI Model Selector

Given the Golden Repos configuration section (or Claude Integration config)
When the analysis_model selector is displayed
Then it is a dropdown with options: "Opus", "Sonnet"
And "Opus" is selected by default
And changing selection and saving persists the choice

AC5: Claude CLI Model Parameter

Given a self-monitoring scan is triggered
When Claude CLI is invoked
Then --model {self_monitoring_config.model} is passed
And Claude uses the specified model (opus or sonnet resolves to latest version)

AC6: Claude Server Model Parameter

Given a golden repo analysis job is created
When claude_server_client.create_job is called
Then the Model field is included in the JSON payload
And the value is from golden_repos_config.analysis_model

AC7: Claude CLI Model Alias Verification

Given Claude CLI is invoked with --model opus
Then Claude resolves "opus" to the latest Opus version
Given Claude CLI is invoked with --model sonnet
Then Claude resolves "sonnet" to the latest Sonnet version

Technical Requirements

Files to Modify

  • src/code_indexer/server/utils/config_manager.py
    • Add model field to SelfMonitoringConfig
    • Add analysis_model field to GoldenReposConfig
  • src/code_indexer/server/self_monitoring/scanner.py
    • Pass --model to Claude CLI invocation
  • src/code_indexer/server/clients/claude_server_client.py
    • Add model parameter to create_job method
    • Include Model in JSON payload if provided
  • src/code_indexer/server/web/templates/self_monitoring.html
    • Add model dropdown to configuration section
  • src/code_indexer/server/web/templates/config.html (or golden_repos section)
    • Add analysis_model dropdown

Claude CLI Invocation Pattern

cmd = ["claude", "--print", "--model", config.model, prompt]
subprocess.run(cmd, ...)

Claude Server API Pattern

async def create_job(self, prompt: str, repositories: List[str], model: Optional[str] = None):
    json_data = {"prompt": prompt, "Repositories": repositories}
    if model:
        json_data["Model"] = model
    ...

Testing Requirements

  • Unit test for config field defaults
  • Unit test for CLI argument construction
  • Unit test for API payload construction
  • Integration test for end-to-end model selection

Definition of Done

  • SelfMonitoringConfig.model field implemented (default "opus")
  • GoldenReposConfig.analysis_model field implemented (default "opus")
  • Self-Monitoring UI has model dropdown
  • Golden Repos config has analysis_model dropdown
  • Claude CLI invoked with --model parameter
  • Claude Server API includes Model in payload
  • All tests pass
  • Code review approved

Metadata

Metadata

Assignees

No one assigned

    Labels

    completedStory/Epic completed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions