AI can reason. PromptFence decides. - What we learned building a permission layer for AI agents in four days
Our AI agent wanted to refund ₹42,000. Cedar said a human decides. Then it tried forty legal refunds of ₹9,000 - and got caught anyway. How two students built a session-aware authorization gate on Lambda, Cedar and DynamoDB at First Commit, and everything that fought back.
Two years ago, AI answered questions. Now it takes actions. A support agent at an online store can process your refund without a human touching it. That's the problem we spent four days on at First Commit, the opening event of the WeMakeDevs × AWS Bharat Builds Tour.
We are Mehrak Codes - two third-year B.Tech students from Jaipur. One of us wrote the policy engine and the agent. The other built the interface and the demo. This is what we built, what it's made of, and what fought back.
The problem
Giving an AI agent a tool is not the same as deciding when it's allowed to use it.
Picture a customer-support agent with a refund tool and a rule: up to ₹10,000 on your own, anything more needs a manager. Today, that rule lives in the prompt. The model reads it, and you hope. But a model can be persuaded, confused, or simply wrong - and the moment it is, the money's gone, because nothing stood between the model's decision and the actual refund.
An IAM role can answer "is this workload allowed to invoke this Lambda?" It cannot answer "is this specific agent, in this session, allowed to call
refund_order for ₹42,000 right now?" Understanding a request is not the same as having permission to fulfil it. That gap is what PromptFence closes.What PromptFence is
A gate. The agent may request an action; the request passes through PromptFence before it reaches any tool. PromptFence checks it against written Cedar policies and returns one of three answers: ALLOW, DENY, or APPROVAL (a human decides). The rules aren't in the model's head. They're in a separate system the model cannot argue with.
Tagline: AI can reason. PromptFence decides.
The demo - and the part nobody expects
Ask our agent to refund ₹42,000. It understands, wants to help, and calls the refund tool. The tool asks PromptFence first. Cedar checks the per-call limit. APPROVAL - held for a human. The tool never runs. That's the expected block, and lots of teams could build it.
Now the part we're proud of. The agent issues forty separate refunds of ₹9,000. Every single one is under the ₹10,000 limit. Every one is individually, provably legal. A per-call check says ALLOW forty times.
Total: ₹3,60,000. No alarm.
This happens because per-call authorization has no memory. It evaluates each request as if it's the first. PromptFence keeps a ledger of what the agent has already done this session, and the policy reasons about the running total:
// cumulative-refund-ceiling-v1forbid(principal, action == Action::"refund", resource)when { principal.role == "support" && context.session_total + context.amount > 355000 };Request #39 lands the session at ₹3,51,000 - allowed. Request #40 would reach ₹3,60,000. DENY. On the dashboard, thirty-nine green rows, then one red one.
Legal individually. Dangerous together.
The stack, and what each piece is for
We tried to have no decorative services. Every one here has a job you can see in the demo.
Service | Its job |
|---|---|
Amazon Bedrock (Nova Lite) | The model behind the support agent |
Strands Agents SDK | The agent loop and tool-calling; the refund tool is wrapped so it must ask PromptFence first |
Cedar (via cedarpy ) | Makes the actual allow/deny decision. Never faked |
AWS Lambda | Two functions: the authorizer and the agent, sharing one policy bundle |
Amazon API Gateway | /v1/authorize , /v1/sessions/{id} , /v1/attack-run , /v1/agent/chat |
Amazon DynamoDB | Policies, decisions, and the session ledger — the memory per-call checks don't have |
Amazon EventBridge | One event per decision: requested, allowed, held, denied |
AWS Amplify Hosting | The Control Room dashboard and landing page, static export from Next.js |
The whole thing deploys with one
sam deploy .What fought back
This is the honest section.
Prior art we didn't know existed. Two days before kickoff we discovered AWS had shipped almost exactly our idea: AgentCore Policy, GA in March 2026, Cedar-based authorization for agent tool calls. We nearly dropped the project. Then we read closer - it evaluates one call at a time at the Gateway boundary, and AWS's own Dogwood work (open-sourced a month ago) is aimed at the sequence problem we'd stumbled into. So we repositioned: AWS solves point-in-time. We work one level up, on sequences, with a ledger, a human-approval path, and an operator's view. Naming your competitor before a judge does turned out to be the most important sentence in our pitch.
Cedar only knows permit and forbid. Our third answer, APPROVAL, doesn't exist in Cedar. We solved it with an
@decision("APPROVAL") annotation on the hold policy; the handler maps a permit whose determining policy carries that annotation to APPROVAL. Forbid still beats everything, which is exactly the semantics you want.Integer overflow as a policy bypass. An absurdly large
amount could overflow Cedar's arithmetic in the ceiling check. Cedar then skips the forbid with an error - and the request falls through to APPROVAL. A permission gate that fails open under a malformed input is worse than no gate. We cap amounts before Cedar ever sees them, and any Cedar evaluation error is a DENY.Two requests racing under the ceiling. A plain DynamoDB
ADD can't stop two parallel requests from both reading ₹3,46,000 and both passing. The session update and the decision write now happen in one transaction, conditioned on the sequence number not having moved; on conflict, we re-read and re-evaluate with Cedar. Up to five times, then 503.The database failing must not reset the ceiling. Our first version quietly treated an unreachable table as
session_total = 0 . That's a fail-open. Now a DynamoDB error is a 503 - the tool doesn't run.Lambda's 250 MB limit.
strands-agents plus cedarpy unzips to 113 MB. Adding strands-agents-tools took it to 261 MB. We define our own tools, so it went.The model leaked its thoughts. Nova's replies arrived with
<thinking> blocks intact, straight into the customer-facing text. Stripped, tested, and a line added to the system prompt.Amplify and monorepos. Two failed deploys before the first success: one because a monorepo needs an
applications: block in amplify.yml , one because Amplify assumed our static Next.js export was SSR. aws amplify update-app --platform WEB fixed the second.Our own design. We designed the dashboard twice. The first version was all mono, all caps, and it looked like a developer tool from a film. It was hard to read. Sentence case, a readable sans, and mono only for values fixed it. The prize is for a thing that's a pleasure to use.
What's not built
Authentication (the dashboard runs on a fixed demo session), audit search, an SDK, multi-region, multi-tenant. Bearer API keys exist in the table but aren't enforced on the routes yet. The Step Functions approval hold is designed, not shipped. We'd rather say that here than have you find it.
What we learned
Per-call authorization was the easy part. Every real design decision lived in the ledger: what counts toward the total, what happens on conflict, what happens when the store is down. And the most important call in the whole system is the one it doesn't make.
Try it
- Live: Control Room - click Replay attack simulation, or ask the agent for a refund yourself.
- Code: github.com/Anumehajain78/promptfence - MIT,
sam deployand it's yours.
- Demo video: https://www.youtube.com/watch?v=UOR5\_vs2WZM
Built by Anumeha Jain and Rakshit Gang at First Commit, 17–20 September 2026. Tools we used and want to credit: Claude Code and Claude Design.
Enjoyed reading this content? Let the author know!
Your likes, comments, shares, and saves help creators reach more builders.
Loading recommendations
Loading article