Est.

Policy-as-Code Approaches for AI Agent Governance at Scale

Runtime policy enforcement at the tool call is how enterprises govern agents.

· 11 min read · Updated
Cover illustration for “Policy-as-Code Approaches for AI Agent Governance at Scale”
Security Policy · October 11, 2026 · 11 min read · 2,409 words

An enterprise AI agent with a stored API key and standing database access is not a governed system, it is a liability with good uptime. The fix that is actually shipping in production right now is policy-as-code: governance rules expressed as machine-executable logic, enforced at an MCP gateway with OAuth 2.1 authentication and tool-level RBAC, evaluated on every single tool call before it runs. That architecture, not a PDF, is what lets an enterprise say with a straight face that its agents are under control.

Policy-As-Code in Production

Enterprise AI governance does not suffer from a shortage of policy documents. It suffers from a category error: it keeps writing policies for an audience that cannot read them. AI agents do not open documents. They call tools, and they do it on a schedule that has nothing to do with whether anyone updated the compliance wiki this quarter.

Arcade's CISO governance guide lays out the three substitutes enterprises currently lean on: logging after the fact, spreadsheet tracking that drifts the moment new code ships, and policy PDFs that exist mainly to answer an auditor's question about what the company intended. None of these are governance. What none of them answers is the only question that matters at runtime: what did this agent actually do, right now, at this specific moment, with these specific credentials.

ValidMind's analysis of policy-as-code states the stakes directly: documentation cannot govern a system that acts faster than a human can review it, so execution becomes the only layer where governance actually holds. But those controls were built to govern a human logging into a system. They were not built to govern an agent that autonomously decides, mid-workflow, which five systems to reach across next.

What makes AI agents structurally ungovernable by document-based controls

Four properties of autonomous agents each break a different assumption that document-based governance quietly depends on, and none of the four is hypothetical.

Agents run continuously. An agent provisioned for one business purpose keeps exercising that access long after the purpose, the data classification, or the regulatory requirement that justified it has changed, with nobody re-checking the grant.

Agents act at machine speed. If an agent is compromised, or just misbehaving, it can exfiltrate data or trigger an irreversible action before a 24-hour audit cycle even starts. Monthly and quarterly detective controls were designed to catch violations that happen at human speed, and an agent does not wait for the auditor's calendar.

Agents lack semantic context. Left unconstrained, it can hallucinate a query against a dataset it should never have approached.

Then there's delegation, and this is the case that is hardest to wave off as an edge case. Tightening access controls on the underlying systems helps, but system-level controls don't capture an agent's reasoning path or the sequence of individually-permitted steps that, stacked together, add up to something that should never have been allowed to happen.

What policy-as-code does at the moment an agent acts

Policy-as-code moves governance from advisory to enforceable by turning rules into logic that runs automatically at the exact point an agent acts, not during a design review six weeks earlier and not in a postmortem six weeks later.

ValidMind's framing draws the line cleanly. The rule cannot be skipped, because the system itself refuses the promotion without the artifact.

Three elements separate this from documentation. Third, versioning and traceability: every rule is a tracked artifact with a clear history, so each enforcement decision maps back to the exact policy version that was live when it happened. That turns an audit from an archaeology project into a database query.

Arcade describes the resulting contract as enforcement "at the exact millisecond of every tool call," and that specificity is the whole point: it is the difference between watching and stopping. Kyndryl frames the same shift this way: you convert organizational rules, regulatory requirements, and operational controls into machine-readable code that restricts what an agent can do. Governance is no longer a quality of a document somebody filed away; it becomes a property of the running system itself.

The three-layer enforcement architecture that makes runtime governance operational

Policy-as-code works as an ongoing architecture with three layers operating at once, not as three sequential project phases, and skipping any one of them leaves a gap an agent will eventually find.

Build-time gates come first. Before anything deploys, this layer checks whether an agent has an assigned owner, a risk classification, and tool permissions scoped to least privilege. Singapore's IMDA framework, published May 2026, recommends exactly this: assess and bound risk before deployment, including narrowing an agent's action-space by limiting which tools and external systems it can reach, rather than discovering the boundary after an incident forces the question.

