Skip to content

fix: load .env file at startup in basic-tui-agent scaffold - #3

Open
hofftodd wants to merge 1 commit into
kyuz0:mainfrom
hofftodd:fix/load-dotenv
Open

hofftodd wants to merge 1 commit into
kyuz0:mainfrom
hofftodd:fix/load-dotenv

Conversation

@hofftodd

@hofftodd hofftodd commented Jul 9, 2026

Copy link
Copy Markdown

Summary

The basic-tui-agent scaffold declares python-dotenv as a dependency, and resources/docs/IMPLEMENTATION.md instructs that "Secrets belong inside .env via python-dotenv" — but nothing in the scaffold ever calls load_dotenv(). Values in .env (OPENAI_API_BASE, OPENAI_API_KEY, OPENAI_MODEL) are silently ignored, so every agent generated from this scaffold falls back to the config.yaml defaults with a "dummy" API key.

Changes

  • Load .env in src/config.py before the config is initialized, anchored to the project root (parent of src/) with a cwd-lookup fallback. Real environment variables still take precedence over .env values, so the existing env-overlay behavior is unchanged.
  • Add .env to the repo-root .gitignore so local secrets can't be committed by accident.

Context

Found while debugging an agent generated by this skill — this is the scaffold-level version of kyuz0/deep-research-agent#1, upstreamed here so future generated agents don't inherit the bug.

🤖 Generated with Claude Code

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 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant