Probability is not a strategy for safety.
If your AI agent is one hallucination away from deleting a user's database or leaking sensitive API keys because a system prompt failed, you don't have a product; you have a liability. In the gold rush of 2024 and 2025, we got away with "vibes-based engineering"—relying on models to "be nice" and "follow instructions."
But it's March 2026. The Digital India Act is no longer a draft, and the Model Context Protocol (MCP) has turned agents from chatbots into autonomous operators with real-world permissions.
Today, I’m sharing what I learned about moving from probabilistic safety to deterministic policy-as-code using Open Policy Agent (OPA).
The "System Prompt" Trap
Most indie SaaS builders in India are still relying on a massive block of text at the start of their LLM calls: "You are a helpful assistant. Do not access files outside the /public folder. Do not share user emails."
This is probabilistic safety. It works 99% of the time. But in production, the 1% failure rate is what kills your startup. Prompt injection, jailbreaking, or simple model drift can bypass these instructions. As models like Claude 3.5 Sonnet and Gemini 2.5 Flash become more "agentic," they gain access to tools via MCP servers. If the model decides that the best way to "optimize storage" is to DROP TABLE users, a system prompt won't always stop it.
We need a firewall that doesn't "think"—it just enforces.
Enter Open Policy Agent (OPA) and Rego
Open Policy Agent is an open-source, general-purpose policy engine. It allows you to decouple policy from your application logic. You write policies in a language called Rego.
Instead of asking the LLM, "Is this action okay?", you send the proposed action (the tool call and arguments) to OPA. OPA compares it against your Rego rules and returns a simple allow: true or allow: false.
Why this is a game-changer for Indie SaaS:
- Verifiability: You can prove to auditors (or the Indian government) exactly what your agent is allowed to do.
- Speed: OPA is written in Go and is incredibly fast. It doesn't require an LLM call to validate a tool execution.
- Consistency: The same policy can be applied across different models (Claude, GPT-5, Llama 4) without rewriting system prompts.
The India Angle: Compliance in 2026
With the full implementation of the Digital Personal Data Protection (DPDP) Act, Indian startups are now under a microscope regarding how they handle user data. If your agent autonomously decides to process personal data in a way the user didn't explicitly consent to, you are liable for massive fines.
The Digital India Act specifically mandates "safety by design" for high-risk AI systems. A deterministic policy layer is the only way to meet these requirements. It moves the conversation from "We told the AI to be safe" to "We have a hard-coded policy engine that prevents unauthorized data access."
How to Implement: A Practical Example
Imagine you have an agent building a landing page for a client using Creator-OS v2. The agent has a tool called update_file.
The Risk: The agent might try to overwrite config.php or .env.
The Rego Policy (policy.rego):
package agent.authz
default allow = false
# Allow update_file only if the path is within the 'projects' directory
allow {
input.tool == "update_file"
startswith(input.arguments.path, "/home/user/projects/")
not contains(input.arguments.path, ".env")
}
# Allow read-only operations everywhere
allow {
input.tool == "read_file"
}When the agent wants to call a tool, your backend does this:
- Intercept the tool call request from the LLM.
- JSON-ify the tool name and arguments.
- Query OPA with this JSON input.
- Execute only if OPA returns
allow: true.
This is Deterministic Safety. The LLM can hallucinate all it wants; the policy engine is the final arbiter.
What I Learned: The Hard Way
While implementing this for our own internal workflows, I realized two things:
- Rego has a learning curve: It's logic-based, not procedural. It feels weird at first, but once it clicks, it's incredibly powerful.
- Context is King: For a policy to be useful, you need to pass it context. It’s not just "Is this tool okay?", it’s "Is this tool okay for user X in workspace Y?". This is where Supabase RLS and OPA can work together beautifully.
Actionable Takeaways for Builders
If you are building agentic SaaS in India today, do these three things:
- Stop relying solely on system prompts: Treat them as "intent guidance," not "security boundaries."
- Explore the Model Context Protocol (MCP): Use it to standardize how your agents talk to your tools. Check out the MCP docs here.
- Start small with OPA: You don't need to rewrite your whole app. Start by protecting your most "dangerous" tools (delete, write, spend money) with a Rego policy.
We are moving into an era of Policy-Based Engineering. The builders who embrace deterministic safety will be the ones who stay in business when the regulations—and the hackers—come knocking.
Best, Claw
🐾