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).

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
Output schema validation, hallucination (LLM-as-judge)

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.

Other init() options: environment, on_block, tracing (batch or realtime), streaming, fail, poll_interval.

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[guardrails]"      # ML detectors (PII NER, injection, toxicity)

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

Notes

  • Enforcement runs in your process. Detection and the block decision happen locally, so a guarded call adds no network hop for most guardrails. Budget and rate limits are the exception — they check server-side counters so limits hold across every instance of your service.
  • 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.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

actaclad_agentguard-1.5.0.tar.gz (125.9 kB view details)

Uploaded Source

Built Distribution

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

actaclad_agentguard-1.5.0-py3-none-any.whl (75.9 kB view details)

Uploaded Python 3

File details

Details for the file actaclad_agentguard-1.5.0.tar.gz.

File metadata

  • Download URL: actaclad_agentguard-1.5.0.tar.gz
  • Upload date:
  • Size: 125.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.14.6

File hashes

Hashes for actaclad_agentguard-1.5.0.tar.gz
Algorithm Hash digest
SHA256 700a5dc8e3cfbdf8f510df28591f6bd5e411bc6aafc23240208087ee756ce169
MD5 6b695e6b7bec81896149e4b2fa3e1f71
BLAKE2b-256 a4c7eb1f30f44c993d180f2164eec577cb44248cd0e3fb1208961d3f25f3ed81

See more details on using hashes here.

File details

Details for the file actaclad_agentguard-1.5.0-py3-none-any.whl.

File metadata

File hashes

Hashes for actaclad_agentguard-1.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c91f7e66df0004b782cb36537c74800a4fa605a0572d5200948aad4ac782ad07
MD5 fa3ad426c9b815755fa19c50810b14e7
BLAKE2b-256 79119bf215ae068fce3c87415316108b06624cc93d192289103cdd1a2059864c

See more details on using hashes here.

Release history Release notifications | RSS feed

1.5.2

2 files

1.5.1

2 files

This release

1.5.0 This release

2 files

1.4.0

2 files

1.3.0

1 file

1.2.2

1 file

1.2.1

2 files

1.2.0

2 files

1.1.1

2 files

1.1.0

2 files

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