{"id":"TIE-AGT-006","title":"Guardrails for autonomous coding agents","maturity":"reference-build","collection":"Agent identity","category":"Workforce agents","complexity":"Medium","intent":"Let coding agents write and test code freely, while identity controls stop them from pushing, merging, deploying or touching production on their own authority.","summary":"Coding agents now commit, open pull requests and trigger pipelines. Running them on a developer's credentials gives them that developer's reach into production. This pattern gives each agent its own identity, keeps production credentials out of reach, and puts human-approved gates on push, merge and deploy.","problems":["Production changes by agents","Agents using human or shared credentials","Irreversible agent actions","Secrets exposure","Software supply chain risk","Accountability for AI actions"],"standards":["OWASP Agentic Top 10 ASI02 Tool Misuse and Exploitation","OWASP Agentic Top 10 ASI05 Unexpected Code Execution","NIST SP 800-218 Secure Software Development Framework","SLSA","OpenID Connect workload identity federation"],"tags":["coding agent","AI developer","autonomous agent","pull request","branch protection","deployment approval","CI/CD","GitHub","personal access token","PAT","production database","sandbox","separation of duties"],"roles":["IAM architect","Identity engineer","Security leader","Platform engineering","AI engineering"],"industries":["Cross-industry","Financial services","Healthcare","Retail","Public sector"],"builds_on":["TIE-AGT-001","TIE-AGT-004"],"related":["TIE-AGT-003","TIE-AGT-005"],"authors":"Trevonix Innovation","reviewers":"Trevonix IAM architecture","version":"1.0","last_reviewed":"2026-11-24","published":"2026-11-24","og_image":"og-tie-agt-006.png","sections":{"summary":[{"type":"bullets","content":"Each coding agent has **its own identity**, never a developer's personal access token, SSH key or cloud session.\nThe agent works freely in a **sandbox**: its own branches, test data and non-production credentials. **Production credentials are never in its reach.**\n**Push to protected branches, merge and deploy** go through gates the agent cannot pass alone: a human review by someone other than the requester, and an approval for every deployment the agent starts."}],"problem":[{"type":"paragraph","content":"Coding agents have moved from suggesting lines to doing the work: they clone repositories, run tests, commit, open pull requests and, increasingly, trigger pipelines and call cloud APIs. Most run with whatever the developer who started them can do. That usually includes pushing to shared branches, reading secrets from the developer's environment and, through deployment tooling, reaching production.\n\nThe failure modes are public. In July 2025 a widely reported incident saw a coding agent delete a live production database during a declared code freeze, despite instructions not to make changes. The instruction was a sentence in a chat; nothing in the agent's identity or access stopped it. The same pattern appears with credentials committed to repositories, dependencies added on the agent's own judgement, and proofs of concept deployed straight to production."}],"use_when":[{"type":"bullets","content":"Developers use coding agents that can run commands, commit code or call cloud and pipeline APIs.\nAgents run unattended, for example on issues assigned to them or on a schedule.\nYour repositories and pipelines can reach production systems or customer data.\nYou must show auditors who changed production and who approved it."}],"avoid_when":[{"type":"bullets","content":"The assistant only suggests code inside an editor and the developer commits it. Normal developer controls apply.\nYou have no branch protection or deployment approval for human developers yet. Put those in place first; agents should not get a weaker path than people."}],"forces":[{"type":"bullets","content":"**Speed against control.** The value of a coding agent is that it does not wait; every gate slows it.\n**Developer identity against agent identity.** Using the developer's access is the easiest setup and makes the agent indistinguishable from the person.\n**Real environments against realistic risk.** Agents test better against real systems, which is exactly where they can do harm.\n**Platform controls against identity controls.** Repository platforms offer some protections for their own agents; agents from other vendors may get none."}],"solution":[{"type":"paragraph","content":"Treat each coding agent as a new team member with no production access on day one. It gets its own registered identity with an accountable sponsor, a sandbox with non-production credentials, and the right to create branches and pull requests. Everything that changes shared or production state, protected branches, merges, releases and deployments, passes through gates enforced by the repository, the pipeline or a gateway, each needing a human who is not the person who asked the agent to act."},{"type":"image","content":"The agent works freely in its sandbox; every step towards production passes a gate it cannot open alone.","title":"Solution overview","media":"tie-agt-006-solution.png","alt":"Diagram: a developer assigns a task to a coding agent that has its own identity and a sponsor. In its sandbox the agent can read code, create agent branches, run tests and use non-production credentials. Three gates stand between the sandbox and production. Gate 1, push to protected branch or open p"},{"type":"table","content":"Control | Where it lives | Stops\nOwn identity per agent (or agent type per team) | Identity platform, repository platform app or bot account | Agent actions logged as the developer; agent inheriting the developer's reach\nSandbox with non-production credentials | Dev environment, secrets manager | Agent reaching production data or systems while it works\nAgent branches only | Repository rules | Direct pushes to main or release branches\nRequired review by someone else | Repository rules | The requester approving their own agent's change\nRequired checks: tests, secret scanning, dependency review | CI | Leaked credentials and unreviewed dependencies\nFederated, short-lived pipeline identity | CI and cloud identity provider | Long-lived deployment keys the agent could find and use\nApproval for every agent-started deployment | Pipeline environment rules or a gateway | Unattended production releases\nKill switch | Identity platform and repository | An agent that keeps acting after something has gone wrong","title":"Controls and what each one stops"},{"type":"numbered","content":"**Register the agent** with its own identity, a sponsor and owners (see TIE-AGT-001). Revoke any personal tokens it used before.\n**Build its sandbox**: repository access limited to the repositories it works on, its own branch prefix, test data and non-production secrets.\n**Protect what matters**: protected branches, required pull request review by someone other than the requester, required status checks.\n**Separate deployment identity**: pipelines authenticate to cloud with short-lived federated credentials tied to the protected branch and environment, never with keys the agent can read.\n**Gate deployments**: every deployment the agent triggers waits for approval, with the agent's findings shown to the approver (see TIE-AGT-004).\n**Watch and stop**: log agent actions under its own identity, alert on attempts to reach production, and give the sponsor a way to disable it immediately.","title":"How to apply it"}],"design_rules":[{"type":"numbered","content":"**No personal credentials.** Agents never run on a developer's personal access token, SSH key or cloud login.\n**No production credentials in the sandbox.** If the agent can read it, assume an injection can use it.\n**Agents propose, people dispose.** Agents open pull requests; humans merge.\n**The requester does not approve.** The person who asked the agent to act cannot be the reviewer or the deployment approver.\n**Every agent-started deployment is approved.** Not only the ones that look risky; findings are shown as context to the approver.\n**Separate production data.** Development, preview and production never share a database.\n**Workflow runs on agent changes need approval** before they get access to secrets.\n**Same or stronger controls than people.** An agent never gets a path to production that a developer would not have."}],"anti_patterns":[{"type":"table","content":"Anti-pattern | What goes wrong\nAgent uses the developer's personal access token | Every push and deployment looks like the developer; the agent can reach everything they can\nCode freeze declared in the chat | The agent's instructions are not a control; nothing stops a change\nProduction secrets in the dev container | The agent, or an injection, finds and uses them\nSame database for preview and production | A test run by the agent changes live data\nAuto-merge when checks pass | Nobody reviews what the agent changed before it ships\nDeveloper approves their own agent's pull request | Separation of duties exists on paper only"}],"benefits":[{"type":"bullets","content":"Agents can work quickly and safely inside the sandbox.\nProduction changes always have a human reviewer and approver on record.\nAgent actions are attributable to the agent, its sponsor and the requester.\nA compromised or confused agent cannot reach production on its own."}],"costs":[{"type":"bullets","content":"Waiting time for reviews and deployment approvals.\nSet-up effort: agent identities, sandboxes, branch rules and federated pipeline identities.\nLicensing for agent-specific identity features and repository protections.\nDevelopers may push back on losing their own credentials in the agent; explain the incident record."}],"tests":[{"type":"table","content":"Test | Expected result\nAgent pushes directly to main | Rejected by branch protection\nAgent opens a pull request and the requester approves it | Approval does not count; merge blocked\nAgent's change includes a secret | Secret scanning blocks the merge\nAgent tries to read a production secret from its environment | Not present\nAgent triggers a deployment | Deployment waits for approval; approver sees the agent's findings\nApprover rejects | Nothing is deployed; agent and requester are told\nSponsor disables the agent | Agent can no longer authenticate to the repository or pipeline\nAudit a production change | Shows agent identity, requester, reviewer and deployment approver"}],"maturity_notes":[{"type":"paragraph","content":"**Reference build.** Trevonix has built governed coding and DevOps agents with gated push and deployment steps on Ping Identity (PingOne Advanced Identity Cloud, PingGateway and Ping's authorisation engine) and on Microsoft Entra (Entra Agent ID with approvals in Microsoft Teams), in lab tenants (November 2026). The Okta, Saviynt and GitHub recipes are written from vendor documentation and have not yet been lab-tested by Trevonix for this pattern."}],"faq":[{"type":"faq","content":"Yes, but not on their personal credentials. Give each agent its own identity, scoped to the repositories and environments it needs, with the developer as requester and a named sponsor accountable for it.","title":"Can developers still run agents on their own machines?"},{"type":"faq","content":"They help, and you should turn them on. They only cover that vendor's agent on that platform. Identity controls cover every agent you run and every system it touches, including cloud and databases.","title":"Our repository platform already protects its own coding agent. Is that enough?"},{"type":"faq","content":"Start with every deployment the agent starts. Once you have data on what the agent deploys and how often approvers reject, you can lower the bar for low-risk environments, never for production.","title":"Does every deployment really need approval?"}],"references":[{"type":"bullets","content":"[Fortune: AI coding tool wiped a database during a code freeze (July 2025)](https://fortune.com/2025/07/23/ai-coding-tool-replit-wiped-database-called-it-a-catastrophic-failure/)\n[GitHub Docs: Risks and mitigations for Copilot cloud agent](https://docs.github.com/en/copilot/concepts/agents/cloud-agent/risks-and-mitigations)\n[GitHub Docs: Configuring OpenID Connect in Azure](https://docs.github.com/en/actions/how-tos/secure-your-work/security-harden-deployments/oidc-in-azure)\n[OWASP Top 10 for Agentic Applications](https://genai.owasp.org/2025/12/09/owasp-top-10-for-agentic-applications-the-benchmark-for-agentic-security-in-the-age-of-autonomous-ai/)\n[NIST SP 800-218: Secure Software Development Framework](https://csrc.nist.gov/pubs/sp/800/218/final)\n[Microsoft Learn: Microsoft Entra Agent ID](https://learn.microsoft.com/en-us/entra/agent-id/)"}]},"recipes":{"ping":{"status":"reference-build","product_name":"PingOne Advanced Identity Cloud, PingGateway and Ping authorisation","summary":"The coding agent has its own AI agent identity; PingGateway fronts the repository and deployment APIs, and Ping's authorisation engine requires approval for pushes to shared branches and for every deployment.","last_verified":"2026-11","blocks":[{"type":"table","content":"Component | Role in this pattern\nAI agent identity (Advanced Identity Cloud) | The coding agent's own OAuth client, sponsor and owners\nPingGateway | Enforcement point in front of repository and deployment APIs the agent calls\nPing's authorisation engine | Policies for push, merge and deploy actions, returning approval obligations\nApproval service | Holds gated actions until an approver who is not the requester approves","title":"Components"},{"type":"numbered","content":"Register the coding agent under **AI Agents** in Advanced Identity Cloud with a sponsor attribute and owners (see TIE-AGT-001).\nExpose the repository and deployment APIs the agent uses only through PingGateway routes, each requiring a delegated token for the right audience.\nWrite policies that permit reads and agent-branch commits, return an approval obligation for pushes to shared branches and for every deployment, and deny direct production access.\nHave PingGateway hold gated calls and release them only after approval (see TIE-AGT-004).\nKeep production credentials in PingGateway or the pipeline, never in the agent's environment.","title":"Configure"},{"type":"bullets","content":"If the agent can reach the repository platform directly with its own token, the gateway is bypassed. Make the gateway the only network path, or use repository rules as a second line.","title":"Gotchas"}]},"okta":{"status":"documented","product_name":"Okta for AI Agents with Agent Gateway","summary":"Okta registers the coding agent and brokers short-lived, per-user access to repository tools through Agent Gateway. Written from Okta's documentation; not yet lab-tested by Trevonix for this pattern.","last_verified":"2026-11","blocks":[{"type":"table","content":"Component | Role in this pattern\nOkta for AI Agents | The coding agent's identity and owners\nAgent Gateway | Okta-secured endpoint for the MCP tools the agent uses, such as a repository MCP server\nBrokered consent (Okta STS) | Per-user, short-lived access to the repository platform instead of a stored token","title":"Components"},{"type":"numbered","content":"Register the coding agent under **Directory > AI Agents** with at least two owners.\nConnect the agent to an Agent Gateway and add the repository platform's MCP server; allow only the tools its tasks need.\nUse brokered consent so the agent uses short-lived, per-user access rather than a stored personal access token.\nKeep branch protection, review and deployment approval in the repository and pipeline as the second line.","title":"Configure"}]},"entra":{"status":"reference-build","product_name":"Microsoft Entra Agent ID with Power Automate and Microsoft Teams","summary":"The DevOps agent runs with its own Entra agent identity and non-production access; every deployment it starts waits for the accountable manager's approval in Teams, and the pipeline deploys with a separate federated identity.","last_verified":"2026-11","blocks":[{"type":"table","content":"Component | Role in this pattern\nEntra Agent ID | The DevOps or coding agent's identity, with sponsor and owners\nAgent platform (for example Microsoft Foundry) | Runs the agent with its agent identity\nPower Automate and Microsoft Teams | Deployment approval to the accountable manager, with findings as context\nWorkload identity federation | Short-lived credentials for the pipeline, separate from the agent","title":"Components"},{"type":"numbered","content":"Create the agent from a blueprint under **Entra ID > Agents**, with the accountable manager or team lead as sponsor (see TIE-AGT-001).\nGive the agent identity access to non-production resources only.\nConfigure the pipeline to authenticate to Azure with a federated credential on a separate app or managed identity, scoped to the protected branch and environment.\nRoute every deployment the agent starts through an approval flow in Power Automate that posts to the approver in Teams (see TIE-AGT-004).\nCreate a Conditional Access policy that blocks high-risk agent identities.","title":"Configure"},{"type":"bullets","content":"Do not give the agent identity rights on the production subscription so that it can 'just run the deployment'. The pipeline deploys; the agent requests.","title":"Gotchas"}]},"saviynt":{"status":"documented","product_name":"Saviynt Identity Security for AI","summary":"Saviynt discovers coding agents and their access, assigns owners and runs access reviews. Written from Saviynt's published material; not lab-tested by Trevonix.","last_verified":"2026-11","blocks":[{"type":"table","content":"Capability | Role in this pattern\nAI inventory and posture | Finds coding agents and their access, including agents running on developer machines\nOwnership and lifecycle | Assigns owners and retires agents that are no longer used\nAccess reviews | Sponsors certify each agent's repository and environment access","title":"Capabilities used"},{"type":"numbered","content":"Discover coding agents and the credentials they use; flag any using personal tokens.\nAssign owners and register each agent; set review frequency by environment.\nCertify repository and environment access quarterly and remove anything that reaches production.","title":"Configure"}]},"misc":{"status":"documented","product_name":"GitHub","summary":"GitHub rulesets, required reviews, environments and OIDC federation provide the repository and pipeline gates. Written from GitHub's documentation; not lab-tested by Trevonix for this pattern.","last_verified":"2026-11","blocks":[{"type":"table","content":"Setting | What to configure\nAgent identity | A GitHub App or machine account per agent, not a developer's personal access token\nRulesets or branch protection | Require pull requests, required reviews, and the \"most recent push must be approved\" rule on main and release branches\nRequired checks | Tests, secret scanning push protection and dependency review\nEnvironments | Production environment with required reviewers and \"prevent self-review\"\nOIDC to cloud | Deployment jobs use OpenID Connect federation, scoped to the production environment\nCopilot cloud agent | Keep the default that workflows on agent pull requests need approval before they run","title":"GitHub settings"},{"type":"bullets","content":"Copilot's cloud agent can push only to its own branch, and approvals by the person who started it do not count towards required reviews. Third-party agents get none of these defaults; apply the rules to them yourself.\nGitHub lets repository administrators allow workflows on agent pull requests to run without approval. Leave approval on: those workflows can reach secrets.","title":"Gotchas"}]}},"slug":"tie-agt-006-guardrails-for-autonomous-coding-agents","updated_at":"2026-11-24T16:55:58.454Z","url":"https://exchange.trevonix.com/patterns/tie-agt-006-guardrails-for-autonomous-coding-agents","markdown_url":"https://exchange.trevonix.com/patterns/tie-agt-006-guardrails-for-autonomous-coding-agents.md","publisher":"Trevonix","license":{"name":"CC BY 4.0","url":"https://creativecommons.org/licenses/by/4.0/"}}