
When an Agent Can Act, Governance Can't Live in a PDF, It Has to Live in the Architecture
Governing autonomous agents with Cedar policy-as-code at the Amazon Bedrock AgentCore Gateway
In front of a live audience, I ask my agent to email a confidential market brief to
partner@gmail.com — an outside address. The agent wants to help. The send-email tool is right there. And the request comes back:"This action was blocked by policy."
Then I ask it to send the same brief to
aigovernance@drb-hicom.com — an internal address. It goes through.Same agent, same tool, same session. The only thing that changed was the recipient — and a rule the agent could not see, could not reach, and could not talk its way around. That rule is the whole point of this article.
Why "chatbot thinking" breaks when agents can act
A chatbot answers. An agent acts: it calls tools, sends things, changes state. The moment your agent can take real actions, a new question appears: what stops it from taking the wrong action?
The tempting answer is "I'll put the rules in the prompt." Don't email external addresses. This feels like control. It isn't. The prompt is the one part of the system a confused model — or a clever user — can influence. If the rules live in the prompt, the rules are negotiable, and anything negotiable is not a control.
Real governance needs rules that sit outside the agent's code and outside the prompt, checked on every tool call, denying by default. That's exactly what the Amazon Bedrock AgentCore Gateway + Cedar gives you.
Where the rules actually live
My demo agent writes a "Malaysia Market Brief" from public economic data. Here's its shape:

The key is the Gateway - the AgentCore component that turns APIs and Lambda functions into agent tools. Because every tool call leaves the agent and passes through the Gateway, it's the perfect place to ask one question before anything runs:
Is this specific call, with these specific arguments, allowed?
Cedar - AWS's open-source policy language answers it in ENFORCE mode: if no policy explicitly permits a call, it's denied. The prompt can beg, the model can hallucinate a justification , none of it matters, because the decision happens where the agent's text can't reach.
The agent exposes two tools:
get_dataset (reads public data from data.gov.my) and send_email (sends the brief to one recipient). Two tools is all we need to tell the whole governance story.The entire ruleset: two permits, no "forbid"
This is the complete policy , the actual files, not a simplified version.
// 1. Anyone may read public data
permit(principal,
action == AgentCore::Action::"MarketTools___get_dataset",
resource == AgentCore::Gateway::"<gateway-arn>");// 2. Email only inside the company
permit(principal,
action == AgentCore::Action::"MarketTools___send_email",
resource == AgentCore::Gateway::"<gateway-arn>")
when { context.input.recipient like "*@drb-hicom.com" };
In plain English: reading public data is always fine; sending email is fine only when the recipient ends in
@drb-hicom.com . That when { ... } clause inspects the actual argument the agent is trying to pass and permits the call only if it matches.Notice what's not here: there is no
forbid rule. I never wrote "block Gmail." In ENFORCE mode, Cedar denies by default — so partner@gmail.com isn't blocked by a rule that names it; it's blocked because no permit covers it. This is the key mental shift:You don't enumerate what's forbidden. You enumerate what's allowed, and everything else is denied for free.
A deny-list needs a rule for every bad case you can imagine and you'll never imagine them all. An allow-list needs a rule for each good case, and the unknown future is handled for you.
The three moments, and what each proves
# | What I ask | Result | Why |
|---|---|---|---|
1 | "Brief me on this month's CPI and industrial production." | ✅ ALLOWED - real figures (CPI 137.6, +1.78% YoY; IPI +4.95% YoY) | AllowRead permit |
2 | "Email it to partner@gmail.com ." | ⛔ DENIED - "blocked by policy" | no permit matches → denied by default |
3 | "Email it to aigovernance@drb-hicom.com instead." | ✅ ALLOWED -
sent | matches like "*@drb-hicom.com" |
The most convincing part is what the logs show after the block. The trace for the external request reads:
code -32002, "No policy applies to the request (denied by default)"
And the Lambda's own logs for that moment show nothing and
send_email was never invoked. The decision happened at the Gateway, upstream of the code. The agent didn't decide to behave; it was never given the chance to misbehave.Governance by design
The pattern generalizes. Almost any rule a security team would write becomes a Cedar permit:
Business rule | Cedar control |
|---|---|
"Read public data freely." | permit on the read tool, no conditions |
"Email internal staff only." | permit + when { recipient like "*@company.com" } |
"Refund up to RM500 without a human." | permit + when { context.input.amount <= 500 } |
"No destructive actions, ever." | never write a permit → denied by default |
A go-live checklist for agents that act
- [ ] Rules live outside the prompt. If user input can change a rule, it isn't a control.
- [ ] Deny by default. ENFORCE on; an unmatched call is refused.
- [ ] Allow-list, not deny-list. Enumerate the good; the unknown is denied for free.
- [ ] Check arguments, not just tool names. The recipient, the amount and the values are where the risk lives.
- [ ] Every decision is logged. Both allows and denies, traceable enough to answer "why?"
The takeaway
The leap from chatbot to agent isn't about smarter models, it's about consequences. The moment your AI can send the email or move the money, "it usually behaves" stops being good enough. The fix isn't a better prompt; it's moving the rules to where the prompt can't touch them: a short allow-list of Cedar permits, enforced at the Gateway, checked on every call, denying by default.
Two permits. No "forbid." One blocked email. That's the difference between an agent you hope is safe and one you can prove is governed.
Built with Amazon Bedrock AgentCore (Runtime + Gateway), Cedar, AWS Lambda, and open data from data.gov.my. The policies shown are the real ones from a working, deployed demo.
Enjoyed reading this content? Let the author know!
Your likes, comments, shares, and saves help creators reach more builders.
Loading recommendations
Loading article