Skip to content

Rework loading .env in load_dotenv_for_agent to respect explicitly specified ENVs #4020

@Spikhalskiy

Description

@Spikhalskiy

Is your feature request related to a problem? Please describe.

Currently, load_dotenv_for_agent has the following code:

    load_dotenv(dotenv_file_path, override=True, verbose=True)

This prevents overriding default variable values specified in .env by explicitly setting environment variables before launching ADK modules.

Describe the solution you'd like
I don't know the history of the question and why override=True was put here in the first place, maybe to allow agent .env to override properties from the root .env, but this approach has a significant adverse side effect - users can't override the variables specified in .env by exporting explicit ENVS before ADK launch.
Could this be reconsidered? It potentially would prevent issues like #3228 and #4018, and potentially may render the unconventional solution with ADK_DISABLE_LOAD_DOTENV flag unnecessary.

Metadata

Metadata

Assignees

No one assigned

    Labels

    core[Component] This issue is related to the core interface and implementation

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions