adk-python icon indicating copy to clipboard operation
adk-python copied to clipboard

Disable forced `.env` loading

Open matiasedgeandnode opened this issue 1 year ago • 5 comments

Is your feature request related to a problem? Please describe. I have a mono-repo with env var loading handled by direnv. In particular it loads env vars from files in this order: .env then .env.local. Now when I run:

uv --directory=python/example-buyers run -- adk run src/example_buyers/adk/a2a_example

ADK re-loads .env file automatically, negating any overrides in .env.local

I understand this is a convenience feature, but it'd be great if there was a way to disable this behavior.

Describe the solution you'd like A flag I can pass to adk run like --no-dotenv or similar, to disable this automatic behavior.

Describe alternatives you've considered For now, I've renamed by env files to .env.dev and .env.local.

matiasedgeandnode avatar Oct 20 '25 13:10 matiasedgeandnode

We have the same issue in a monorepo.

Not a solution but a temporary workaround:

.env in the agents folder (the var name doesn't matter)

# This file prevents the adk from traversing up the directory tree searching for .env files
PREVENT_PARENT_ENV_LOAD=true

We committed this file to our repo.

bastiandg avatar Oct 21 '25 13:10 bastiandg

Thanks @bastiandg, that's a neat workaround 👍

matiasedgeandnode avatar Oct 21 '25 14:10 matiasedgeandnode

@speedstorm1 - I can work on this

speedstorm1 avatar Oct 27 '25 23:10 speedstorm1

Hi @bastiandg and @matiasedgeandnode ,

Thanks for bringing this up. Now, as part of https://github.com/google/adk-python/commit/15afbcd1587d4102a4dc5c07c0c493917df9d6ea, you may set the environment variable ADK_DISABLE_LOAD_DOTENV=true to skip the automatic .env loading.

speedstorm1 avatar Oct 29 '25 17:10 speedstorm1

Thanks for fixing this @speedstorm1 👍

matiasedgeandnode avatar Oct 29 '25 17:10 matiasedgeandnode