Skip to main content

codesec-agentguard (Python SDK)

Official Python SDK for the AgentGuard AI Agent Security Gateway.

AgentGuard intercepts, evaluates, and verifies autonomous AI agent actions against deterministic spending limits, currency controls, capability whitelists, and adversarial prompt injection heuristic scans before downstream payment APIs (such as Razorpay or PayPal) are executed.


Installation

pip install codesec-agentguard

Or install locally in editable mode:

pip install -e packages/python-sdk

Quickstart

import os
from agentguard import AgentGuard

# Initialize client
guard = AgentGuard(
    base_url=os.environ.get("AGENTGUARD_URL", "http://localhost:3001"),
    api_key=os.environ["AGENTGUARD_API_KEY"],
    timeout=5.0,
)

# Pre-flight evaluation
decision = guard.evaluate({
    "action": "payment.create",
    "amount": 1200.0,
    "currency": "INR",
    "recipient": "merchant@store.com",
    "description": "Autonomous grocery restocking order",
    "prompt_context": "User prompt: Restock organic coffee beans.",
})

if decision.status == "ALLOW":
    print(f"Action permitted! Policy version: {decision.policy_version}")
    # Safe to initiate Razorpay order
elif decision.status == "HOLD":
    print(f"Action held for human review: {decision.pending_approval_id}")
    # Wait for operator in AgentGuard dashboard
else:
    print(f"Blocked by AgentGuard: {decision.reason}")
    for violation in decision.violations:
        print(f" - {violation}")

Context Manager Usage

with AgentGuard(base_url="http://localhost:3001", api_key="ag_live_...") as guard:
    decision = guard.evaluate(action="payment.create", amount=25.0)
    if decision.is_allowed:
        pass

Strict Fail-Closed Guarantee

# evaluate_safely catches all timeouts, DNS failures, and gateway crashes,
# strictly returning an authoritative BLOCK decision so your code never fails open.
decision = guard.evaluate_safely(action="payment.create", amount=50.0)
if not decision.is_allowed:
    print(f"Transaction denied: {decision.reason}")

License

MIT © AgentGuard Security Team

Metadata

Release files for codesec-agentguard 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for codesec-agentguard 1.0.0
File Interpreter ABI Platform Actions
codesec_agentguard-1.0.0-py3-none-any.whl Python 3 none any Details for codesec_agentguard-1.0.0-py3-none-any.whl

Release files / codesec_agentguard-1.0.0-py3-none-any.whl

Download URL codesec_agentguard-1.0.0-py3-none-any.whl
Size 9.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b2b4d1642973c78b079cc12db7612e6908e1b71b9b8609fc0c0bcc9f2df4282b
BLAKE2b-256 checksum
How to use checksums
4da3ffcf1a513ceb30e9e252624650b20d6ced217d113d4d2812d7a955f7432b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.6

Security for codesec-agentguard 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.0 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page