Skip to main content

Trust & governance layer for OpenAI Agents SDK — policy enforcement, trust-gated handoffs, and hash-chained audit trails

Project description

agentmesh-openai-agents-trust

Trust & governance layer for the OpenAI Agents SDK. Adds policy enforcement, trust-gated handoffs, and tamper-evident audit trails using native SDK guardrails and hooks.

Built by AgentMesh — the open-source trust layer for multi-agent systems. Similar integrations merged into Dify (65K ⭐), LlamaIndex (47K ⭐), and Microsoft Agent-Lightning (15K ⭐).

Install

pip install agentmesh-openai-agents-trust

Quick Start

from agents import Agent, Runner
from openai_agents_trust import (
    trust_input_guardrail,
    policy_input_guardrail,
    GovernanceHooks,
    TrustGuardrailConfig,
    PolicyGuardrailConfig,
    TrustScorer,
    GovernancePolicy,
    AuditLog,
)

# Shared governance state
scorer = TrustScorer()
audit = AuditLog()
policy = GovernancePolicy(
    name="production",
    max_tool_calls=20,
    blocked_patterns=[r"DROP TABLE", r"rm -rf", r"eval\("],
    min_trust_score=0.7,
)

# Create guardrails
trust_config = TrustGuardrailConfig(scorer=scorer, min_score=0.7, audit_log=audit)
policy_config = PolicyGuardrailConfig(policy=policy, audit_log=audit)

# Attach to agents
agent = Agent(
    name="researcher",
    instructions="You are a research assistant.",
    input_guardrails=[
        trust_input_guardrail(trust_config),
        policy_input_guardrail(policy_config),
    ],
)

# Run with governance hooks
result = await Runner.run(
    agent,
    input="Analyze this data",
    run_config=RunConfig(hooks=GovernanceHooks(policy=policy, scorer=scorer, audit_log=audit)),
)

# Verify audit integrity
print(f"Audit entries: {len(audit)}")
print(f"Chain valid: {audit.verify_chain()}")

Trust-Gated Handoffs

from openai_agents_trust import trust_gated_handoff

billing_agent = Agent(name="billing", instructions="Handle billing.")
support_agent = Agent(name="support", instructions="Handle support.")

triage = Agent(
    name="triage",
    handoffs=[
        trust_gated_handoff(billing_agent, scorer=scorer, min_score=0.8),
        trust_gated_handoff(support_agent, scorer=scorer, min_score=0.6),
    ],
)

Features

Feature SDK Hook Description
Trust Guardrail InputGuardrail Blocks agents below trust threshold
Policy Guardrail InputGuardrail Enforces blocked patterns, tool limits
Content Guardrail OutputGuardrail Validates output against policies
Governance Hooks RunHooksBase Tracks tools, audits handoffs, scores trust
Trust-Gated Handoff is_enabled Disables handoffs to untrusted agents
hash-chain Audit Tamper-evident chain of all decisions

License

MIT

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

agentmesh_openai_agents_trust-3.5.0.tar.gz (11.7 kB view details)

Uploaded Source

Built Distribution

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

agentmesh_openai_agents_trust-3.5.0-py3-none-any.whl (12.8 kB view details)

Uploaded Python 3

File details

Details for the file agentmesh_openai_agents_trust-3.5.0.tar.gz.

File metadata

File hashes

Hashes for agentmesh_openai_agents_trust-3.5.0.tar.gz
Algorithm Hash digest
SHA256 66f3e2d7c85147146d4265502e07d15fb8bac9c5e760d9e7ccd1f6a2e43e78b5
MD5 6599e94a562750d7dce2ad64f789d556
BLAKE2b-256 0f44e932370f799ae2ebe9333d50528a4eb4c4e69f45b50e4bb134e6ace10a0d

See more details on using hashes here.

File details

Details for the file agentmesh_openai_agents_trust-3.5.0-py3-none-any.whl.

File metadata

File hashes

Hashes for agentmesh_openai_agents_trust-3.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a7330ad62d9331928c590f24f6fc699bd4a34cd8e78a5574ef928d72babc43e5
MD5 6a7b8c3f81eebb77d148dbbdd3116192
BLAKE2b-256 c83da56bfbcdddbc0f0bec80fc45cb7c920a7daacd23474e8ba2acc236c447cc

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