Skip to main content

Python SDK for AgentGuard — the firewall for AI agents

Project description

AgentGuard Python SDK

Lightweight Python client for AgentGuard — the firewall for AI agents.

Install

pip install agentguardproxy

# With framework adapters
pip install agentguardproxy[langchain]
pip install agentguardproxy[crewai]
pip install agentguardproxy[browser-use]
pip install agentguardproxy[all]

Quick Start

from agentguard import Guard

guard = Guard("http://localhost:8080", agent_id="my-agent")

# Check before executing
result = guard.check("shell", command="rm -rf ./old_data")

if result.allowed:
    execute(command)
elif result.needs_approval:
    print(f"Approve at: {result.approval_url}")
else:
    print(f"Blocked: {result.reason}")

Framework Adapters

LangChain

from agentguard.adapters.langchain import GuardedToolkit

toolkit = GuardedToolkit(
    tools=my_tools,
    guard_url="http://localhost:8080",
    agent_id="langchain-agent",
)

agent = create_react_agent(llm, toolkit.tools, prompt)

CrewAI

from agentguard.adapters.crewai import guard_crew_tools

guarded_tools = guard_crew_tools(
    tools=my_crew_tools,
    guard_url="http://localhost:8080",
    agent_id="crew-agent",
)

browser-use

from agentguard.adapters.browseruse import GuardedBrowser

browser = GuardedBrowser(guard_url="http://localhost:8080")

result = browser.check_navigation("https://example.com")
if result.allowed:
    await page.goto("https://example.com")

MCP

from agentguard.adapters.mcp import GuardedMCPServer

server = GuardedMCPServer(guard_url="http://localhost:8080")
server.add_tool("my_tool", "Description", handler=my_handler)
server.run()  # Starts stdio MCP server

API Reference

Guard(base_url, agent_id="")

  • check(scope, *, action, command, path, domain, url, meta) — Check an action against policy
  • approve(approval_id) — Approve a pending action
  • deny(approval_id) — Deny a pending action
  • wait_for_approval(approval_id, timeout=300) — Block until resolved

CheckResult

  • .allowed — True if action is permitted
  • .denied — True if action is blocked
  • .needs_approval — True if human approval required
  • .decision — Raw decision string
  • .reason — Explanation
  • .approval_url — URL to approve (when applicable)

@guarded(scope, guard=None) decorator

Wraps a function so it's checked before execution.

License

Apache 2.0

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

agentguardproxy-0.4.0.tar.gz (14.7 kB view details)

Uploaded Source

Built Distribution

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

agentguardproxy-0.4.0-py3-none-any.whl (13.4 kB view details)

Uploaded Python 3

File details

Details for the file agentguardproxy-0.4.0.tar.gz.

File metadata

  • Download URL: agentguardproxy-0.4.0.tar.gz
  • Upload date:
  • Size: 14.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for agentguardproxy-0.4.0.tar.gz
Algorithm Hash digest
SHA256 faec3bd6c33b674796aafd471a34b1d06ba0152b310b4f90c740ffe6a8a87ddf
MD5 0d749279299630ec0a0981d96eb9bb2f
BLAKE2b-256 8c9c081ededf33283fcdc83fa9470bf560b1115d9f9dd6d7081f74c68df97d90

See more details on using hashes here.

File details

Details for the file agentguardproxy-0.4.0-py3-none-any.whl.

File metadata

File hashes

Hashes for agentguardproxy-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ead1c169bc4e48b79463a7a3c5410b9e95a262e16a14cf1d422cb3b7cda08eab
MD5 29a36167708d4e0c38d5f7f286f62690
BLAKE2b-256 ec960873c1a423c328616ccb0c306a4af186fe5e52eeda27c3a1525fb5940fc3

See more details on using hashes here.

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