When codeagent-wrapper sets cmd.Dir=$HOME for Gemini backend, Gemini CLI
hangs after emitting init event on long prompts (e.g. with ROLE_FILE
injection). Only the init JSON event is output, then no further events
are produced — causing the wrapper to block indefinitely.
Root cause: Gemini CLI performs directory scanning from CWD. When CWD is
$HOME (which typically contains thousands of files), combined with a
long prompt, Gemini stalls between init and the first user message event.
Fix: Use workDir as CWD for Gemini (same as Claude backend). The
original $HOME workaround was to prevent project .env files from
overriding global API keys (gemini-cli#2493), but this is already
handled by cmd.SetEnv() which injects API keys from
loadMinimalEnvSettings() with higher priority than .env files.
Tested: exact same command that previously hung for 90s+ now completes
in 65-85s with correct output.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>