← Back to Learn
sdkguardrailstutorialagent-safety

OpenAI Agents SDK Safety Integration

Authensor

The OpenAI Agents SDK provides a structured way to build agents with tool use, handoffs, and guardrails. Authensor's OpenAI adapter adds external policy enforcement, content scanning, and cryptographic audit trails on top of the SDK's built-in safety features.

Installation

pip install authensor-openai

The Python adapter works with the OpenAI Agents SDK's tool and guardrail extension points.

Tool Safety Wrapping

Wrap your agent's tools with Authensor's safety layer. Every tool call passes through policy evaluation before execution.

from authensor_openai import wrap_tools

safe_tools = wrap_tools(
    tools=my_tools,
    authensor_url="https://your-authensor-instance.com",
    api_key="your-api-key",
    agent_id="openai-agent-1",
)

The wrapper submits each tool call as an action envelope, receives a policy decision, and either proceeds with execution or returns a denial message to the agent.

Guardrail Integration

The OpenAI Agents SDK supports custom guardrails that run on input and output. Register Authensor's content scanner as a guardrail:

from authensor_openai import AegisGuardrail

agent = Agent(
    tools=safe_tools,
    input_guardrails=[AegisGuardrail(authensor_client)],
    output_guardrails=[AegisGuardrail(authensor_client)],
)

Aegis scans both user input and model output for prompt injection, harmful content, and PII leakage.

Handoff Safety

Multi-agent systems using the SDK's handoff feature need safety checks at handoff boundaries. Authensor's adapter intercepts handoffs and evaluates whether the transferring agent is authorized to delegate to the target agent with the given context.

Audit Trail

Every tool call, guardrail evaluation, and handoff is logged as an immutable audit receipt. This gives you a complete record of what each agent did, which policies governed it, and what safety checks ran.

Combining with Built-in Guardrails

Use the SDK's built-in guardrails for fast, model-specific checks and Authensor for organization-wide policy enforcement. The two layers complement each other: built-in guardrails handle model-specific safety, Authensor handles organizational policies and compliance requirements.

Keep learning

Explore more guides on AI agent safety, prompt injection, and building secure systems.

View All Guides