The cloud task works on a fresh copy of your repo from GitHub, and .env.local is not in there (good). You need to give the environment its own variables in the Codex environment settings.
What I would do:
- Don't give it your production keys. Give it a separate test project, or run Supabase locally in the setup script if your tests need a real database.
- Put the non-secret values (the URL, the anon key of the test project) in environment variables.
- Anything that must stay secret goes in secrets. Those are only available while the setup script runs, not while the agent works, which is exactly what you want for keys.
And reverting the mock was the right call. "Make the tests pass" is a dangerous task for an agent, because deleting the check is also a way to pass.