mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-07-28 10:09:21 +00:00
fix(cli): load project .env in the declarative-flow runner
The declarative-flow path never loaded .env — flow projects (type = "flow") missed API keys/config that crew projects pick up. The JSON-crew path loads Path.cwd()/.env with override=True (run_crew._run_json_crew); mirror that at the top of run_declarative_flow() so flow projects behave the same regardless of where crewai is installed. Test: run_declarative_flow_loads_project_env. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RBYGqJHC2TMC6fonFziuuh
This commit is contained in:
@@ -52,6 +52,15 @@ def run_declarative_flow(definition: str | Path, inputs: str | None = None) -> N
|
||||
for interactively, and everything is validated against the schema before
|
||||
kickoff — so a bare ``crewai run`` on a configured flow just works.
|
||||
"""
|
||||
# Load the project's .env before kickoff, mirroring the JSON-crew path
|
||||
# (run_crew._run_json_crew) so flow projects pick up API keys/config the
|
||||
# same way regardless of where crewai is installed.
|
||||
from dotenv import load_dotenv
|
||||
|
||||
env_file = Path.cwd() / ".env"
|
||||
if env_file.exists():
|
||||
load_dotenv(env_file, override=True)
|
||||
|
||||
provided = _parse_inputs(inputs) or {}
|
||||
|
||||
flow = load_declarative_flow(definition)
|
||||
|
||||
Reference in New Issue
Block a user