Skip to main content

AgentGuard — Python SDK

Runtime guardrails and observability for LLM and agent applications.

One call to init() instruments your provider clients. Every LLM call is then scanned against the guardrails you configure in the AgentGuard console, and traced — prompts, responses, token usage, cost, and any guardrail that fired.

pip install actaclad-agentguard
import agentguard

agentguard.init(
    public_key="pk-...",
    secret_key="sk-...",
    base_url="https://your-agentguard-host",
    project_id="your-project-id",
)

That is the whole setup. Your existing OpenAI, Anthropic, Gemini or LiteLLM calls are now guarded and traced — no call sites change.

Scoping a request

policy() attaches identity to the work inside it and opens the trace, so an agent run is one trace rather than a scatter of unlinked calls.

with agentguard.policy(
    user_id="u-123",
    session_id="s-456",
    feature="support-triage",
    metadata={"tenant": "acme"},
):
    answer = my_agent.invoke(question)

Everything inside — guarded LLM calls, tool calls, agent steps — lands in one trace, with the identity recorded once at the top and filterable in the console.

Agent frameworks

LangChain and LangGraph are traced automatically inside a policy() scope. No callback wiring:

with agentguard.policy(user_id=user_id, feature="triage"):
    agent.invoke({"messages": [{"role": "user", "content": question}]})

Pass the handler yourself only if you want to — agentguard.langchain_handler(). Opt out with policy(autotrace=False).

Tools are guarded automatically. LangChain tools (including LangGraph's ToolNode) and CrewAI tools get a permission check, and their arguments and results are scanned. For MCP, instrument the client session:

from agentguard.mcp import instrument_mcp_client   # pip install "actaclad-agentguard[mcp]"
instrument_mcp_client(session)

Other frameworks:

agentguard.instrument_crewai()          # pip install "actaclad-agentguard[crewai]"
agentguard.instrument_openai_agents()   # pip install "actaclad-agentguard[openai-agents]"

Guardrails

Guardrails are configured server-side per project and enforced in the SDK, so a policy change takes effect without a redeploy.

Content PII redaction, secret scanner, token scanner
Safety prompt injection, toxic content
Cost & rate budget guard, rate limit, token limit
Policy allowed-model list, tool permission, execution limit guard, your custom policies
Output schema validation, hallucination (LLM-as-judge)

To try a policy before you enforce it, use observe mode (1.7.0+). Every guardrail runs and records what it finds, but nothing is blocked; the console shows those findings as WOULD BLOCK. Redaction still applies.

agentguard.init(project_id="...", guardrails="observe")   # "auto" enforces

A kill switch in the console blocks every model call in the project. The SDK checks it every 10 seconds, so it works without a redeploy.

Azure, Bedrock and Vertex clients (sync and async) report their real provider: azure, bedrock or vertex. List those models under the matching provider in the Allowed Model List.

A blocked call raises, so you can handle it explicitly:

try:
    with agentguard.policy(user_id=user_id, on_block="raise"):
        answer = my_agent.invoke(question)
except agentguard.AgentGuardBlocked as blocked:
    answer = "Sorry — I can't help with that."

Use on_block="refuse" to get a safe refusal response instead of an exception.

Configuration

Credentials can come from the environment instead of init() arguments:

Variable Purpose
AGENTGUARD_PUBLIC_KEY Project public key
AGENTGUARD_SECRET_KEY Project secret key
AGENTGUARD_BASE_URL Your AgentGuard host
AGENTGUARD_PROJECT_ID Project id
AGENTGUARD_CAPTURE_CONTENT true to record prompts and responses. Default off — PII-safe by default.
AGENTGUARD_KILL_SWITCH_POLLER_ENABLED false to turn off the 10-second kill-switch check

Other init() options: guardrails (auto, observe or off), environment (a label on traces), on_block (raise or refuse), tracing (batch or realtime), streaming, poll_interval (seconds, default 900), kill_switch_poll_interval (seconds, default 10).

API

init(...) Instrument providers and start guardrail config polling
policy(...) Scope guardrails and identity to a block of work; opens the trace
start_trace(name, ...) Open a trace explicitly, e.g. to name it
chat(...) / achat(...) Guarded chat completion through the built-in client
langchain_handler() LangChain/LangGraph handler, for passing explicitly
flush() Flush pending telemetry — call before a short-lived process exits
AgentGuardBlocked Raised when a guardrail blocks a call

Optional extras

pip install "actaclad-agentguard[gemini]"          # google-genai
pip install "actaclad-agentguard[anthropic]"
pip install "actaclad-agentguard[langchain]"       # LangChain / LangGraph
pip install "actaclad-agentguard[mcp]"             # MCP tools

Guardrails need no extra install.

The base install keeps dependencies small; each extra is pulled in only when you need it.

Notes

  • Where checks run. PII, prompt injection and toxic content are scored by your AgentGuard host, in one call per step; the text is scanned, not stored. Budget and rate limits check server-side counters so limits hold across every instance of your service. Everything else runs in your process. The block decision is always made in your process.
  • If AgentGuard can't be reached, PII, injection and toxicity checks let the call through and log a warning.
  • Content capture is off by default. Prompts and responses are only recorded when AGENTGUARD_CAPTURE_CONTENT=true.
  • Failures degrade, they don't break. If telemetry or config polling fails, your application call still runs.

© ActaClad Technologies. See the AgentGuard console for documentation and project settings.

Metadata

Release files for actaclad-agentguard 1.7.0

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

Source distribution (sdist)

Source distribution for actaclad-agentguard 1.7.0
File Size Uploaded Provenance Actions
actaclad_agentguard-1.7.0.tar.gz 166.7 kB Without provenance Details for actaclad_agentguard-1.7.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for actaclad-agentguard 1.7.0
File Interpreter ABI Platform Actions
actaclad_agentguard-1.7.0-py3-none-any.whl Python 3 none any Details for actaclad_agentguard-1.7.0-py3-none-any.whl

Total release size: 292.6 kB

Release files / actaclad_agentguard-1.7.0.tar.gz

Download URL actaclad_agentguard-1.7.0.tar.gz
Size 166.7 kB
Tags Source
SHA-256 checksum
How to use checksums
a458a5fa50de83c94c1f1b33de202dba484a4d11421fffaee0180bdae8fd2e0c
BLAKE2b-256 checksum
How to use checksums
37b5865b5c2228d44f47089b3db944484dcca7b5042c8827ff9cf4fe0a7e8053
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.6

Release files / actaclad_agentguard-1.7.0-py3-none-any.whl

Download URL actaclad_agentguard-1.7.0-py3-none-any.whl
Size 125.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9a35d429135065c8dd95ae67422cd2c98047d5ed7bf8ebd11a05186990727a78
BLAKE2b-256 checksum
How to use checksums
1058ab87bd091e995ac9d952d57b94c924da22d1f41190f07edf76758c5959ed
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.6

Security for actaclad-agentguard 1.7.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.

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