sudo for AI agents - allow, deny, or ask before any tool runs
Project description
agentpriv
sudo for AI agents - allow, deny, or ask before any tool runs.
AI agents run tools autonomously, but some calls are too risky to run unchecked. agentpriv gives you a permission layer to control what goes through.
Why
- One place - guard a tool once, every agent using it gets the same rule
- Gradual trust - start on
"ask", promote to"allow"as you gain confidence - Visibility - every blocked or prompted call is printed with full arguments, so you see exactly what the agent is trying to do
- Framework agnostic - plain wrapper around your functions, so it works with any agent framework or none at all
Install
pip install agentpriv
Quick start
from agentpriv import guard, guard_all, AgentPrivDenied
safe_send = guard(send_message, policy="ask")
tools = guard_all(
[read_messages, send_message, delete_channel],
policy={
"delete_*": "deny",
"send_*": "ask",
"*": "allow",
}
)
Three modes
| Mode | What happens |
|---|---|
"allow" |
Runs normally, no interruption |
"deny" |
Raises AgentPrivDenied immediately, the function never executes |
"ask" |
Pauses, shows the call in your terminal, waits for y/n |
agentpriv: send_message(channel='general', text='deploying now')
Allow this call? [y/n]: y # runs the function
Allow this call? [y/n]: n # raises AgentPrivDenied
on_deny - raise or return
By default, denied calls raise AgentPrivDenied. When using frameworks, set on_deny="return" so the LLM sees the denial as a tool result instead of crashing:
# Plain Python - raises exception
safe = guard(delete_channel, policy="deny")
# Frameworks - returns error string to the LLM
safe = guard(delete_channel, policy="deny", on_deny="return")
Works with any framework
Guard first, then pass to your framework as usual:
OpenAI Agents SDK
safe_delete = function_tool(guard(delete_db, policy="ask", on_deny="return"))
agent = Agent(name="Demo", tools=[safe_delete])
LangChain / LangGraph
safe_delete = tool(guard(delete_db, policy="ask", on_deny="return"))
agent = create_agent(model=llm, tools=[safe_delete])
PydanticAI
agent = Agent("openai:gpt-4o", tools=[guard(delete_db, policy="ask", on_deny="return")])
CrewAI
safe_delete = tool("Delete DB")(guard(delete_db, policy="ask", on_deny="return"))
agent = Agent(role="DBA", tools=[safe_delete])
Policy matching
- Patterns use glob syntax (
fnmatch) against the function's__name__ - More specific patterns win over wildcards (
delete_channel>delete_*>*) - If a function doesn't match any pattern, it defaults to
"deny"- so forgetting a rule blocks the call rather than silently allowing it. Use"*": "allow"as a catch-all to opt out
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file agentpriv-0.1.0.tar.gz.
File metadata
- Download URL: agentpriv-0.1.0.tar.gz
- Upload date:
- Size: 5.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
799951a5af421c653aa1f10b0aa5abe7f776e12288fbd39ca8faa3530c5f035c
|
|
| MD5 |
484e10ecba498d3014b4686657d1d3fe
|
|
| BLAKE2b-256 |
79d4b1449e3e08cc7ff7025e61a37f6046cf7631d8643d32025ae3bde2d5467d
|
Provenance
The following attestation bundles were made for agentpriv-0.1.0.tar.gz:
Publisher:
publish.yml on nichkej/agentpriv
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
agentpriv-0.1.0.tar.gz -
Subject digest:
799951a5af421c653aa1f10b0aa5abe7f776e12288fbd39ca8faa3530c5f035c - Sigstore transparency entry: 962148437
- Sigstore integration time:
-
Permalink:
nichkej/agentpriv@635ad653226492da431d35271ce942b9de3eee28 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/nichkej
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@635ad653226492da431d35271ce942b9de3eee28 -
Trigger Event:
release
-
Statement type:
File details
Details for the file agentpriv-0.1.0-py3-none-any.whl.
File metadata
- Download URL: agentpriv-0.1.0-py3-none-any.whl
- Upload date:
- Size: 5.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9a1b345bb322a64e5320db69f255a025208c0a54ed62613d7082218d23679e59
|
|
| MD5 |
71b68ba116991b4c0f1def364fa54c65
|
|
| BLAKE2b-256 |
bc52bdce74615392b4394ec670f90fb5425dd70600376bcbd55a28abb3f0b6e1
|
Provenance
The following attestation bundles were made for agentpriv-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on nichkej/agentpriv
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
agentpriv-0.1.0-py3-none-any.whl -
Subject digest:
9a1b345bb322a64e5320db69f255a025208c0a54ed62613d7082218d23679e59 - Sigstore transparency entry: 962148454
- Sigstore integration time:
-
Permalink:
nichkej/agentpriv@635ad653226492da431d35271ce942b9de3eee28 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/nichkej
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@635ad653226492da431d35271ce942b9de3eee28 -
Trigger Event:
release
-
Statement type: