code review screen

Photo by Jakub Zerdzicki on Pexels

Teams that write an AI agent authorization policy often choose between Cedar and Rego for Open Policy Agent (OPA). Cedar is a deliberately small language that its authors can analyze and prove things about. Rego has a large built-in function library and years of production use. Both can stop an agent from deleting a production bucket. For the harder checks that agents force, Rego is the more capable choice. This post explains why, where Cedar is the better tool, and what to check before you choose.

How do Cedar and Rego differ?

Cedar is an authorization language. A request has four parts: a principal, an action, a resource and a context. The engine evaluates the request against a policy set and the entity data that the host application supplies. Cedar has no general loops or recursion, and it has no I/O: a decision cannot call an external service. Every policy terminates, and the language has a formal model in Lean. That narrowness is the point. It makes Cedar fast, and it makes policies analyzable.

Rego is a general policy language for a decision engine. Rules build sets and objects, comprehensions and the some and every keywords iterate over collections, and user-defined functions let a team reuse logic. A policy can refer to any data loaded into OPA, not only to the request. That breadth is why OPA was widely used for Kubernetes admission control (Gatekeeper), infrastructure guardrails and service authorization (the Envoy plugin) before agents arrived.

What does an AI agent authorization policy need to express?

An AI agent authorization policy decides whether an agent may take an action before the action runs. Its inputs are wider than those of a user-facing permission check:

  • The agent’s identity, and the token that proves it.
  • The person or service the agent acts for, and the chain of delegation between them.
  • The tool, the operation and the arguments. Arguments often arrive as a JSON string or a shell command.
  • The target system and the class of data it holds.
  • The time: a change freeze, business hours in a named time zone.
  • What the agent did earlier in the session.

A policy language for this work must handle all of these, either in the policy or in the code that prepares the request. Whatever the policy cannot express moves into that code. See least-privilege agent permissions for how an agent’s scope is defined.

Where does Cedar earn its place?

Cedar has real strengths:

  • A small set of constructs, which makes review and sign-off easier for risk and audit teams.
  • No I/O and guaranteed termination, with a formal model in Lean and a validator that is proved correct.
  • Schema validation, which catches unknown actions, unknown attributes and type mismatches when policies are written or loaded.
  • Analysis tools: the Cedar symbolic compiler can prove that a policy never errors, or that two policy sets are equivalent, and gives a counterexample when a check fails.
  • Speed: in its authors’ own benchmarks, Cedar was 42.8 to 80.8 times faster than Rego (Cedar paper).

Cedar has been a CNCF Sandbox project since October 2025. AWS uses it in Amazon Verified Permissions, generally available since June 2023, and in Amazon Bedrock AgentCore Policy.

In August 2026, AWS released Dogwood, an open-source language that extends Cedar with temporal conditions. A Dogwood policy can require an earlier approval, require one action before another, and limit a count or a running total within a time window. AgentCore Policy runs these as temporal policies and records each session’s events itself. There are quotas: 20 temporal policies per policy engine, three temporal operators per policy and a 24-hour maximum window per temporal condition. History is scoped to a session whose ID the caller supplies, so a count limit starts again when a new session starts. AWS also notes that temporal conditions do not get Cedar’s automated analysis (InfoQ). These are the conditions that agents need. They are also new. AgentCore Policy runs them as a managed service, and the open-source Dogwood project also provides a Rust library and a CLI.

Why does Rego’s built-in function library matter for agents?

Rego has a much larger built-in function library than Cedar. The OPA 1.23 reference groups its built-ins into 29 categories. The documentation gives no total; we count about 175 named built-in functions. They cover string, regex and glob matching, CIDR math, time with named time zones, semantic versions, JSON and YAML parsing, JWT verification, graph reachability and HTTP calls.

Cedar has a small, fixed set of operators. For strings, it has only like, with * as the single wildcard. It has no regex, no JSON parsing, no JWT verification, no semantic-version type and no network access. Its datetime type accepts fixed UTC offsets, not named time zones, and Cedar has no clock, so the caller must supply the current time. AgentCore Policy, for example, adds it to every request. Cedar has no user-defined functions. It does have a transitive in for entity hierarchies, and an ip() type with isInRange for CIDR checks.

This difference decides where each check runs:

