diff --git a/elroy/cli/options.py b/elroy/cli/options.py index 8f340d28..7d816cbb 100644 --- a/elroy/cli/options.py +++ b/elroy/cli/options.py @@ -10,7 +10,7 @@ from toolz.curried import map, valfilter from ..config.llm import DEFAULTS_CONFIG -from ..config.paths import get_default_sqlite_url +from ..config.paths import get_default_config_path, get_default_sqlite_url from ..core.constants import CLAUDE_3_5_SONNET logger = get_logger() @@ -42,10 +42,7 @@ def resolve_model_alias(alias: str) -> str | None: def load_config_file_params(config_path: str | None = None) -> dict: # Looks for user specified config path, then merges with default values packaged with the lib - user_config_path = config_path or os.environ.get(get_env_var_name("config_path")) - - if not user_config_path: - return {} + user_config_path = config_path or os.environ.get(get_env_var_name("config_path")) or str(get_default_config_path()) if user_config_path and not Path(user_config_path).is_absolute(): logger.info("Resolving relative user config path") # convert to absolute path if not already, relative to working dir diff --git a/tests/test_config.py b/tests/test_config.py index 669997a3..aa1b438b 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -2,6 +2,7 @@ from rich.table import Table +from elroy.core.ctx import ElroyConfig from elroy.tools.developer import print_config from tests.utils import process_test_message @@ -14,3 +15,20 @@ def test_print_config(ctx): def test_custom_config(ctx): ctx.config_path = Path(__file__).parent / "fixtures" / "test_config.yml" process_test_message(ctx, "hello world") + + +def test_default_config_path_is_loaded(monkeypatch, tmp_path): + home_dir = tmp_path / "elroy-home" + config_path = home_dir / "elroy.conf.yaml" + config_path.parent.mkdir(parents=True, exist_ok=True) + config_path.write_text("chat_model: gpt-5.4\n", encoding="utf-8") + + monkeypatch.setenv("ELROY_HOME", str(home_dir)) + monkeypatch.delenv("ELROY_CONFIG_PATH", raising=False) + monkeypatch.delenv("OPENAI_API_KEY", raising=False) + monkeypatch.delenv("ANTHROPIC_API_KEY", raising=False) + monkeypatch.delenv("GEMINI_API_KEY", raising=False) + + ctx = ElroyConfig.init() + + assert ctx.model_config.chat_model == "gpt-5.4"