Skip to content

"Vibe-Trading: Your Personal Trading Agent"

fix(preflight): reset EnvConfig after dotenv load to pick up .env values (#479)

Ananayb410eba3cfaa
diff --git a/agent/src/preflight.py b/agent/src/preflight.py
index e75f33fbb..f6d17fcac 100644
--- a/agent/src/preflight.py
+++ b/agent/src/preflight.py
@@ -15,7 +15,7 @@ from typing import List, Optional
from rich.console import Console
from rich.table import Table
-from src.config.accessor import get_env_config
+from src.config.accessor import get_env_config, reset_env_config
@dataclass(frozen=True)
@@ -34,6 +34,11 @@ def _check_llm_provider() -> CheckResult:
from src.providers.llm import _ensure_dotenv, _sync_provider_env, provider_diagnostics
_ensure_dotenv()
+ # The EnvConfig singleton may have been cached before _ensure_dotenv()
+ # loaded the .env file (e.g. by theme.py's import-time _is_dark_terminal
+ # call). Reset it so get_env_config() rebuilds from the now-populated
+ # os.environ.
+ reset_env_config()
_cfg = get_env_config()
provider = _cfg.llm.langchain_provider.strip()
model = _cfg.llm.langchain_model_name.strip()