Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/microsoft/agent-governance-toolkit/llms.txt

Use this file to discover all available pages before exploring further.

AGT works with any agent framework through two integration paths: the universal govern() wrapper — which adds policy enforcement in two lines with zero framework knowledge — or framework-specific kernel adapters that unlock deeper hooks like tool call interception, memory write logging, and sub-agent delegation tracking. Every adapter intercepts calls before they reach the model, making denied actions structurally impossible rather than merely discouraged.

Integration Paths at a Glance

Integration TypeHow It WorksBest For
govern() wrapperWraps any callable; evaluates YAML policy on every callAny framework, minimal setup
Kernel adapter (e.g. LangChainKernel)Framework-aware proxy with pre/post hooksLangChain, CrewAI, AutoGen, OpenAI, Gemini
Middleware (MAF pattern)Composable async middleware chainMicrosoft Agent Framework
PluginInstalled into the framework’s plugin systemDify, Claude Code, GitHub Copilot CLI
All adapters inherit from BaseIntegration in agent_os/integrations/base.py and expose the same three lifecycle hooks:
HookWhen It FiresWhat It Does
pre_execute()Before the LLM callEnforces token limits, timeout, blocked patterns
Tool interceptionOn each tool/function callValidates against allowed_tools / blocked_patterns
post_execute()After the LLM responseDrift detection, output scanning, audit entry
Violations raise PolicyViolationError.

The Two Integration Patterns

Pattern 1: Universal govern() Wrapper

The govern() wrapper works with any framework. It evaluates a YAML policy on every call and raises GovernanceDenied if the action is blocked.
from agentmesh.governance import govern

safe_tool = govern(my_tool, policy="policy.yaml")  # every call checked, logged, enforced
Combined with a policy file:
# policy.yaml
apiVersion: governance.toolkit/v1
name: production-policy
default_action: allow
rules:
  - name: block-destructive
    condition: "action.type in ['drop', 'delete', 'truncate']"
    action: deny
    description: "Destructive operations require human approval"

  - name: require-approval-for-send
    condition: "action.type == 'send_email'"
    action: require_approval
    approvers: ["security-team"]
>>> safe_tool(action="read", table="users")
{'table': 'users', 'rows': 42}

>>> safe_tool(action="drop", table="users")
GovernanceDenied: Action denied by policy rule 'block-destructive':
  Destructive operations require human approval

Pattern 2: Framework-Specific Kernel Adapters

Kernel adapters provide deeper integration. The pattern is always: create a policy → create a kernel → wrap the framework object → use the governed object as normal.
┌─────────────┐     ┌──────────────┐     ┌───────────────┐
│  Your Code   │ ──► │  Kernel      │ ──► │  Framework    │
│              │ ◄── │  (governance │ ◄── │  (OpenAI,     │
│              │     │   layer)     │     │   LangChain…) │
└─────────────┘     └──────────────┘     └───────────────┘
                     pre_execute()
                     tool interception
                     post_execute()
                     drift detection
                     audit log

Framework Examples

Install the framework package alongside the kernel:
pip install agent-os-kernel openai
from openai import OpenAI
from agent_os.integrations import OpenAIKernel, GovernancePolicy

client = OpenAI()
assistant = client.beta.assistants.create(
    name="analyst",
    model="gpt-4o",
    tools=[{"type": "code_interpreter"}],
)

# 1. Define policy
policy = GovernancePolicy(
    max_tokens=4096,
    max_tool_calls=5,
    allowed_tools=["code_interpreter"],
    blocked_patterns=["rm -rf", "DROP TABLE"],
    log_all_calls=True,
)

# 2. Create kernel
kernel = OpenAIKernel(policy=policy)

# 3. Wrap — returns a GovernedAssistant
governed = kernel.wrap(assistant, client)

# 4. Use exactly like before
thread = client.beta.threads.create()
client.beta.threads.messages.create(thread.id, role="user", content="Summarize Q3 revenue")
run = governed.run(thread.id)
Inspect execution state at any time:
ctx = governed.get_context()
print(ctx.call_count)    # number of LLM round-trips
print(ctx.total_tokens)  # cumulative token usage
print(ctx.tool_calls)    # list of intercepted tool calls

Full Framework Support Table

FrameworkIntegration Type
Microsoft Agent FrameworkNative Middleware
Semantic KernelNative (.NET + Python)
AutoGenAdapter
LangGraph / LangChainAdapter
CrewAIAdapter
OpenAI Agents SDKMiddleware
Claude CodeGovernance plugin package
Google ADKAdapter
LlamaIndexMiddleware
HaystackPipeline
MastraAdapter
DifyPlugin
Azure AI FoundryDeployment Guide
GitHub Copilot CLIGovernance installer
All 22+ adapters live in agent-governance-python/agent-os/src/agent_os/integrations/. When your framework isn’t listed, extend BaseIntegration — the custom adapter section in Tutorial 03 walks through the minimal implementation.

Common GovernancePolicy Patterns

readonly_policy = GovernancePolicy(
    name="read-only",
    max_tokens=4096,
    max_tool_calls=10,
    allowed_tools=["search", "retrieve", "summarize"],
    blocked_patterns=[
        ("DELETE", "substring"),
        ("DROP", "substring"),
        ("INSERT", "substring"),
        ("UPDATE", "substring"),
        ("rm ", "substring"),
        ("write_file", "substring"),
    ],
    require_human_approval=False,
    log_all_calls=True,
)
Policies serialize to YAML for version-controlled policy-as-code:
# Save
production_policy.to_yaml("policies/production.yaml")

# Load
policy = GovernancePolicy.from_yaml("policies/production.yaml")

# Diff two policies
changes = production_policy.diff(dev_policy)
for field, (prod_val, dev_val) in changes.items():
    print(f"  {field}: {prod_val}{dev_val}")

Multi-Framework Unified Governance

A real-world pattern: one policy across multiple frameworks with a centralized violation handler.
from agent_os.integrations import (
    GovernancePolicy,
    OpenAIKernel,
    LangChainKernel,
    AnthropicKernel,
    GovernanceEventType,
)

# One policy for the whole system
policy = GovernancePolicy.from_yaml("policies/production.yaml")

# Centralized violation handler
def on_violation(data):
    send_to_siem(data)
    page_on_call(data["agent_id"], data["reason"])

# OpenAI assistant
oai_kernel = OpenAIKernel(policy=policy)
oai_kernel.on(GovernanceEventType.POLICY_VIOLATION, on_violation)
governed_assistant = oai_kernel.wrap(assistant, client)

# LangChain RAG chain
lc_kernel = LangChainKernel(policy=policy)
lc_kernel.on(GovernanceEventType.POLICY_VIOLATION, on_violation)
governed_chain = lc_kernel.wrap(rag_chain)

# Anthropic summarizer
anth_kernel = AnthropicKernel(policy=policy)
anth_kernel.on(GovernanceEventType.POLICY_VIOLATION, on_violation)
governed_claude = anth_kernel.wrap(anthropic_client)
Every call across all three frameworks is governed by the same policy, violations route to the same handler, and the audit trail is unified.

Build docs developers (and LLMs) love