Deploy-time gates come next. This layer blocks any agent that hasn't been certified from ever reaching a production environment, the same way a CI/CD pipeline blocks an artifact that fails its checks. It catches the shadow agent: the agent someone spun up for a demo that nobody formally registered or reviewed, and that keeps running anyway.

Runtime enforcement is the third layer and the hardest one to get right, because it has to intercept every tool call and evaluate it against policy before execution completes, operating at the same speed the agent does, and it is the only layer that can catch the multi-agent delegation failure described above, because that failure only shows up in the live sequence of actions, not in any static review. It also has to carry two different kinds of judgment at once: deterministic boundaries that never bend, and context-sensitive evaluation for situations that require actual reasoning about what the agent is doing and why.

Build-time and deploy-time gates shrink the blast radius before an agent ever touches production, but neither can substitute for runtime enforcement, because agents run into conditions in the field that nobody enumerated at build time. In practice, the build-time and deploy-time checks are one-time costs paid once per agent, and runtime enforcement, done with the right policy engine, is automated and adds sub-millisecond latency to each call.

Choosing a policy language: deterministic rules versus AI-evaluated judgment

Production governance needs two different kinds of policy evaluation, and using the wrong one for the job yields a system too brittle to survive contact with a real agent, or one too vague to enforce anything.

Deterministic rules handle the clean majority of cases, the ones where the answer has to be binary and auditable: never execute a financial transaction above a set dollar threshold without sign-off, never let an agent touch a customer PII table outside an approved workflow. CEL, the Common Expression Language, evaluates in the nanosecond-to-microsecond range, which makes it the right fit for blocking individual commands right at the tool-call layer, where every microsecond of added latency is felt.

AI-evaluated judgment handles the questions that cannot be reduced to a boolean: is this agent's behavior still consistent with what it was built to do, is this particular request anomalous given the agent's recent history. They require reasoning about context.

The deterministic layer covers most of real-world enforcement, and the AI-evaluated layer picks up the exceptions that no finite rule set could have anticipated. A governance system built only on AI evaluation will produce judgment calls but not the tamper-evident, versioned audit trail that regulators are now asking for by name. Both modes need the same discipline applied to them: every policy change tracked, tested, and deployed with the same rigor as the agent code it is meant to constrain.

Agent identity as the prerequisite that policy enforcement depends on

None of the enforcement described above means anything if the system cannot reliably identify the actor. A policy engine can write the most precise rule in the world, but if the agent triggering it doesn't have a stable, governed identity, it can end up holding permissions nobody explicitly granted it, simply because nobody was tracking what it had access to.

The infrastructure to fix this is now shipping, not theoretical. Microsoft Entra Agent ID reached general availability in April 2026 and introduces agent identity blueprints: reusable templates that define an agent type's owners, sponsors, access boundaries, and audit behavior once, then apply that same template consistently to every instance of that agent. Microsoft rolled out two dedicated service plans, Conditional Access for Agents and ID Protection for Agents, worldwide starting July 2026, extending the same Zero Trust stack (Conditional Access, Identity Protection, Privileged Identity Management) that already governs human accounts to non-human ones.

Okta announced general availability of Agent SSO on August 24, 2026, so agents get a first-class identity instead of being treated as anonymous scripts holding a stored API key. Both of these depend on the same basic requirement: a registry, a system of record for what agents exist, who owns each one, what data it touches, and when it was created. Without that registry, shadow agents keep running indefinitely on permissions nobody remembers granting.

MCP gateways as the enforcement point where policy-as-code meets agentic tool use

Anthropic introduced the Model Context Protocol in November 2024, and it standardizes how an agent reaches the systems where enterprise data lives. Anthropic handed stewardship of the protocol to the Agentic AI Foundation, a directed fund under the Linux Foundation, in December 2025. The protocol's own 2026 roadmap names its gaps outright: audit trails, enterprise-managed authentication, and gateway and proxy patterns. The MCP gateway category exists specifically to close those gaps, which is also what makes it the natural enforcement point for policy-as-code. It sits between every agent and every tool call. Governance can intercept the full surface of agent activity there without having to instrument each downstream system one at a time. Without a gateway, every MCP server needs its own credentials and configuration, and you have to copy-paste policy-as-code rules across every one of them, which is neither consistent nor auditable at any scale that matters.

