Governing Agents with Policies: Allow, Deny, and Ask
Policies are declarative gates that control what agents can do. Set them at the server, agent spec, or session level — with ALLOW, DENY, or ASK verdicts.
Use this file to discover all available pages before exploring further.
Policies are declarative gates that evaluate every agent action at specific enforcement points and return one of three verdicts: ALLOW (the action proceeds), DENY (the action is blocked and the agent receives an error), or ASK (the action is paused for your approval — approved becomes ALLOW, refused becomes DENY). Multiple policies can be active at once; they compose in declaration order, and a DENY from any policy short-circuits the rest.
Session policies evaluate first and can enforce stricter rules than the
agent spec or server defaults — a user-level policy can DENY an action before
spec or admin policies ever run.
Policies are configured at three levels, each serving a different persona.
Level
Who sets it
How
Evaluated
Server-wide
Admin
policies block in server config YAML, or REST API
Last
Agent spec
Agent developer
policies block in agent YAML
Middle
Session
End user
Session info panel in the web UI, or chat
First
Session policies evaluate before spec policies, which evaluate before server-wide policies. This means a session-level DENY short-circuits the rest of the chain.
Policies declared in an agent YAML apply to every session that uses that agent. They are evaluated in declaration order:
name: github_agentprompt: You are a coding assistant with access to GitHub.executor: harness: claude-sdk model: databricks-claude-sonnet-4-6tools: github: type: mcp url: https://api.githubcopilot.com/mcp/policies: limit_tool_calls: type: function handler: omnigent.policies.builtins.safety.max_tool_calls_per_session factory_params: limit: 100 github_access: type: function handler: omnigent.policies.builtins.github.github_policy factory_params: write_repos: - myorg/my-repo write_branches: - "feature/*" google_policy: type: function handler: omnigent.policies.builtins.google.gdrive_policy factory_params: read_all: true allow_create: true
Each policy entry requires type ("function") and handler (a dotted Python import path). Add factory_params when the handler is a factory that accepts configuration.
Session-level policies let you customize agent behavior for your current task without modifying the spec or server config. There are two ways to add them:
Web UI — Open the session’s info panel to browse available policies and toggle them on or off.
Chat — Tell the agent directly, for example: “Add a policy that asks me before running shell commands.” The agent uses its built-in sys_add_policy tool to configure it.
A policy is a Python callable that receives a PolicyEvent dict and returns a PolicyResponse dict (or None to abstain).
from omnigent.policies.schema import PolicyEvent, PolicyResponsedef my_policy(event: PolicyEvent) -> PolicyResponse | None: if event["type"] != "tool_call": return None # abstain on non-tool phases tool = event["data"]["name"] if tool == "dangerous_tool": return {"result": "DENY", "reason": "This tool is blocked."} return {"result": "ALLOW"}
For policies that need configuration, write a factory — a function that accepts parameters and returns the actual evaluator:
def block_domains(blocked_domains: list[str]) -> callable: blocked = frozenset(d.lower() for d in blocked_domains) def evaluate(event: PolicyEvent) -> PolicyResponse | None: if event["type"] != "tool_call" or event["target"] != "web_fetch": return None url = event["data"]["arguments"].get("url", "") for domain in blocked: if domain in url.lower(): return {"result": "DENY", "reason": f"Domain {domain} is blocked."} return {"result": "ALLOW"} return evaluate
The result field is the only required key in the response dict. Valid values are "ALLOW", "DENY", and "ASK". Return None to abstain and let the next policy in the chain evaluate.To make custom policies appear in the UI registry, export a POLICY_REGISTRY list from your module and register the module in the server config under policy_modules.
Builtin policy reference
Full parameter tables, default values, and YAML examples for every builtin
policy.