Skip to content

AI agents can unintentionally target upstream repos due to gh defaults #12380

Open

Description

@Benkovichnikita

Describe the feature or problem you’d like to solve

When using the GitHub CLI (gh) in non-interactive, automated environments, cloning a forked repository implicitly configures the upstream (original) repository as the default target for subsequent write actions such as gh issue create.

This behavior is reasonable for human workflows, but becomes risky for AI agents, where execution is fully automated, warnings are not shown, and no interactive confirmation is possible.

We encountered this while solving SWE-bench Verified (500), where AI agents automatically solve historical verified issues on forked repositories.

Proposed solution

Provide safer and more explicit control over the default repository target for automation and agent-based workflows.

Possible directions include:

  • Allow gh repo clone to explicitly define which repository (fork vs upstream) should be set as the default for write actions.
  • Introduce a single atomic command that clones a fork and sets it as the default repository.
  • Emit a machine-readable warning or error when a write action targets upstream while operating from a fork in non-interactive mode.

Chaining commands like:

gh repo clone <fork>
gh repo set-default <fork>

is fragile for LLM-based agents and increases the likelihood of unintended side effects.

Additional context

We are building a multi-agent system for SWE-bench Verified, where agents with different roles (planner, solver, reviewer, etc.) interact with GitHub repositories exclusively via gh. Agents can clone repositories, create issues, open pull requests, and review changes.

These agents run in non-interactive bash environments, where warnings or prompts are not visible.

This behavior resulted in an accidental issues and PRs being opened in an upstream repository during benchmark execution:
sphinx-doc/sphinx#14214
sphinx-doc/sphinx#14212
sphinx-doc/sphinx#14218
sphinx-doc/sphinx#14216
sphinx-doc/sphinx#14215

The issue was closed once identified and the workflow fixed on our side. However, this incident highlights a gap between human-oriented CLI defaults and AI-agent-driven automation.

Improving this would make gh safer and more robust for emerging AI-powered developer workflows, while preserving existing behavior for human users.

Activity

  1. added
    enhancement
    on Dec 27, 2025
  2. github-actions commented on Dec 27, 2025

    @github-actions
    Contributor

    Thank you for your issue! We have categorized it as a feature request, and it has been added to our backlog. In doing so, we are not committing to implementing this feature at this time, but, we will consider it for future releases based on community feedback and our own product roadmap.

    Unless you see the help wanted Contributions welcome label, we are not currently looking for external contributions for this feature.

    If you come across this issue and would like to see it implemented, please add a thumbs up! This will help us prioritize the feature. Please only comment if you have additional information or viewpoints to contribute.

  3. added
    needs-triage
    on Dec 27, 2025
  4. added
    gh-repo
    and removed
    needs-triage
    on Mar 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementgh-repostale

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions