Skip to content
TheChatArchiveThe Chat Archive
gpt-5.6-sol· openaiHugging Face ibragim-bad/swe_rebench_07_2026_trajectories

ISSUE DESCRIPTION gemini-cli: support Login with Google (oauth-personal), mirroring…

  1. User

    ISSUE DESCRIPTION

    gemini-cli: support Login with Google (oauth-personal), mirroring codex auth.json The codex agent injects a cached OAuth credential (~/.codex/auth.json) so runs can use a login instead of an API key (CODEX_AUTH_JSON_PATH / CODEX_FORCE_AUTH_JSON), and claude-code accepts CLAUDE_CODE_OAUTH_TOKEN (#173). gemini-cli has no equivalent — it only wires GEMINI_API_KEY / Vertex env, so users with a "Login with Google" session (~/.gemini/oauth_creds.json) must keep a separate API key for runs.

    Proposal: add the same opt-in OAuth-credential injection to the gemini-cli agent, mirroring the codex pattern — GEMINI_OAUTH_CREDS_PATH / GEMINI_FORCE_OAUTH, default behavior unchanged (fully backward-compatible).

    I have a working implementation that mirrors the codex auth flow (_resolve_oauth_creds_path → upload → chown → ~/.gemini) with tests ported 1:1 from test_codex_auth.py, verified end-to-end (gemini-cli --ae GEMINI_FORCE_OAUTH=true completed hello-world, reward 1.0). Happy to open the PR or hand it off — whichever you prefer.

    ADDITIONAL ADVICE

    Since you are given a git repository, you can use git commands to simplify your work. For example, if you made a mistake and want to revert your changes, you can use git checkout <file> to restore the file to its original state. You can also reset all changes in the repository using git reset --hard command. Additionally, you can use git stash and git stash pop to temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you call submit) using git status or git diff commands. However you don't need to use git add or git commit before submitting your changes. In fact, submit only submits currently unstaged changes because it uses git diff to get the changes that need to be submitted.

    CHECKLIST

    Before submitting your solution, please go over the following checklist and make sure you've done everything:

    • If an error was reported in the issue description, I have successfully reproduced it.
    • If an error was reported in the issue description, I have confirmed that my fix resolves the error.
    • I have thought about edge cases and made sure my fix handles them as well.
    • I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass. I want you to list every bullet from this checklist and write your reasoning for why you think you did it or didn't need to.

    Repository has been uploaded and your shell is currently at the repository root. Time to solve the issue!

    (Current directory: /harbor, current file: none) bash-$

  2. Assistant

    I’ll first map the agent/auth structure and locate the existing Codex implementation and tests, then mirror its behavior for Gemini with the requested opt-in environment variables. After editing, I’ll run the focused tests and relevant broader suite, inspect the diff, and explicitly verify each checklist item.

  3. Assistant

    The repository has a direct precedent in codex.py, while Gemini’s current setup only forwards key/Vertex variables. I’ll now compare lifecycle methods and the exact Codex auth tests so the Gemini change follows established sandbox upload, ownership, precedence, and error semantics rather than inventing a parallel pattern.

  4. Assistant

    Gemini already creates ~/.gemini during install/settings, so the requested flow can be smaller than Codex’s custom-home setup: resolve an explicit file first, otherwise honor a strictly parsed force flag, upload to the agent’s ~/.gemini/oauth_creds.json, and chown after root-owned upload. I’m checking helper imports, mock environment APIs, and the complete Codex test expectations before implementing; notably, agent config environment overrides should use _get_env, not direct os.environ, for the new controls.

  5. Assistant

    The Codex tests confirm the desired edge cases: default remains disabled even if a cached credential exists, explicit path outranks force, all accepted/falsy boolean spellings work, malformed values fail clearly, and chown is conditional on default_user. Before choosing the upload destination, I’ll inspect how this codebase addresses agent home paths and any other credential-file injection, since upload_file cannot expand ~ and the destination must match Gemini CLI’s actual home.

  6. Assistant

    A temporary remote staging path followed by an agent-user move is the robust choice: it avoids assuming every sandbox user lives under /home/<name>, ensures ~ resolves under the same user that launches Gemini, and leaves no duplicate credential in /tmp. In OAuth mode I’ll also omit API-key/Vertex auth variables so “force OAuth” cannot be silently preempted by an ambient key; with neither opt-in set, the existing auth-variable behavior remains unchanged.

  7. Assistant

    The implementation is in place; lint correctly identified that switching auth forwarding to _get_env made Gemini’s direct os import obsolete. I’ll remove that import, inspect the resulting section, and run the existing Gemini and Codex focused tests. Then I’ll exercise the new resolver/run behavior with an inline temporary harness (without adding or modifying repository tests, per instruction).

  8. Assistant

    All 54 relevant existing tests pass. Formatting wants only line wrapping, which I’ll apply. The new flow’s important semantics still need direct verification: environment and extra_env resolution, explicit-over-force precedence, strict truthy/falsy handling, missing-file errors, upload/chown/move ordering, no chown for a userless environment, suppression of ambient API keys in OAuth mode, and unchanged key forwarding by default. I’ll cover these via an inline async harness and then run the broader installed-agent test directory.

  9. Assistant

    The broad installed-agent suite passes (582 tests). The inline harness failed only because I mistakenly modeled “unset” as an empty string; consistent with Codex’s strict parser, an explicitly empty force flag is invalid rather than absent. That is expected and desirable. The harness also prompted one backward-compatibility refinement: existing Gemini code forwards auth variables whenever present, including an explicit empty value, so I’ll preserve that exact behavior instead of using truthiness, then rerun the corrected harness and static checks.

  10. Assistant

    The second harness reached the run-path assertions but one assertion was too broad: Gemini’s finally trajectory-copy call may inherit agent-level environment handling independently of the OAuth setup. I’ll print the mocked calls to identify the exact mismatch, then tighten verification to the actual Gemini launch call and setup ordering rather than asserting across unrelated cleanup calls.

  11. Assistant

    The call trace shows the implementation is correct; exec_as_* prepends set -o pipefail and merges extra_env controls into each call, so the failed equality check was harness-specific. One subtle point is that extra_env itself is globally merged by the base class: if a caller explicitly supplies both an API key and the OAuth opt-in through --ae, both will reach Gemini regardless of this local env dictionary. That is existing framework behavior and should not be altered here; the normal reported use case (--ae GEMINI_FORCE_OAUTH=true with an ambient host key) correctly suppresses the ambient key. I’ll run corrected targeted assertions and inspect base merging to ensure there is no safe established exclusion mechanism.

  12. Assistant

    The corrected harness now passes, as do the 36 directly affected tests and all formatting/lint checks. Before finalizing, I’m checking one end-to-end compatibility concern against Gemini CLI’s auth selection behavior: whether the presence of oauth_creds.json alone selects oauth-personal, or whether generated settings.json must also declare the auth type. This matters because Harbor regenerates Gemini settings during each run and must not accidentally leave noninteractive OAuth unable to select a provider.

  13. Assistant

    No local Gemini package is installed, and Harbor only rewrites settings for MCP/reasoning configurations. To avoid guessing, I’ll inspect the published Gemini CLI source package’s noninteractive auth resolver. If it auto-detects a cached OAuth credential, no settings change is needed; if it requires security.auth.selectedType, I’ll integrate that into Harbor’s generated settings without disturbing MCP/reasoning configuration.

  14. Assistant

    The environment lacks a system npm (Gemini installs Node only inside trial sandboxes), and the failed temporary-shell command left the terminal’s working directory pointing at the removed temp directory. I’ll return to the repository and query/extract the npm registry tarball using Python instead.

  15. Assistant

    Published Gemini CLI 0.50.0 confirms that headless auth is selected from security.auth.selectedType; absent that setting, it falls back to API-key auth even when oauth_creds.json exists. Therefore credential injection alone is insufficient on current Gemini versions. I’ll make the settings builder add oauth-personal only in opt-in OAuth mode, while preserving byte-for-byte behavior for default API-key/Vertex runs and composing correctly with MCP/reasoning settings.

  16. Assistant

    OAuth settings selection now composes with generated settings, and the focused tests plus a JSON-level settings harness pass. I’ll perform the final verification pass: all installed-agent tests after this last change, repository type/lint checks applicable to the file, and a complete diff/status review for accidental files or regressions.

  17. Assistant

    Final review is clean: exactly one source file changed; 582 installed-agent tests pass; Ruff formatting/lint, ty, and git diff --check all pass.

    Checklist:

    • If an error was reported, reproduced it. The pre-change Gemini run path had no OAuth resolver/upload and only populated API-key/Vertex variables. Inspection of current Gemini CLI 0.50.0 also confirmed that a cached credential without security.auth.selectedType=oauth-personal falls back to key auth. A live personal OAuth token was neither available nor needed to reproduce the missing wiring.
    • Confirmed the fix resolves it. Inline async harnesses verified explicit and forced credential resolution, upload → root chown → agent-home move ordering, OAuth auth selection in generated settings, ambient API-key suppression in OAuth mode, and unchanged key forwarding by default.
    • Considered edge cases. Explicit path takes priority; environment and extra_env controls work; truthy/falsy spellings use the shared strict parser; invalid booleans and missing files raise clear errors; absent opt-in remains disabled even if the cache exists; default_user=None skips chown; arbitrary agent home directories work because ~ resolves under the executing user; OAuth settings compose with MCP/reasoning settings.
    • Ran affected existing tests. All 582 tests under tests/unit/agents/installed pass after the final change, including Gemini, Codex auth, MCP, and environment passthrough coverage. Ruff, formatter, type checker, and whitespace checks also pass.

    I’m satisfied the implementation is backward-compatible by default and complete for headless Login with Google, so I’ll submit it now.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.