Policy-as-code for agent actions

Security architecture — last reviewed: 2026-07-25.

Learning objectives

  • externalize action authorization from prompts and model reasoning;
  • model delegated authority with principal, action, resource, and context;
  • test, deploy, observe, and roll back agent policy safely.

The decision in one sentence

The model proposes intent; a deterministic policy decision point authorizes the exact action and an enforcement point controls execution.

Authorization path

Prompt instructions are useful behavior guidance, not a security boundary. Open Policy Agent decouples policy decisions through Rego; Cedar models principal-action-resource-context authorization with default deny and forbid-overrides-permit semantics.

flowchart TB accTitle: Agent action policy-as-code enforcement accDescr: An agent proposes a typed action; the enforcement point resolves trusted identity and context, asks a versioned policy engine, and executes only an allowed and sufficiently approved request. A["Agent proposes typed action"] --> B["Policy enforcement point"] C["Trusted principal, delegation and tenant"] --> B D["Resource attributes, risk and runtime context"] --> B B --> E["Policy decision point"] E --> F{"Allow, deny or require approval?"} F -- "Deny" --> G["Safe error and audit event"] F -- "Approve" --> H["Human or service approval"] H --> B F -- "Allow" --> I["Idempotent tool executor"] I --> J["Result, obligation evidence and audit"]
Input Trusted source Example
Principal identity provider/workload identity employee or agent instance
Delegation signed grant/session may draft but not submit
Action tool manifest case.update_address
Resource system of record case owner, region, sensitivity
Context trusted runtime time, device, amount, risk, approval
Policy reviewed repository/store version and effective date

Policy engineering

Normalize tool intents before evaluation; do not let free text become an action name or resource ID. Default deny. Scope allow rules narrowly and add explicit forbids for high-harm combinations. Return obligations such as redact fields, require step-up authentication, cap amount, log evidence, or obtain approval.

Treat policy like production code: schema/type validation, unit tests, decision tables, property tests for invariants, negative tests, historical replay, peer review, signed artifact, staged rollout, decision telemetry, and rapid rollback. Evaluate changes against real authorization traces with sensitive values minimized.

Keep policy-decision availability in the service SLO. For consequential writes, fail closed. For low-risk reads, a carefully defined cached decision may be acceptable if identity, policy version, and resource attributes remain valid. Never let the agent reinterpret a deny into another semantically equivalent tool call; enforce action families and rate/sequence constraints.

Northstar example

The Northstar agent can read policy for the user’s region and draft a case note. It may update a mailing address only with a live user session, matching case ownership, verified source evidence, and human confirmation. It can never change eligibility or payment destination. A policy change is replayed against 90 days of minimized decision logs before canary release.

Practical artifact: action-control matrix

For every tool/action record principal types, delegation, resources, conditions, forbidden combinations, obligations, approval, rate/sequence limits, fail behavior, policy tests, decision retention, owner, and review date.

Apply the matrix to production tool engineering and retain its decisions for agent incident forensics.

Check yourself

  1. Why is 'the system prompt forbids it' not an authorization control, and what is one?
  2. The policy service is down. What happens to a refund write and to a low-risk read?
  3. An agent denied 'case.update_address' retries with a semantically equivalent tool. What did the design miss?
  4. How would you release a policy change safely?
What a strong answer covers
  1. A prompt guides behaviour but is not a security boundary. A deterministic policy decision point authorizes the exact action from trusted inputs, default-deny, and an enforcement point controls execution.
  2. Consequential writes fail closed. A low-risk read may use a carefully defined cached decision only while identity, policy version, and resource attributes remain valid; policy availability belongs in the service SLO.
  3. Enforcement over action families and sequence and rate constraints. Tool intents must be normalized before evaluation, free text must never become an action name or resource ID, and the agent must not reinterpret a deny.
  4. Schema validation, unit and property tests, negative tests, review, a signed artifact, replay against minimized historical decision logs (Northstar replays 90 days), staged or canary rollout, decision telemetry, and a rapid rollback path.

Further reading

results matching ""

    No results matching ""