Skip to main content

Runtime security guardrails for AI agents — inspect, control, and audit every tool call. Zero-dependency local mode included.

Project description

AgentGuard Python SDK

Lightweight security guardrails for AI agents. All security logic runs server-side.

Quick Start

from agentguard import Shield

shield = Shield()  # reads AGENTGUARD_API_KEY from env

@shield.guard
async def send_email(to: str, body: str) -> str:
    ...  # your tool implementation

# The server decides: ALLOW, BLOCK, or REQUIRE_CONFIRMATION
await send_email(to="user@company.com", body="Hello")

Session Mode

async with shield.session("Summarize my emails") as s:
    result = await s.guarded_executor.execute(
        "read_inbox", {"limit": 10}, read_inbox_fn
    )

Error Handling

from agentguard import Shield, ToolCallBlocked, ConfirmationRejected, ServerError

shield = Shield()

@shield.guard
async def send_email(to: str, body: str) -> str:
    ...

try:
    await send_email(to="user@test.com", body="hi")
except ToolCallBlocked as e:
    print(f"Blocked: {e.reason} (trace: {e.trace_id})")
except ConfirmationRejected:
    print("User declined confirmation")
except ServerError as e:
    print(f"Server error: {e}")

Configuration

# Explicit configuration
shield = Shield(
    api_key="your-key",
    base_url="https://shield.yourcompany.com",
    timeout=10.0,
    max_retries=3,
    agent_id="my-agent",
)

Or via environment variables:

  • AGENTGUARD_API_KEY (required)
  • AGENTGUARD_BASE_URL (default: http://localhost:8000)
  • AGENTGUARD_TIMEOUT (default: 10.0)
  • AGENTGUARD_AGENT_ID

Or via agentguard.yaml in the working directory.

Data Sanitization

# Sanitize external data before processing
result = await shield.sanitize(
    data=email_body,
    source="email/external",
)
# result.content has hidden injections removed
# result.trust_level shows the computed trust level

Framework Integrations

from agentguard.integrations import LangChainShield, CrewAIShield

# LangChain
guarded = LangChainShield(shield).wrap(agent_executor)

# CrewAI
guarded = CrewAIShield(shield).wrap(crew)

# AutoGen
from agentguard.integrations import AutoGenShield
AutoGenShield(shield).wrap(assistant)

# Claude Agent SDK
from agentguard.integrations import ClaudeAgentGuard
guarded_handler = ClaudeAgentGuard(shield).wrap(my_tool_handler)

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

agentguardx-0.1.0.tar.gz (19.4 kB view details)

Uploaded Source

Built Distribution

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

agentguardx-0.1.0-py3-none-any.whl (21.3 kB view details)

Uploaded Python 3

File details

Details for the file agentguardx-0.1.0.tar.gz.

File metadata

  • Download URL: agentguardx-0.1.0.tar.gz
  • Upload date:
  • Size: 19.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for agentguardx-0.1.0.tar.gz
Algorithm Hash digest
SHA256 86ca57478cd97bf1021308d479398a7014dcadb1b1bf810153a27c35ae35e765
MD5 8451bcddd4e63a1e13b00a0a2f40c9c9
BLAKE2b-256 4ccceeacc13371c4114fc6e41ce4d7581772088e7432dac4afded3d30269ed54

See more details on using hashes here.

File details

Details for the file agentguardx-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: agentguardx-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 21.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for agentguardx-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 591b0a9df197efad1a8f2dcd46d69d365aaeb41fd600733de183505b09642489
MD5 163b0d93c06d26e5ef42db1dc7b2eadf
BLAKE2b-256 a46d00dd91c1a3ab49d635518218c3a94af6d5c2017d760cc80b5b936b07e96c

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