A governed MCP gateway centralizes authentication and identity verification, tool access filtering by role or team, audit logging of every tool call, rate and cost controls, and real-time policy evaluation before a tool is ever allowed to run. The vendor field here is active, and each option earns its place on its own merits.

Bifrost, from Maxim AI, is open-source under Apache 2.0, written in Go, and unifies LLM routing with MCP tool governance in a single gateway.

Lunar.dev's MCPX ships an open-source tier with Tool Groups and local and remote MCP server authentication, while the Enterprise tier adds identity provider integration with Okta and Entra ID, automated risk scoring of MCP servers, and hosted deployment.

Kong AI Gateway built an MCP Registry into Konnect, announced February 2026, that catalogs and versions MCP servers alongside the APIs behind them, with ownership and policy inheritance built in. Its sharpest design choice is hiding unauthorized tools at discovery time instead of only blocking them at execution: a compromised agent can't reach a tool it never even sees listed, which shrinks the space the agent can reason about.

Cloudflare AI Gateway, paired with MCP Server Portals, targets enterprises already running on Cloudflare's edge network and uses protocol-level heuristics, hostname and URL selectors, and content-inspection rules to detect shadow MCP servers running unsanctioned on the network. IBM's ContextForge is open-source, Kubernetes-ready, and deployable through Docker or PyPI, with federation built in from the start: multiple gateway instances share a shared in-memory-store-backed registry, support auto-discovery via mDNS and DNS-SD, and operate as one unified system across regions, while also bridging legacy REST and gRPC services into MCP without rewriting them.

Speakeasy takes a broader scope. It places a governed layer between agents and MCP servers, enforcing RBAC and identity through existing providers like Okta and Entra ID, detecting shadow AI and prompt injection as they happen, and surfacing cost and usage telemetry across the organization, which addresses the full governance surface rather than treating each MCP server connection as its own isolated problem. A crowded field of credible, differently-scoped gateways is itself a signal: enterprise MCP governance has moved past the experimental stage and into infrastructure enterprises are expected to have in place.

Regulatory frameworks that are turning policy-as-code from best practice into compliance requirement

Regulators have stopped issuing principles; now they issue requirements that only enforcement logic, not documentation, can satisfy.

The EU AI Act requires high-risk AI systems to carry documented risk management, automatic logging, human oversight mechanisms, and technical documentation. What satisfies that question is a versioned, timestamped audit trail, which policy-as-code produces and a document sitting in a shared drive cannot.

NIST's AI Risk Management Framework has become the default US enterprise baseline, and its four functions, Govern, Map, Measure, Manage, map onto a policy-as-code implementation almost directly. The NIST AI 600-1 Generative AI Profile adds twelve specific risk areas on top of that, including information security and data privacy. ISO/IEC 42001:2023 is the international standard for AI management systems, and it is certifiable, which is the sharpest point in the whole regulatory picture: certification means an outside auditor has to verify the claim, and an auditor verifying an enforcement claim needs machine-generated evidence, not a human's word that the policy was followed. The OWASP Agentic AI Top 10 documents concrete attack patterns, prompt injection, excessive agency, unbounded costs, that line up directly with the runtime gaps policy-as-code closes. Compliance timelines have a reputation for slipping, but the EU AI Act's enforcement is already live in 2026, and regulated sectors like banking and healthcare carry sector-specific requirements with fine structures attached that are not available to defer.

What a working policy-as-code governance program looks like

A governance program that is actually working has four properties showing up at once: every agent action gets evaluated against policy before it runs, every one of those evaluations leaves an immutable record, policy changes move through version control like any other code change, and the whole governance layer is invisible to an agent that stays in bounds and impassable to one that doesn't.

Actions above a defined autonomy threshold route automatically to a human approval workflow, with the agent paused and awaiting review, which is what Singapore's IMDA framework describes when it talks about bounding an agent's action-space before deployment: the same boundary, enforced at runtime.

The organizations that get this right earliest are the ones that build the governance layer as shared infrastructure from the start, before the agents are already running in production and the retrofit becomes somebody's unpleasant weekend project.

Sources

  1. GitHub - systempromptio/awesome-ai-agent-governance: The curated list of tools, standards, and resources for governing AI agents in production: policy enforcement, audit trails, EU AI Act compliance, MCP and Claude Code security. · GitHub
Filed underSecurity Policy

More in Security Policy