_resolve_endpoint raises ValueError when provider/model in agent config is not a string
- Dominant language
- Python
- Stars
- 5.9k
- Forks
- 516
- Avg merge
- 22m
- Merged PRs (30d)
- 5
Description
In `artemis/services/llm.py`, `_resolve_endpoint` extracts `provider_val` and `model_val` using bare `getattr`:
```python
provider_val = getattr(cfg, "provider", "google")
model_val = getattr(cfg, "model", "gemini-2.5-flash")
```
While other fields in the same function use `_get_val(obj, attr, expected_type)` to safely validate types, `provider_val` and `model_val` do not. When `cfg` has non-string or mock attributes (such as in `tests/unit/agents/test_explorer.py`), `getattr` does not fall back to the default string, causing `ModelProvider.from_string` to raise:
```
ValueError: Unknown LLM provider . Valid providers: ['anthropic', 'claude', 'custom', 'gemini', 'google', 'grok', 'ollama', 'openai', 'openrouter', 'vertex', 'vertexai', 'vllm', 'xai']
```
This currently breaks 9 unit tests in `tests/unit/agents/test_explorer.py`.
### Fix
Use `_get_val(cfg, "provider", str) or "google"` and `_get_val(cfg, "model", str) or "gemini-2.5-flash"` consistent with the other fields in `_resolve_endpoint`.
Contributor guide
Research direction
Start in artemis/services/llm.py at _resolve_endpoint and compare provider/model handling with the other fields using _get_val. Run tests/unit/agents/test_explorer.py to reproduce the nine failures. Done means non-string provider or model attributes use the documented string defaults and the affected tests pass.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- ai, testing
- Issue type
- Bug
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 92/100