When an AI coding agent opens a pull request, the question is no longer whether the code is good but whose identity wrote it, who is accountable for it and which human is allowed to let it merge. This guide sets out a governance model for agent-authored pull requests: how agents should be identified, how their commits should be attributed, which branch and review rules should apply, and how to stop the person who asked an agent for a change from also being the only person who approves it.
It is a companion to our AI Coding Agents Security Guide, which covers sandboxing, tool permissions and prompt injection. Here we stay at the point where agent output enters your source of truth: the pull request. Examples draw on GitHub's documented controls because they are widely used and publicly described; the same principles apply to any platform with branch rules, required reviews and machine identities.
Key takeaways
- An agent is a non-human identity. Give it its own account or app identity, scoped to the repositories it works on, and never let it act through a developer's personal token.
- Attribution needs two names: the agent that authored the change and the human who requested it. Both should appear in the commit history and the pull request.
- The requester should not be the approver. Require an independent human approval for every agent-authored pull request.
- Agents should never approve or merge their own work, and automation tokens should not be able to approve pull requests at all.
- Constrain where agents can push. A dedicated branch prefix plus rulesets that protect default and release branches limits the blast radius of a confused or hijacked agent.
- Hold workflows on agent branches until a human has reviewed the change, because CI runs with secrets and cloud credentials.
Why agent pull requests need their own governance
Traditional review rules assume a person wrote the code and a different person reviewed it. AI coding agents break that assumption in three ways.
- Authorship is blurred. A developer types a request, an agent writes hundreds of lines, and the commits may carry the developer's name, the agent's name or both. Without a rule, audit trails cannot show who did what.
- Review becomes self-review. The developer who asked for the change often feels ownership of it and approves it. In practice that is one human approving their own request, with an agent in the middle.
- The agent holds credentials. To open a pull request the agent needs a token that can push to the repository. If that token is a developer's personal access token, the agent inherits everything the developer can do, across every repository they can reach.
Separation of duties, least privilege and accountability are old controls. The work is to apply them to a new kind of contributor. The OWASP Top 10 for Agentic Applications and the OWASP Non-Human Identities Top 10, both listed below, frame the same risks from the agent and identity sides.
Agent identity: who is pushing the code
Every agent that writes to a repository should have an identity you can name, scope, audit and revoke on its own.
Preferred: an app or platform-managed agent identity
Where the platform offers a managed agent identity or an installable app, use it. App identities have permissions set per installation and per repository, short-lived installation tokens and a clear "bot" label in the interface. Our GitHub Apps vs Personal Access Tokens vs OAuth Apps guide explains why app identities are usually the safer machine identity for automation.
GitHub's own coding agent shows what a platform-managed identity can enforce. GitHub documents that only users with write access to the repository can trigger the agent, that it can only perform simple push operations rather than running arbitrary Git commands, and that it pushes to a single branch.
Acceptable: a dedicated machine user
If an agent can only work through a user account, create a dedicated machine user per agent or per team, never shared with humans. Give it only the repositories it needs, a fine-grained token with a short expiry, and an owner in your identity inventory. Record it as a non-human identity with a named human sponsor, exactly as you would a service account.
Avoid: the developer's personal token
Running an agent with a developer's personal token is the most common and most dangerous pattern. The agent's pushes look like the developer's, the token usually reaches far more repositories than the task needs, and a prompt injection in one repository can be used to act in another. If local agents must use the developer's session, restrict them to local branches and require the developer to push and open the pull request themselves, so the review rules below still apply.
Attribution: recording agent and human together
Good attribution answers three questions for any commit: which agent produced it, which human asked for it and which session or task it came from.
- Author the commit as the agent. The agent identity should be the commit author or committer, so history and blame show machine-written code clearly.
- Name the human as co-author or requester. GitHub documents that its coding agent's commits are authored by Copilot, with the developer who assigned the issue marked as co-author. Whatever agent you use, adopt a similar rule, using a co-author trailer or a pull request field.
- Link to the session. GitHub states that each of its agent's commits links to the session logs. For other agents, include a task or session identifier in the pull request description so reviewers and incident responders can trace the prompt and tool calls.
- Sign the commits. GitHub notes its coding agent's commits are signed and appear as Verified. For agents you run yourself, sign with a key or keyless identity tied to the agent, not a developer's personal signing key.
- Label the pull request. A consistent label or title prefix lets you report on agent-authored changes, apply extra checks and measure review quality.
Our AI Agent Attribution and Non-Repudiation guide covers the logging and evidence side in more depth.
Approval rules: who may approve agent work
The core rule is simple: an agent-authored pull request needs approval from a human who neither requested it nor pushed to it.
Block self-approval by the requester
GitHub's coding agent prevents the user who asked it to create a pull request from approving that pull request, and the agent itself cannot approve or merge. If your agent does not enforce this natively, achieve it with rules: require at least one approval and enable Require approval of the most recent reviewable push, which GitHub describes as requiring an approval from someone other than the last person to push to a branch. Where a developer pushes follow-up commits onto an agent branch, this rule stops them approving their own last push.
Add an approval for unattributed agent work
GitHub documents that, if a pull request opened by its agent is not attributed to a person and the repository already requires at least one approval, one more approval is required before merging. This is enabled by default in rulesets and has no effect if the ruleset requires zero approvals. That is a useful reminder to set a non-zero approval count on every protected branch that agents can target.
Route sensitive paths to code owners
Enable Require review from code owners so that changes to authentication code, infrastructure definitions, workflow files and dependency manifests need a named owner's approval. GitHub requires code owners to have write permission, and a team code owner must be visible with write access. Assign an owner to the CODEOWNERS file itself, as GitHub recommends, so an agent cannot quietly rewrite who reviews what. Note that GitHub does not automatically request code owner reviews on draft pull requests; owners are notified when the pull request is marked ready for review. Many agents open drafts, so make "ready for review" a deliberate human step.
Dismiss stale approvals
Enable dismissal of stale approvals when new commits change the diff. Agents often iterate in response to review comments, and an approval given to the first version should not carry over to the fifth.
Keep automation out of approvals
Workflow tokens should never approve pull requests. On GitHub, check the Allow GitHub Actions to create and approve pull requests setting. GitHub's documentation states that repositories in a personal account start blocked and organisation repositories inherit the organisation setting, so review it at organisation level and leave approval disabled.
Branch rules and push restrictions
Branch rules decide where an agent can write and what must be true before its work lands.
- Give agents a branch namespace. GitHub's coding agent creates a new branch with a
copilot/prefix and can only push to that branch. For other agents, assign a prefix such asagent/and use push rulesets so their identities can only push there. - Protect default and release branches. Require a pull request before merging, restrict direct updates and require status checks. GitHub notes that a ruleset or branch protection rule can prevent its agent from creating or updating pull requests, and that administrators can configure a bypass for the agent. Grant such bypasses rarely and document each one.
- Require signed commits. GitHub's Require signed commits rule means contributors and bots can only push signed and verified commits. Be aware that unsigned commits on the head branch can block a squash merge.
- Pin status check sources. When you require a status check, set the expected source app. GitHub documents that if the status is then set by any other person or integration, merging is not allowed, which stops an agent with write access from posting a fake green check.
- Keep the bypass list short. Rulesets allow bypass by roles, teams or apps. An agent identity should never appear on a bypass list for a production branch.
CI workflows on agent branches
A pull request triggers CI, and CI often holds deployment secrets, cloud credentials and package publishing tokens. An agent that has been steered by a malicious issue or file can try to change a workflow so that it leaks those secrets on the next run.
- Hold workflows until review. GitHub states that for its coding agent, workflows are not triggered until the agent's code is reviewed and a user with write access approves them, with an optional admin setting to allow automatic runs. Keep the default. For other agents, use environment protection rules or manual approval gates on jobs that touch secrets.
- Default the workflow token to read-only. Choose the restricted setting for the workflow token and grant write scopes per job.
- Treat workflow files as code-owner paths. Any change to workflow definitions in an agent pull request should need a platform or security owner's review.
- Use federated cloud credentials. Short-lived, workload identity based credentials limit what a compromised run can take away. See our GitHub and GitHub Actions Security Guide.
What reviewers should check on agent code
Independent approval only helps if the reviewer actually reviews. Give reviewers a short, agent-specific checklist:
- Does the change do only what the task asked? Look for unrequested edits to configuration, workflows, dependency files or agent instruction files.
- Are there new dependencies, and are they real, maintained packages rather than invented or typo-squatted names?
- Are secrets, tokens or connection strings present in code, tests or fixtures?
- Do tests prove the behaviour, or were they adjusted to pass?
- Has the agent added or widened permissions, scopes or network access?
- Do the session logs show the agent reading untrusted content, such as issue comments or web pages, that could have steered it?
GitHub reminds users that logs do not replace their own review and testing. Our AI-Generated Code Review Guide expands this checklist.
A policy you can adopt
| Control | Rule |
|---|---|
| Identity | Each agent uses a platform-managed agent identity, app or dedicated machine user with a named human sponsor. |
| Scope | Agent credentials reach only the repositories in scope and expire within days, not months. |
| Branches | Agents push only to their branch prefix. Default and release branches require pull requests and signed commits. |
| Attribution | Commits are authored by the agent, credit the requesting human and link to a session or task. |
| Approval | At least one approval from a human who did not request and did not last push to the change. Code owners approve sensitive paths. |
| Automation | Agents and workflow tokens cannot approve or merge. Workflows on agent branches wait for human review. |
| Exceptions | Ruleset bypasses for agents are documented, time-limited and reviewed quarterly. |
Measuring and auditing agent pull requests
Governance is only real if you can show it working. Use labels, author identities and audit logs to report on:
- The number of agent-authored pull requests per repository and the share merged.
- Median review time and the share approved with no review comments, a rough signal of rubber-stamping.
- Any merge where the approver was the requester, which should be zero.
- Ruleset bypass events involving agent identities.
- Agent identities with access to repositories they have not used in 90 days, which are candidates for removal.
Feed these into your non-human identity reviews so that agent identities are recertified like any other service account. Our Agent Identity Recertification guide covers the review cycle.
Common failure patterns
- Agent runs on a personal token. Pushes look human, scope is too wide and revocation means breaking the developer's own access.
- Requester approves. The only human in the loop is the one who wanted the change.
- Zero required approvals. Extra-approval protections for agent pull requests have nothing to add to.
- Workflow token can approve. Automation can approve automation.
- CODEOWNERS file unowned. An agent edit to CODEOWNERS changes who reviews the next change.
- Agent on the bypass list. Added once to unblock a task and never removed.
- Workflows auto-run on agent branches. A steered agent can reach CI secrets before anyone looks.
Practitioner checklist
- Inventory every agent that can push code and record its identity, scope, sponsor and credential expiry.
- Replace personal tokens used by agents with app, platform-managed or dedicated machine identities.
- Require at least one approval and enable approval of the most recent reviewable push on all protected branches.
- Enable code owner review for workflows, infrastructure, auth code, dependency manifests and the CODEOWNERS file.
- Disable approval of pull requests by workflow tokens at organisation level.
- Restrict agent pushes to a branch prefix and require signed commits on protected branches.
- Hold CI workflows on agent pull requests until a human has reviewed the change.
- Report monthly on agent pull requests, self-approvals and agent bypass events.
Standards and references
- GitHub Docs: Risks and mitigations for the Copilot coding agent
- GitHub Docs: Available rules for rulesets
- GitHub Docs: About code owners
- GitHub Docs: Managing GitHub Actions settings for a repository
- OWASP GenAI Security Project: Top 10 for Agentic Applications for 2026
- OWASP: Non-Human Identities Top 10 2025
- OWASP: Top 10 CI/CD Security Risks
- NIST: SP 800-218 Secure Software Development Framework (SSDF) Version 1.1
Related NHI Mgmt Group resources: AI Coding Agents Security Guide · AI-Generated Code Review Guide · AI Agent Attribution and Non-Repudiation · GitHub Apps vs Personal Access Tokens vs OAuth Apps