alibaba / alibaba/open-code-review
Support --provider flag in ocr review/scan commands for runtime LLM provider override
- Dominant language
- Go
- Stars
- 24.4k
- Forks
- 1.8k
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 105
Description
### Problem Statement
Currently, changing the LLM provider or model requires running `ocr config set provider ` and `ocr config set model ` to persist the configuration globally. This is inconvenient for users who:
1. Want to quickly test different models/providers for a single review without affecting the default configuration
2. Need to run multiple reviews with different providers in CI/CD pipelines
3. Want to avoid accidentally changing the global default when testing
4. Need to override provider/model in automation scripts
Currently, `ocr review` only supports `--model` but not `--provider`, making it impossible to dynamically switch providers at runtime.
### Proposed Solution
Add `--provider` and `--model` command-line flags to `ocr review` and `ocr scan` commands to allow dynamic provider/model specification without modifying the configuration file.
Proposed syntax:
```bash
# Specify both provider and model at runtime
ocr review --from main --to feature-branch --provider anthropic --model claude-opus-4-6
ocr review --commit abc123 --provider openai --model gpt-4o
ocr scan --provider deepseek --model deepseek-v4-flash
# Use existing default if not specified
ocr review --from main --to feature-branch --model claude-3.5-sonnet # uses current provider
ocr review --from main --to feature-branch --provider openai # uses provider's default model
```
Behavior:
- Runtime flags override the configuration file defaults
- Do not modify `~/.opencodereview/config.json`
- Support both built-in and custom providers
- Validate provider/model existence before starting review
- When resuming sessions, use the runtime-specified provider/model (not the original session's provider)
### Alternatives Considered
1. Use environment variables to override provider/model - but this doesn't provide per-command granularity
2. Continue with current approach - force users to use `ocr config set` for temporary changes
3. Add a temporary config file option - more complex and less intuitive than CLI flags
### Affected Area
CLI / Commands, Configuration
### Additional Context
Related observations:
- Session resume only saves `Model`, not `Provider`, making provider changes during resume potentially unsafe
- Consider also documenting whether resumed sessions should use the original or new provider/model
- This feature would be particularly useful for CI/CD integrations where different steps might need different models
Example use case:
```bash
#!/bin/bash
# First pass: quick review with fast model
ocr review --from main --to feature --provider deepseek --model deepseek-v4-flash --timeout 5
# Second pass: detailed review with high-quality model if needed
if [ $? -ne 0 ]; then
ocr review --from main --to feature --provider anthropic --model claude-opus-4-6
fi
```
Contributor guide
Research direction
Start at the CLI entry points for the ocr review and ocr scan commands and trace how provider, model, and configuration defaults are resolved. Check the session-resume handling and the ~/.opencodereview/config.json behavior. Done means both commands accept runtime overrides, validate them, preserve the config file, and use the specified values when resuming sessions.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- cli
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100