Contextual policies are reshaping how we think about security for AI agents.
For a long time, agent frameworks operated on simple logic: allow, deny, or ask the user. But as these agents become more autonomous — executing complex tasks, accessing files, sending emails, making API calls, and burning through credits on language models — that basic model starts to show its cracks. The problem isn’t just technical. It’s behavioral. When a system asks for approval on every single action, the user goes on autopilot and starts approving everything without thinking. At that point, any safeguard becomes decoration.
This is exactly where Databricks comes in with a different approach. Omnigent is an open source meta-harness for AI agents that adds an intelligent layer on top of the frameworks you already use, like Claude Code, Codex, and custom agents. The idea is to let you keep using the tools you like while gaining a shared layer for collaboration, composition, and policies. The big news is contextual policies: instead of just reacting to an isolated action, the system can remember what the agent did throughout the entire session — like what it read or how much it has spent in dollars — and use that history to decide what can or cannot happen next. It sounds simple, but it changes a lot in practice.
Picture a coding agent that just pushed to GitHub. Is that safe? It depends. If it spent the entire session working on a feature for an engineer, probably yes. But if before that it downloaded an untrusted web page that could contain an injection attack, the same push becomes a real risk. With static rules, you can’t make that distinction. With contextual policies, you can. In the sections ahead, we’ll break down how this works in practice, which use cases come built into Omnigent, and why this approach represents a real step forward in risk management for AI agents. 🚀
Why controlling agents gets better with context
The core idea behind contextual policies is fairly straightforward: an action shouldn’t be evaluated in isolation but within the context in which it happens. AI agents introduce new types of risk for businesses. One of the most concerning is prompt injection, where untrusted content manages to manipulate the agent into performing harmful actions. That’s why it’s desirable to prevent the same agent from reading untrusted content, accessing sensitive data, and communicating with the outside world all at the same time. This concept gained traction through what’s known as the Lethal Trifecta, coined by Simon Willison, and the Agents Rule of Two from Meta.
If an AI agent is about to send an email, the question isn’t just whether it has permission to send emails. The real question is: what did this agent do before getting here? Did it access sensitive files? Visit external URLs? Receive instructions from an unverified source? That collection of information is what transforms a binary decision into a smart one, capable of reflecting the actual risk of each situation within the running session.
The problem is that most agent software today only offers simple allowlist controls or guardrails on individual actions — like allowing or blocking Git pushes or web searches. To prevent injection attacks, you’d have to block at least one of those actions entirely, which would be way too restrictive for many harmless use cases. Asking for user approval on every action doesn’t work well either, because people get exhausted by constant prompts and end up clicking approve on autopilot.
And this applies to plenty of other scenarios. It might be perfectly normal for a salesperson’s agent to send an email to a client, but sending thousands of emails already signals an intrusion or a bug. An agent editing a document it created itself is fine, but the same agent editing thousands of internal documents deserves attention. In fact, many security tools designed for human users already consider history rather than just the current action — something known as contextual security.
How Omnigent puts all of this into practice
In Omnigent, a policy can listen to events an agent executes — like tool calls, responses, and inputs and outputs to the LLM — and decide whether to allow, deny, transform the messages, or ask for user permission, just like traditional guardrails. The big difference is that the policy can also update the session state, meaning arbitrary variables visible only to that policy. This includes tracking how many times the agent used a specific tool, which documents it read, and so on.
The Omnigent server stores this state for each policy and each session, then passes it back to the policy handler the next time it gets called. To write a contextual policy, you simply create a function that receives the old state and the new event the agent is trying to execute, and returns the state updates plus the decision. And the best part: Omnigent already ships with several useful policies ready to go.
Since Omnigent is a meta-harness, it applies its contextual policies to agents from any harness in the same way. It supports widely used coding agents like Claude Code, Codex, Antigravity, Pi, OpenCode, and Hermes, along with custom agents built on frameworks like OpenAI Agents SDK and Claude Agents SDK. Just launch your agents through Omnigent, and the server will intercept tool calls to apply the policies.
Use cases that come built in
Omnigent ships with several example policies baked in, and each one relies on a different type of session state: the content the agent has read so far, a cumulative risk score, or the total session cost. Let’s walk through them. 👇
1. Google Drive Policy: keeping access restricted to the right documents
This policy governs what the agent can read and modify across Docs, Sheets, and Slides. By default, writes are restricted to documents the agent itself created during that session. So the agent can create a new document and edit it freely, but it can’t silently alter a pre-existing file it was never supposed to touch. This wouldn’t be possible with simple allowlists — we don’t want to fully enable or block the write tool, we want to allow it only on documents the agent created in the same session.
As a second example of contextual behavior, you can flag a set of documents as confidential. The moment the agent opens one of them, the policy tightens up and restricts writes to only that set. Even a document the agent created minutes ago becomes off-limits, since attaching confidential material to it would leak that content to a less protected file. In classic security terms, this implements the Bell-LaPadula model with its no-write-down rule.
2. Risk Score Policy: increasing caution as the agent handles sensitive material
Risk scoring is something security teams already use extensively to manage human access. In Omnigent, the risk policy maintains a running score for the current session — a single number that tracks how much risk has accumulated while the agent works. Users configure which actions raise that score and by how much: a routine tool call might add one or two points, while reading a document flagged as highly confidential adds a lot more.
While the score stays low, the agent works without interruptions. But when it crosses a threshold, actions like sending an email or sharing a file start returning ASK instead of ALLOW, requiring user confirmation. In other words, the same email that would have gone out without issue at the start of the session might require human approval later, after the agent has handled enough sensitive material to push the score up.
3. Cost Policy: keeping spending under control
Autonomous AI agents can easily get stuck in loops, make redundant calls to expensive language models, or process far more data than necessary. The budget policy tracks how much the session has spent on model calls. After crossing a soft limit, it pauses and asks if you want to continue. When spending hits the hard cap, the policy blocks new calls to the expensive model until the agent switches to a cheaper one, allowing the session to continue rather than stopping dead.
The same idea extends beyond a single session. A platform team can stack a daily per-user cap on top of the per-session cap, so no one racks up costs across multiple separate conversations. In both cases, the context is cumulative spending: the policy doesn’t judge an individual model call, it watches the running total and steps in when the session or user has spent too much. This turns cost control into a first-class policy.
4. Intent-Based Authorization: limiting privileges by purpose
Intent-based authorization sets the agent’s permissions based on the user’s initial prompt, so that even an agent that falls victim to prompt injection can’t use most of its tools to cause harm. For example, if you start a session asking the agent to update a Google Slides presentation, the policy enables reading and writing on that presentation but blocks access if the agent suddenly tries to use GitHub.
The policy simply stores as state what the user actually requested at the start of the session and then checks every tool call against that original goal, applying the Principle of Least Privilege. It’s a simple yet powerful policy enabled by contextual state: you can configure agents with plenty of tools by default, and they’ll automatically be restricted in each session. The same tool call that’s perfectly acceptable in one session might require your approval in another, depending on what you asked the agent to do.
Dynamic security as the new frontier for autonomous agents
The concept of dynamic security goes beyond simply adding more rules to an existing system. It represents a paradigm shift in how we think about protection in environments where agent behavior is, by nature, emergent and hard to predict ahead of time. Instead of trying to enumerate every possible action and classify it as safe or dangerous beforehand, dynamic security bets on continuous observation of runtime behavior to build a risk assessment that evolves alongside the session.
As agents take on more real work, the hard part shifts from making them work to controlling them well. Agents can start causing harm due to malicious inputs or honest bugs, and allowlist policies that inspect individual actions aren’t flexible enough to keep agents both useful and safe at the same time. Contextual policies resolve that tension by dynamically tracking state within a session and blocking actions only when the agent has accumulated enough risk. They also provide a simple and powerful tool for managing budgets at the session level, not just per user per day.
For teams running agents in production, this shift in mindset has concrete implications. First, it requires thinking about policies as flows rather than permission lists. Instead of asking what the agent can do, the question becomes under what context is a given action acceptable. Second, it changes the relationship between automation and human oversight: the goal isn’t to eliminate oversight but to concentrate it on the moments when it actually makes a difference — that is, when the accumulated context indicates something is going off-script.
Finally, it’s worth noting that Omnigent’s open source nature is a significant factor for large-scale adoption. The project is available in alpha today, integrating with the most popular coding agents and frameworks, so you can already start applying these ideas to your existing agents. Engineering teams can audit the policies, contribute new use cases, and adapt the system to each environment’s needs without relying on a proprietary black box for something as critical as the dynamic security of their agents. Security, in this scenario, stops being a brake and becomes infrastructure that grows alongside the system it protects. 🛡️
