codex - 💡(How to fix) Fix Codex sub-agent does not reuse authenticated CLI session from user shell on Windows PowerShell 7 [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openai/codex#18107Fetched 2026-04-17 08:32:48
View on GitHub
Comments
0
Participants
1
Timeline
12
Reactions
0
Author
Participants
Timeline (top)
labeled ×6renamed ×3unlabeled ×3
RAW_BUFFERClick to expand / collapse

What version of Codex CLI is running?

codex-cli 0.121.0

What subscription do you have?

pro

Which model were you using?

gpt-5.4

What platform is your computer?

Microsoft Windows NT 10.0.26200.0 x64

What terminal emulator and version are you using (if applicable)?

PowerShell 7

What issue are you seeing?

When a Codex sub-agent runs gemini -p "hello!", Gemini CLI does not return the model response. Instead, it stops at this authentication prompt: Opening authentication page in your browser. Do you want to continue? [Y/n]: This happens even though the exact same command works correctly when I run it manually in my own PowerShell session.

What steps can reproduce the bug?

  1. Start a Codex session where sub-agents are available.
  2. Ask Codex to spawn a sub-agent.
  3. In the sub-agent, run: gemini -p "hello!"
  4. Observe that the sub-agent does not return a Gemini response and instead shows: Opening authentication page in your browser. Do you want to continue? [Y/n]:

What is the expected behavior?

If Gemini CLI is already authenticated and working in the user’s local PowerShell environment, a Codex sub-agent should be able to run the same command and return the Gemini response.

If session/auth state cannot be inherited, Codex should at least fail with a clearer explanation of what execution context is missing, instead of appearing to have access to the environment while still triggering a fresh browser-auth flow.

Additional information

OS / shell: Windows PowerShell 7 The same command works when run manually by the user: gemini -p "hello!" In the Codex sub-agent environment, the command exits with code 0 but only prints the authentication prompt shown above The sub-agent was able to access the Gemini config directory: C:\Users\<username>\.gemini

The sub-agent could list files there, including: google_accounts.json oauth_creds.json state.json settings.json installation_id projects.json

The sub-agent could also resolve PowerShell profile paths normally, including: C:\Users\<username>\Documents\PowerShell\Microsoft.PowerShell_profile.ps1 This suggests the issue is not basic file access, but that the Codex sub-agent execution context does not fully reuse the same authenticated Gemini CLI session as the user’s interactive shell.

extent analysis

TL;DR

The issue is likely due to the Codex sub-agent not inheriting the authentication session from the user's PowerShell environment, causing the Gemini CLI to prompt for authentication instead of returning the model response.

Guidance

  • Verify that the Gemini CLI authentication session is properly configured and active in the user's PowerShell environment before running the Codex sub-agent.
  • Check the environment variables and configuration files accessed by the Codex sub-agent to ensure they match the user's environment, particularly the C:\Users\<username>\.gemini directory and its contents.
  • Investigate how the Codex sub-agent handles authentication and session management, and consider implementing a mechanism to inherit or reuse the user's authentication session.
  • Test running the gemini -p "hello!" command in the Codex sub-agent with explicit authentication flags or environment variables to see if it bypasses the authentication prompt.

Example

No code snippet is provided as the issue is more related to environment and session management.

Notes

The issue seems to be specific to the interaction between the Codex sub-agent and the Gemini CLI authentication mechanism, and may require modifications to the Codex sub-agent or the Gemini CLI configuration to resolve.

Recommendation

Apply workaround: Modify the Codex sub-agent to properly inherit or reuse the user's Gemini CLI authentication session, or provide a mechanism for the user to authenticate within the sub-agent environment. This is necessary because the current behavior causes confusion and does not meet the expected functionality of reusing the user's authenticated session.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING