Skip to main content

Compliance-as-code middleware for agentic AI workflows.

Project description

AgentGovern Python SDK

Compliance-as-code for agentic AI workflows.

Beta — API may change before 1.0. Report issues.

AgentGovern intercepts AI agent actions, evaluates them against configurable compliance policies (EU AI Act, NIST AI RMF, ISO 42001), and generates audit-ready evidence — in real-time. This SDK instruments your LangChain, CrewAI, or OpenAI Agents code with minimal changes.

Install

pip install agentgovern

Quickstart — LangChain

import agentgovern
from langchain.agents import AgentExecutor, create_openai_tools_agent
from langchain_openai import ChatOpenAI

# 1. Initialize once at startup
agentgovern.init(
    api_key="ag_prod_...",           # from https://agentgovern.zirahn.com/settings/api-keys
    base_url="https://agentgovern.zirahn.com",
    environment="development",       # "production" | "staging" | "development"
)

# 2. Register your agent
agentgovern.register_agent(
    "credit-scoring-agent-01",
    name="Credit Scoring Agent",
    framework="langchain",
)

# 3. Get the callback handler
handler = agentgovern.instrument_langchain()

# 4. Pass it to your AgentExecutor — no other changes needed
llm = ChatOpenAI(model="gpt-4o")
agent = create_openai_tools_agent(llm, tools, prompt)
executor = AgentExecutor(agent=agent, tools=tools, callbacks=[handler])

result = executor.invoke({"input": "Evaluate loan application for customer #12345"})

Every tool call, LLM invocation, and agent step is automatically captured, evaluated against your enabled compliance policies, and visible in the dashboard.

Manual instrumentation (all frameworks)

from agentgovern.types import ActionType, ActionStatus

agentgovern.track_action(
    agent_external_id="my-agent-id",
    action_type=ActionType.TOOL_CALL,
    action_name="fetch_credit_bureau_data",
    status=ActionStatus.COMPLETED,
    duration_ms=312,
    input_payload={"bureau": "experian", "customer_id": "..."},
    output_payload={"fico_score": 720},
)

Supported frameworks

Framework Auto-instrumentation Status
LangChain instrument_langchain() — wraps tool and LLM callbacks Stable
CrewAI Manual via track_action() Beta
OpenAI Agents API Manual via track_action() Beta

Auto-instrumentation for CrewAI and OpenAI Agents is on the roadmap.

Compliance frameworks

Framework Status
EU AI Act (High-Risk Systems) Available
NIST AI RMF Coming soon
ISO 42001 Coming soon

Enable policy packs from the AgentGovern dashboard.

Configuration

Parameter Default Description
api_key required SDK ingest key from the dashboard
base_url https://agentgovern.zirahn.com API endpoint
environment "production" "production" | "staging" | "development"
fail_silently True If True, SDK errors never raise into your agent

Design guarantees

  • track_action() returns in < 5 ms — all I/O is async in a background thread
  • Buffer cap: 10,000 actions; oldest dropped when full
  • Retry: 3 attempts with exponential backoff (1 s → 30 s max)
  • If AgentGovern is unreachable, your agent continues unaffected

Links

License

MIT — Copyright (c) 2026 Zirahn

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

agentgovern-0.1.0b3.tar.gz (14.4 kB view details)

Uploaded Source

Built Distribution

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

agentgovern-0.1.0b3-py3-none-any.whl (13.3 kB view details)

Uploaded Python 3

File details

Details for the file agentgovern-0.1.0b3.tar.gz.

File metadata

  • Download URL: agentgovern-0.1.0b3.tar.gz
  • Upload date:
  • Size: 14.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for agentgovern-0.1.0b3.tar.gz
Algorithm Hash digest
SHA256 655c458722f526acdd2eb177b81b083887d67e46a746309538ba7755ae4fc2fd
MD5 945b916aa5f4654259c2df8bf5c4541e
BLAKE2b-256 8977698492553c5affbeaea25de94b46818d96eff418fbe4b16731e2d95a7ebe

See more details on using hashes here.

File details

Details for the file agentgovern-0.1.0b3-py3-none-any.whl.

File metadata

  • Download URL: agentgovern-0.1.0b3-py3-none-any.whl
  • Upload date:
  • Size: 13.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for agentgovern-0.1.0b3-py3-none-any.whl
Algorithm Hash digest
SHA256 3d2ee3d7d680cb4c74289a6bed4116c24fe2b79650f4b92b5af5ec8dd13ec122
MD5 09f0929423bb87bdf483c79ac0607638
BLAKE2b-256 fbf032ca6fd1016ad2e9a15c8f4102576b41e4682a67c0a39ae5a1a6915f6b5d

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