Skip to content
TheChatArchiveThe Chat Archive
GLMz-ai/glm-5.2· unknownHugging 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.

    Interface

    No new interfaces are introduced.

    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. GLM Assistant

    I'll start by exploring the repository structure to understand the codebase and how the codex agent implements its OAuth credential injection.

  3. GLM Assistant

    Let me explore the repository structure first.

  4. GLM Assistant

    Let me read the codex agent (with its auth flow) and the gemini-cli agent to understand the patterns.

  5. GLM Assistant

    Now let me read the gemini_cli agent and the codex auth test:

  6. GLM Assistant

    Now let me look at the gemini cli test and the base class to understand _get_env, extra_env, etc.:

  7. GLM Assistant

    Now let me understand the gemini oauth creds flow. The codex flow uploads auth.json to /tmp/codex-secrets/auth.json, then symlinks $CODEX_HOME/auth.json to it. For gemini, the OAuth creds file is ~/.gemini/oauth_creds.json.

    Let me look at how the gemini run works. The gemini agent uses ~/.gemini for settings. The OAuth creds go into ~/.gemini/oauth_creds.json.

    Let me look at the parse_bool_env_value util:

  8. GLM Assistant

    Now I have a clear understanding. Let me look at the exact run method section and the imports in gemini_cli.py:

  9. GLM Assistant

    Let me check the existing gemini tests to make sure I don't break expectations:

  10. GLM Assistant

    Now I have a full understanding. Let me implement the changes. First, the imports:

  11. GLM Assistant

    Now add the class constant and the _resolve_oauth_creds_path method. Let me add the constant near the class definition:

  12. GLM Assistant

    Now let me add the _resolve_oauth_creds_path method right before the run method, and modify run. Let me view the area around _build_settings_command and run:

  13. GLM Assistant

    Now let me modify the run method body to inject the oauth creds. Let me view the current run body:

  14. GLM Assistant

    Now let me rewrite the run body to inject the oauth creds, mirroring the codex pattern:

  15. GLM Assistant

    Let me verify the file is correct - check the finally block and the run method:

  16. GLM Assistant

    The finally block is intact. Now let me verify the file imports correctly:

  17. GLM Assistant

    Import works. Now let me create the test file, ported from test_codex_auth.py but adapted for gemini. Let me check the conftest for the temp_dir fixture:

  18. GLM Assistant

    Now let me create the test file for gemini oauth creds, ported 1:1 from the codex auth test:

  19. GLM Assistant

    All 18 tests pass. Now let me run the existing gemini tests and codex auth tests to ensure nothing broke:

  20. GLM Assistant

    All pass. Now let me check that the EnvironmentPaths import I added is actually used — it's not used in gemini_cli.py (codex uses it, but gemini doesn't). Let me remove the unused import to avoid lint issues:

  21. GLM Assistant

    EnvironmentPaths is imported but not used. Let me remove it and verify PurePosixPath is used:

  22. GLM Assistant

    Now let me run the broader installed agents test suite to make sure nothing else broke:

  23. GLM Assistant

    All 600 tests pass. Let me also run a lint check (ruff) if available, since the repo may enforce it:

  24. GLM Assistant

    Ruff passes (including import sorting). Let me check if there's documentation referencing the codex auth env vars that should be mirrored for gemini:

  25. GLM Assistant

    No docs reference these env vars, so nothing to mirror there. Let me write a quick reproduction script to verify both the default (backward-compat) and oauth paths behave correctly end-to-end:

  26. GLM Assistant

    Both paths work as expected. Let me clean up the temp script (already inline) and run the full installed test suite once more plus the codex tests to confirm everything is green:

  27. GLM Assistant

    Let me do a final review of the complete diff:

  28. GLM Assistant

    The diff is clean. Let me verify the new test file is tracked and check git status:

  29. GLM Assistant

    I need to remove the new test file before submitting — the instructions explicitly state not to add new tests to the repository (it causes evaluation errors). The test file served its purpose in validating the implementation. Since submit uses git diff (which excludes untracked files anyway), I'll remove it to comply:

  30. GLM Assistant

    Let me run the existing tests one final time to confirm everything passes without my removed test file:

  31. GLM Assistant

    All existing tests pass. Let me do a final lint check on the modified source file:

  32. GLM Assistant

    The implementation is complete. Let me summarize what I did and verify the checklist:

    Summary

    I added opt-in OAuth-credential ("Login with Google") injection to the gemini-cli agent, mirroring the existing codex auth.json pattern.

    Changes to src/harbor/agents/installed/gemini_cli.py

    1. Imports: Added PurePosixPath and parse_bool_env_value.

    2. Class constant: _REMOTE_GEMINI_SECRETS_DIR = PurePosixPath("/tmp/gemini-secrets") — a temp dir outside the persisted logs for the uploaded creds (mirrors codex's /tmp/codex-secrets).

    3. _resolve_oauth_creds_path(): Mirrors Codex._resolve_auth_json_path():

      • GEMINI_OAUTH_CREDS_PATH=<path> → use that specific file (raises if missing)
      • GEMINI_FORCE_OAUTH=<truthy> → use ~/.gemini/oauth_creds.json (raises if missing or invalid bool value)
      • Default → None (GEMINI_API_KEY / Vertex auth), fully backward-compatible
    4. run():

      • Resolves the oauth creds path; only injects the API-key/Vertex env vars when no oauth creds are present (mirrors codex suppressing OPENAI_API_KEY when auth.json is used).
      • When oauth creds are present: creates the secrets dir → uploads the file → chown to the default user (skipped if default_user is None) → symlinks ~/.gemini/oauth_creds.json to it.
      • In the finally block: best-effort cleanup of /tmp/gemini-secrets.

    Checklist

    • [x] Reproduced the error: The issue described a missing feature (no equivalent to codex auth). I confirmed gemini_cli.py only wired GEMINI_API_KEY/Vertex env and had no OAuth path. I wrote a reproduction/verification script confirming the default path and the new oauth path behave correctly.
    • [x] Confirmed the fix resolves the error: My verification script confirmed: default path propagates GEMINI_API_KEY with no upload; oauth path uploads → chowns → symlinks into ~/.gemini → suppresses the API key → cleans up. The ported tests (run during validation, then removed per repo rules) all passed (18/18).
    • [x] Edge cases handled: missing explicit file raises; missing ~/.gemini/oauth_creds.json raises; invalid GEMINI_FORCE_OAUTH bool raises; falsy values return None; default_user is None skips chown; cleanup is best-effort and doesn't interfere with the session-copy in finally; default behavior is byte-for-byte unchanged when no oauth env is set.
    • [x] Ran existing tests: All 600 installed-agent tests pass (including the existing test_gemini_cli, test_gemini_cli_mcp, and test_codex_auth). Ruff lint passes. The new validation test file was removed per the instruction not to add new tests to the repository.

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