Check on an agent action Rego built-in Cedar approach
Tool name matches a pattern, such as any delete_* tool glob.match like, one clause per pattern; * also matches dots
Command arguments contain rm -rf or rm -fr regex.match No regex; the caller classifies the command
Tool arguments sent as a JSON string json.unmarshal The caller parses them into a typed context record
Agent identity token is valid io.jwt.decode_verify The application or gateway verifies the token and sends the claims
Egress target is in a blocked range kept as data net.cidr_contains ip().isInRange with ranges written into the policy
Business hours in a named time zone time.weekday, time.clock The caller sends the time and the weekday
Agent is in the user’s delegation chain graph.reachable in, if delegation is modeled as entity parents
MCP server is at least a pinned version semver.compare No version type; the caller sends a precomputed value

Three of these as Rego (OPA 1.x syntax):

destructive_tool if glob.match("{*.,}{delete,drop,purge}_*", ["."], input.tool.name)

agent_claims := claims if {
	[valid, _, claims] := io.jwt.decode_verify(input.agent_token, {
		"cert": json.marshal(data.idp.jwks),
		"iss": "https://idp.example.com",
		"aud": "mcp-gateway",
		"time": input.now_ns,
	})
	valid
}

delegated if input.agent in graph.reachable(data.delegations, {input.user})

The first rule matches delete_repo and github.delete_repo. The second checks the token’s expiry against the time in the input, not the server clock. With Cedar, the gateway or the application must do these steps and pass the results as entity attributes or context. The Cedar policy is shorter, but part of the security logic moves into application code, which needs its own review and tests.

The Cedar team keeps the language small on purpose. Each new function needs updates to the Lean models, the proofs and the analyzer. The datetime RFC explains why Cedar has no clock and no time zones: a current-time function is not pure, and time zones would harm the analysis. Rego’s breadth has a cost too. OPA’s capabilities file marks 11 built-ins as non-deterministic, including http.send, time.now_ns and io.jwt.decode_verify, which reads the clock. To keep decisions reproducible, pass the current time in the input, and keep the record of non-deterministic results that decision logs can store.

Can a policy see more than one action?

Agents do not make single requests. They plan, call a tool, read the result and call another tool. Neither OPA nor plain Cedar records what an agent has done. With OPA, the history arrives as input, as loaded data, or through http.send. With plain Cedar, the caller must reduce that history to context or entity attributes before each request. Dogwood is the exception: AgentCore Policy records the session’s events and evaluates temporal conditions over them, within the quotas above.

The difference is what the language can do with the history once it has it. An enforcement layer usually keeps the record of an agent’s actions and passes it to the policy. Rego can then count, filter and join over that list. These two rules limit refunds per hour and enforce a Segregation of Duties rule across actions: no payment release after the same session changed the vendor’s bank details.

refunds_last_hour := count([a |
	some a in input.history
	a.tool == "issue_refund"
	a.time_ns > input.now_ns - 3600000000000
])

deny contains "refund limit: 3 per hour" if {
	input.action.tool == "issue_refund"
	refunds_last_hour >= 3
}

deny contains "same session changed this vendor's bank details" if {
	input.action.tool == "release_payment"
	some a in input.history
	a.tool == "update_vendor_bank"
	a.args.vendor_id == input.action.args.vendor_id
}

In plain Cedar, the caller would compute “refunds in the last hour” and “bank details changed for this vendor” before each request, so those rules would live in application code.

Can Rego call external APIs during a decision?

Yes. The http.send built-in makes HTTP requests while a policy is evaluated. Responses are cached for the rest of the query, and OPA’s documentation says http.send must not be used to change external systems. A decision that depends on a live call depends on the network for its latency and availability, as the external data guide notes. Operators can block the built-in, or limit the hosts it can reach with allow_net in the capabilities file. Most production deployments load data in advance through bundles or the request input. Cedar has no I/O, so this choice does not exist there.

How do you test an AI agent authorization policy?

Untested policy fails without notice when the code around it changes. OPA’s opa test runs test rules that sit next to the policy, supports parameterized, data-driven tests, mocks input, data and functions with the with keyword, and reports coverage. The tests run in the same pipeline as application code. We tested the rules in this post with opa test on OPA 1.16.2. The Cedar CLI has a run-tests command that runs JSON request cases against a policy set. Cedar’s larger strength is analysis: the symbolic compiler can prove properties that tests can only sample.

