OpenAI Agents SDK Integration
ShadowAudit gates function tools defined with the OpenAI Agents SDK by wrapping them before they are registered with an agent.
Installation
pip install "shadowaudit[openai-agents]"
Wrapping a function tool
from shadowaudit import ShadowAuditTool
from agents import function_tool
@function_tool
def run_shell(command: str) -> str:
"""Execute a shell command."""
import subprocess
return subprocess.check_output(command, shell=True, text=True)
safe_shell = ShadowAuditTool(
tool=run_shell,
agent_id="ops-agent",
capability="shell.execute",
policy_path="policies/shell.yaml"
)
Using with an agent
from agents import Agent, Runner
agent = Agent(
name="OpsAgent",
instructions="You help manage infrastructure.",
tools=[safe_shell]
)
result = Runner.run_sync(agent, "List files in /tmp")
Wrapping multiple tools
from shadowaudit import ShadowAuditTool
tools = [
ShadowAuditTool(
tool=read_file,
agent_id="ops-agent",
capability="filesystem.read",
policy_path="policies/ops.yaml"
),
ShadowAuditTool(
tool=write_file,
agent_id="ops-agent",
capability="filesystem.write",
policy_path="policies/ops.yaml"
),
ShadowAuditTool(
tool=run_shell,
agent_id="ops-agent",
capability="shell.execute",
policy_path="policies/ops.yaml"
),
]
Scanning for ungated tools
shadowaudit check ./src --framework openai_agents