learning-it by example

#234 Enterprise architecture and AI agents 5.6 min

Authorisation for AI Agents With Policy as Code (Cedar)

I changed one line of policy text, and a fifty pound refund was denied, with the checking code unchanged.

1. Why does the video say the decision about a tool call should be made by a policy rather than by the model?
2. In Cedar, what happens to a request that no policy permits, and what does a forbid do against a permit?
3. Under the policy as written, how many of the ten proposed tool calls were allowed, and which ones?
4. The video changes one line of the policy text and runs the same ten calls again. What changed?
5. What does the video say Cedar does not check?

Practice only: nothing is saved and no score counts towards anything. Each answer comes with the reason.

  1. Read the policy file

    Copy the code folder first. Open policy.cedar and, without running anything, write down in one sentence each what the first permit allows, what the second permit allows, and what the forbid stops. Then use them to explain why the call from rogue-agent in compare.py is denied.

    A hint

    Both permits start with principal == Agent::"support-agent", and anything not permitted is denied.

  2. Raise the refund limit

    In policy.cedar, change 100 to 200 in the refund permit. This needs cedarpy 4.12.1 from requirements.txt. Predict which of the ten calls changes, and how many are allowed in total, then run python compare.py. The run prints the whole table for the policy as written. The second block will list no changes, because the script looks for the text <= 100 and no longer finds it.

    A hint

    Only the refund of 150 pounds on A-1 sits between the old limit and the new one.

  3. Ben reads his own order

    In compare.py, change the second call from ("support-agent", "read_order", "B-1", "ana", 0) to use "ben" as the user. Order B-1 belongs to ben in gate.py. Predict the answer for that line and the total allowed, then run python compare.py.

    A hint

    The read permit allows the call when the order owner equals the user in the context.

  4. Try to permit the export

    Add a third permit to policy.cedar that lets support-agent do Action::"export_all" on any resource, copying the shape of the read permit but without a when clause. Predict what happens to the export call, given what the video says about forbid and permit, then run python compare.py to see whether your prediction holds.

    A hint

    The video says a forbid always beats a permit, but its own run did not show this. This task tests it.

These tasks are for you to try on your own machine. Nothing is checked or saved.

What this does not show

One made-up agent, three orders and ten calls I chose. No agent, model or tool runs, and nothing is blocked. No schema. The run does not show a forbid beating a permit. The user and the amount are taken on trust; a refund of minus 500 is allowed. Results are for cedarpy 4.12.1.

Up next in Enterprise architecture and AI agents

More in Enterprise architecture and AI agents

All Enterprise architecture and AI agents videos

Related videos