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.2.3.tar.gz (14.5 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.2.3-py3-none-any.whl (13.3 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for agentguardproxy-0.2.3.tar.gz
Algorithm Hash digest
SHA256 61276c1c4d72b9ffee719adb90a4bdcc8a3d5effba2a7af66769476f5dfb6001
MD5 feb75b711d54089cc0b65fbe668e9e28
BLAKE2b-256 4abe581cfcd1b507168d043e182812c9d36afe7b9d8554dc6da82cbd56e5c536

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for agentguardproxy-0.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 82b1f662b7a98fa79e87e1a867a0a67b32a21f9e06866f1b0b8d1bb8457022e8
MD5 85a760bc2fa81d70a54b4bd9f976ef44
BLAKE2b-256 90b7f3ac2f1b0209897b8bdc1bb7d9ae73e7693472b742e20a0ef3e0aa482a40

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