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 agentguard

# With framework adapters
pip install agentguard[langchain]
pip install agentguard[crewai]
pip install agentguard[browser-use]
pip install agentguard[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.0.tar.gz (10.8 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.0-py3-none-any.whl (12.8 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for agentguardproxy-0.2.0.tar.gz
Algorithm Hash digest
SHA256 94cae3b82f475bc3986bf3920801bbfdc326cea3dd4482896ea02789a177aa8e
MD5 ba10c3cb4928eb562d9ca270d3a713b8
BLAKE2b-256 588e7828791dec7736768dce9af9840404fe18bbbc3cafdb0a29f8963c8b6049

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for agentguardproxy-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ca699d60be71db8aedad416722c7eeca7a1ae48dfd470d1237bef89d4330337a
MD5 d9422360db141a40d4c203334519a349
BLAKE2b-256 43d7f0f130b1a946e3af699fef611e5d6ce272fae7c2e65877babff436983683

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