fix(hypotheses): symlink .env into worktree for local dev

load_dotenv() in tradingagents/config.py searches the cwd for .env.
Worktrees in /tmp/ don't have one, so symlink the main repo's .env
into the worktree root before running discovery.

In CI, secrets are passed as env vars directly — symlink is a no-op.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Youssef Aitousarrah 2026-04-10 11:12:36 -07:00
parent a956863c48
commit 9e1c800f01
1 changed files with 7 additions and 0 deletions

View File

@ -131,6 +131,13 @@ def run_hypothesis(hyp: dict) -> bool:
run(["git", "fetch", "origin", branch], check=False)
run(["git", "worktree", "add", worktree, branch])
# Symlink .env from main repo into worktree so load_dotenv() finds it locally.
# In CI, secrets are env vars already — the symlink is a no-op there.
env_src = ROOT / ".env"
env_dst = Path(worktree) / ".env"
if env_src.exists() and not env_dst.exists():
env_dst.symlink_to(env_src)
try:
result = subprocess.run(
[