Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

agentpriv-0.1.0.tar.gz (5.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

agentpriv-0.1.0-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

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

Hashes for agentpriv-0.1.0.tar.gz
Algorithm Hash digest
SHA256 799951a5af421c653aa1f10b0aa5abe7f776e12288fbd39ca8faa3530c5f035c
MD5 484e10ecba498d3014b4686657d1d3fe
BLAKE2b-256 79d4b1449e3e08cc7ff7025e61a37f6046cf7631d8643d32025ae3bde2d5467d

See more details on using hashes here.

Provenance

The following attestation bundles were made for agentpriv-0.1.0.tar.gz:

Publisher: publish.yml on nichkej/agentpriv

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for agentpriv-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9a1b345bb322a64e5320db69f255a025208c0a54ed62613d7082218d23679e59
MD5 71b68ba116991b4c0f1def364fa54c65
BLAKE2b-256 bc52bdce74615392b4394ec670f90fb5425dd70600376bcbd55a28abb3f0b6e1

See more details on using hashes here.

Provenance

The following attestation bundles were made for agentpriv-0.1.0-py3-none-any.whl:

Publisher: publish.yml on nichkej/agentpriv

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page