Skip to main content

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])

Custom prompt

By default, "ask" mode prompts in the terminal. Pass prompt= to use your own approval logic:

# auto-approve in testing
safe = guard(delete_db, policy="ask", prompt=lambda name, args, kwargs: True)

# approve via web UI, Slack, or any custom flow
safe = guard(delete_db, policy="ask", prompt=my_approval_handler)

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

Release files for agentpriv 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for agentpriv 0.1.1
File Size Uploaded
agentpriv-0.1.1.tar.gz 5.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for agentpriv 0.1.1
File Interpreter ABI Platform
agentpriv-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 11.3 kB

Release files / agentpriv-0.1.1.tar.gz

Download URL agentpriv-0.1.1.tar.gz
Size 5.7 kB
Tags Source
SHA-256 checksum
How to use checksums
7e78fda22f2043c6869390798389c5f7054481ee59667a9c72c9316b9009cb8b
BLAKE2b-256 checksum
How to use checksums
6094121e7d93898c941f4073a66a703b383fd4b3fa56dfabd73b264cd77862c9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Feb 18, 2026.

Transparency log

Release files / agentpriv-0.1.1-py3-none-any.whl

Download URL agentpriv-0.1.1-py3-none-any.whl
Size 5.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d144fafdc341099aeffba4a3c757cf4456a89e98abab8dd95c41610cda378b68
BLAKE2b-256 checksum
How to use checksums
414abca4fcb1f965a038a97bb6af0312480eabd12330f6c3252f51b21056e1b7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Feb 18, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page