From bc1911abb59e84c36889d53080f221b0b85c98b8 Mon Sep 17 00:00:00 2001 From: Todd Hoffman Date: Thu, 9 Jul 2026 16:03:48 -0700 Subject: [PATCH] fix: load .env file at startup in basic-tui-agent scaffold The scaffold declares python-dotenv as a dependency and IMPLEMENTATION.md instructs that secrets belong in .env via python-dotenv, but nothing ever calls load_dotenv(). Values in .env (OPENAI_API_BASE, OPENAI_API_KEY, OPENAI_MODEL) were silently ignored and every agent generated from this scaffold fell back to config.yaml defaults with a "dummy" API key. Load .env in src/config.py before the config is initialized, anchored to the project root with a cwd fallback. Real environment variables still take precedence over .env values. Also ignore .env at the repo root so local secrets can't be committed by accident. Found while debugging an agent generated by this skill (kyuz0/deep-research-agent); this upstreams the same fix so future generated agents don't inherit the bug. Co-Authored-By: Claude Fable 5 --- .gitignore | 4 +++- .../examples/basic-tui-agent/src/config.py | 5 +++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 19734d8..bc758c8 100644 --- a/.gitignore +++ b/.gitignore @@ -10,4 +10,6 @@ research/ .eggs/ *.egg build/ -dist/ \ No newline at end of file +dist/ +# Local secrets +.env diff --git a/skills/local-agent-builder/examples/basic-tui-agent/src/config.py b/skills/local-agent-builder/examples/basic-tui-agent/src/config.py index ef09f1f..9ab5c23 100644 --- a/skills/local-agent-builder/examples/basic-tui-agent/src/config.py +++ b/skills/local-agent-builder/examples/basic-tui-agent/src/config.py @@ -2,6 +2,11 @@ import sys import yaml import copy +from dotenv import load_dotenv + +# Load .env from the project root (parent of src/), falling back to cwd lookup +load_dotenv(os.path.join(os.path.dirname(__file__), "..", ".env")) +load_dotenv() def _get_config_path_from_args(): for i, arg in enumerate(sys.argv):