Why does track record matter for agent security?

OPA has been a CNCF Graduated project since January 2021. It has years of operating practice around bundle distribution, decision logging, Gatekeeper and Envoy, and a known set of failure modes. Cedar’s use in agent governance is newer: AgentCore Policy reached general availability in March 2026. When the system being governed can move money, change identity or delete data, failure modes that nobody has met yet are a cost. Regulated enterprises should weigh that cost explicitly.

What do coding-agent advisories show about where policy belongs?

Published advisories show what a coding agent can be made to trust. A malicious repository could turn off Claude Code’s workspace trust prompt through its committed settings (GHSA-mmgp-wc2j-qcv7, fixed in 2.1.53). Check Point Research showed MCP servers starting before the user could read the trust dialog, and hooks running after a generic trust prompt that did not mention them. On Windows, Claude Desktop ran a git.exe planted in a project folder as soon as the folder was opened (GHSA-4p2j-qj3c-6x84, fixed in Claude Desktop 1.8089.0). And GMO Flatt Security showed that one GitHub issue, posted through a GitHub App, could make Anthropic’s Claude Code GitHub Action leak OIDC credentials that an attacker could exchange for a token with write access to the repository. It was fixed in v1.0.94.

Several of these flaws ran code before any tool call reached a policy check. Patching, sandboxing and managed settings stop that class of flaw. A policy engine on the tool-call path covers what happens after that: which tools run, with which arguments, in which order.

Anthropic’s enterprise guide to securing coding agents uses two layers of controls: judgment-based checks such as its auto mode classifier, and fixed controls such as permission rules, hooks, sandboxing and egress allowlists. Its engineering post How we contain Claude treats the deterministic boundary as the layer that still holds when probabilistic checks miss. A runtime enforcement layer belongs in that fixed layer, outside the agent, as we argued in The controls have to sit outside the agent. Its policy language must be able to express the checks in the sections above.

policy documents

Photo by Pixabay on Pexels

How do Cedar and Rego compare on the decisions agents trigger?

Decision Cedar Rego
Single request against supplied entity data Strong fit, minimal ceremony Works, slightly more structure to write
Tool-name patterns, regex, JSON arguments like only; the application parses and classifies Built-ins in the policy
Agent token verification The application or gateway verifies the token io.jwt.decode_verify
Business hours and named time zones Fixed offsets; the caller supplies the time and weekday Time built-ins with named zones
Approvals, ordering and running limits Plain Cedar: the caller precomputes history. Dogwood on AgentCore Policy: the engine records session history Rules over history that the caller or a data feed supplies
External calls during a decision None (no I/O) http.send, which operators can restrict
Formal analysis Symbolic compiler, proofs in Lean (not for Dogwood temporal conditions) No equivalent in OPA’s documentation
Speed Faster in its authors’ benchmarks Slower in those benchmarks
Policy testing CLI run-tests with JSON request cases opa test, mocking, coverage
Production history Amazon Verified Permissions GA since June 2023; CNCF Sandbox since October 2025; AgentCore Policy GA March 2026 CNCF Graduated since 2021; Gatekeeper, Envoy

How do you choose a language for AI agent authorization policy?

Choose Rego when the policy must parse arguments, verify tokens, match patterns, work in named time zones, join several data sources, or reason over the actions an agent has already taken. That covers most production agent deployments, including coding agents with shell access, and it lets one policy cover agents on many platforms. Choose Cedar when the decision really is a single authorization check, the host application already holds clean entity data, and the team values formal analysis, speed and a small reviewable policy over expressiveness. If your agents run on Amazon Bedrock AgentCore and need conditions over the session’s earlier actions, Dogwood temporal policies are worth a close look.

It is also legitimate to run both. Cedar can handle narrow request-time authorization inside an application, while Rego handles the cross-system decisions that determine whether an agent action proceeds at all. Both layers must receive the same authoritative context about the agent’s identity, owner and permissions.

Do not assume that the smaller language is automatically the safer one. A language that cannot express a condition does not enforce it. The condition moves into application code, where it is harder to test, harder to review and easier to bypass. That is the case for a deterministic control plane between agents and the systems they reach, with policies written in a language that can express how agents behave. On the evidence available today, that language is Rego. Cedar is a strong tool for the problem it was designed to solve.