Observed since 20 Oct, 22:55 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
Runtime policy enforcement for AI agent sessions
AgentPolicy is an open-source Python SDK that puts explicit runtime rules around what an agent is allowed to do. It enforces budgets, tool access, network access, and approval gates in real time, with a structured audit trail for every decision.
One policy layer for agent behavior. Zero infrastructure to manage.
Agents fail in non-deterministic ways:
AgentPolicy makes those decisions explicit and enforceable.
Each runtime action is evaluated as one of:
allowdenyrequire_approvalEvery decision is recorded with the action, the reason, and the matched policy rule.
Budget is treated as a first-class policy.
AgentPolicy uses agentbudget under the hood for spend accounting and hard budget enforcement instead of rebuilding that layer.
Define policy once. Enforce it at runtime.
budget:
max_spend: 5.00
tools:
allow:
- search_docs
- read_file
- send_email
block:
- delete_prod_db
network:
allow:
- docs.python.org
block:
- twitter.com
approval:
require_for:
- tool: send_email
- cost_gt: 1.00
from agentpolicy import AgentPolicy, ApprovalRequired
policy = AgentPolicy.from_yaml("policy.yaml")
with policy.session() as session:
session.check_tool("search_docs", cost=0.02)
session.check_http("https://docs.python.org/3/", cost=0.01)
try:
session.check_tool("send_email")
except ApprovalRequired:
session.check_tool("send_email", approved=True)
print(session.report())
For full control, define policy directly in code.
from agentpolicy import AgentPolicy
policy = AgentPolicy(
budget="$5.00",
allowed_tools=["search_docs", "read_file"],
blocked_domains=["twitter.com"],
approval_rules=[
{"tool": "send_email"},
{"cost_gt": 1.00},
],
)
with policy.session() as session:
session.check_tool("search_docs", cost=0.02)
session.check_http("https://docs.python.org/3/", cost=0.01)
pip install agentpolicy
Python 3.9+.
Installs agentbudget as a dependency.
For local development:
python3 -m pip install -e .[dev]
bash scripts/run_tests.sh
| Object | Description |
|---|---|
AgentPolicy(...) | Define the runtime policy envelope for an agent. |
AgentPolicy.from_yaml(path) | Load a declarative policy file. |
AgentPolicy.from_dict(data) | Build policy from a Python mapping. |
policy.session() | Create a new PolicySession. |
session.check_tool(name, cost=...) | Evaluate a tool execution. |
session.check_http(url, cost=...) | Evaluate an outbound HTTP request. |
session.check_cost(cost, source=...) | Evaluate a metered cost event such as an LLM call. |
session.guard_tool(...) | Decorate a tool with policy enforcement. |
session.evaluate(action) | Return a decision without enforcing it. |
session.enforce(action) | Record and enforce a decision. |
session.report() | Return the full structured audit report. |
policy = AgentPolicy(budget="$3.00")
Denies any action that would push the session over budget.
policy = AgentPolicy(
allowed_tools=["search_docs", "read_file"],
blocked_tools=["delete_prod_db"],
)
Supports allowlists and explicit blocks.
policy = AgentPolicy(
allowed_domains=["docs.python.org", "api.openai.com"],
blocked_domains=["twitter.com", "facebook.com"],
)
Controls outbound HTTP access at the domain layer.
policy = AgentPolicy(
approval_rules=[
{"tool": "send_email"},
{"domain": "api.stripe.com"},
{"cost_gt": 1.00},
]
)
Escalates sensitive actions to ApprovalRequired.
agentpolicy validate policy.yaml
agentpolicy explain policy.yaml
agentpolicy demo policy.yaml
The CLI is intentionally small:
validate checks that a policy file is structurally validexplain prints a simple machine-readable summarydemo runs a sample session and prints the resulting reportAgentPolicy is designed to be legible under pressure.
Each decision includes:
Reports also summarize:
{
"session_id": "pol_a1b2c3d4e5f6",
"budget": 5.0,
"spent": 0.03,
"remaining": 4.97,
"decision_summary": {
"allow": 2,
"deny": 1,
"require_approval": 1,
"by_action_type": {"tool": 2, "http": 2},
},
"cost_summary": {
"by_action_type": {"tool": 0.02, "http": 0.01},
},
"policy_hits": {
"denied_tools": [],
"denied_domains": ["twitter.com"],
"approval_required": ["send_email"],
},
"duration_seconds": 0.14,
"decisions": [...],
}
agentbudget answers:
agentpolicy answers:
In practice, budget is one policy dimension inside a broader runtime control layer.
The stack is:
agentbudget for cost accounting and hard budget enforcementagentpolicy for the broader runtime decision layerMost agent tooling focuses on orchestration. AgentPolicy focuses on control.
It is a good fit for:
AgentPolicy is deliberately small.
It is not a dashboard. It is not a hosted compliance product. It is not an orchestration framework.
It is a runtime primitive for making agent behavior explicit and enforceable.
Early, but real.
The first version covers the four policy types that matter most in practice:
That is enough to protect a surprising amount of real agent behavior without adding operational complexity.
pypistats · 47 observations shown. Missing days are unknown. Source category: overall: without mirrors.
| Date / source period | Value | Observed at |
|---|---|---|
| 2026-10-20 – 2026-10-20 | 2 | 2026-10-21T11:33:38.8716839Z |
| 2026-10-18 – 2026-10-18 | 3 | 2026-10-21T11:33:38.8716839Z |
| 2026-10-17 – 2026-10-17 | 8 | 2026-10-21T11:33:38.8716839Z |
| 2026-10-16 – 2026-10-16 | 1 | 2026-10-21T11:33:38.8716839Z |
| 2026-10-15 – 2026-10-15 | 5 | 2026-10-21T11:33:38.8716839Z |
| 2026-10-14 – 2026-10-14 | 1 | 2026-10-21T11:33:38.8716839Z |
| 2026-10-13 – 2026-10-13 | 1 | 2026-10-21T11:33:38.8716839Z |
| 2026-10-12 – 2026-10-12 | 1 | 2026-10-21T11:33:38.8716839Z |
| 2026-10-10 – 2026-10-10 | 2 | 2026-10-21T11:33:38.8716839Z |
| 2026-10-09 – 2026-10-09 | 2 | 2026-10-21T11:33:38.8716839Z |
| 2026-10-08 – 2026-10-08 | 1 | 2026-10-21T11:33:38.8716839Z |
| 2026-10-06 – 2026-10-06 | 3 | 2026-10-21T11:33:38.8716839Z |
| 2026-10-02 – 2026-10-02 | 1 | 2026-10-21T11:33:38.8716839Z |
| 2026-09-30 – 2026-09-30 | 5 | 2026-10-21T11:33:38.8716839Z |
| 2026-09-29 – 2026-09-29 | 2 | 2026-10-21T11:33:38.8716839Z |
| 2026-09-27 – 2026-09-27 | 2 | 2026-10-21T11:33:38.8716839Z |
| 2026-09-26 – 2026-09-26 | 1 | 2026-10-21T11:33:38.8716839Z |
| 2026-09-23 – 2026-09-23 | 1 | 2026-10-21T11:33:38.8716839Z |
| 2026-09-22 – 2026-09-22 | 1 | 2026-10-21T11:33:38.8716839Z |
| 2026-09-21 – 2026-09-21 | 1 | 2026-10-21T11:33:38.8716839Z |
| 2026-09-20 – 2026-09-20 | 5 | 2026-10-21T11:33:38.8716839Z |
| 2026-09-19 – 2026-09-19 | 2 | 2026-10-21T11:33:38.8716839Z |
| 2026-09-17 – 2026-09-17 | 1 | 2026-10-21T11:33:38.8716839Z |
| 2026-09-16 – 2026-09-16 | 1 | 2026-10-21T11:33:38.8716839Z |
| 2026-09-14 – 2026-09-14 | 4 | 2026-10-21T11:33:38.8716839Z |
| 2026-09-10 – 2026-09-10 | 1 | 2026-10-21T11:33:38.8716839Z |
| 2026-09-07 – 2026-09-07 | 1 | 2026-10-21T11:33:38.8716839Z |
| 2026-09-01 – 2026-09-01 | 1 | 2026-10-21T11:33:38.8716839Z |
| 2026-08-31 – 2026-08-31 | 1 | 2026-10-21T11:33:38.8716839Z |
| 2026-08-28 – 2026-08-28 | 1 | 2026-10-21T11:33:38.8716839Z |
| 2026-08-25 – 2026-08-25 | 1 | 2026-10-21T11:33:38.8716839Z |
| 2026-08-24 – 2026-08-24 | 5 | 2026-10-21T11:33:38.8716839Z |
| 2026-08-23 – 2026-08-23 | 3 | 2026-10-21T11:33:38.8716839Z |
| 2026-08-21 – 2026-08-21 | 1 | 2026-10-21T11:33:38.8716839Z |
| 2026-08-18 – 2026-08-18 | 1 | 2026-10-21T11:33:38.8716839Z |
| 2026-08-17 – 2026-08-17 | 2 | 2026-10-21T11:33:38.8716839Z |
| 2026-08-15 – 2026-08-15 | 2 | 2026-10-21T11:33:38.8716839Z |
| 2026-08-14 – 2026-08-14 | 2 | 2026-10-21T11:33:38.8716839Z |
| 2026-08-11 – 2026-08-11 | 1 | 2026-10-21T11:33:38.8716839Z |
| 2026-08-09 – 2026-08-09 | 2 | 2026-10-21T11:33:38.8716839Z |
| 2026-08-08 – 2026-08-08 | 2 | 2026-10-21T11:33:38.8716839Z |
| 2026-08-04 – 2026-08-04 | 3 | 2026-10-21T11:33:38.8716839Z |
| 2026-08-02 – 2026-08-02 | 2 | 2026-10-21T11:33:38.8716839Z |
| 2026-07-31 – 2026-07-31 | 2 | 2026-10-21T11:33:38.8716839Z |
| 2026-07-27 – 2026-07-27 | 3 | 2026-10-21T11:33:38.8716839Z |
| 2026-07-25 – 2026-07-25 | 2 | 2026-10-21T11:33:38.8716839Z |
| 2026-07-23 – 2026-07-23 | 2 | 2026-10-21T11:33:38.8716839Z |
| Version | Published | Direct dependencies | Open version |
|---|---|---|---|
| 0.1.1 | 25 Mar 2026 | 3 |
This describes our collected data; it is not a security assessment.
Observed since 20 Oct, 22:55 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
package:28df7508db196ba1a3809da7c329e76f8e6435c29bf9a6ab269b8f0adb098b07