OpenAI Agents

Add a guardrail that screens tool calls through the safety shield.

Step 1: Set up A2A TrustGate

Run the quickstart wizard — prints API key setup, MCP config, CLAUDE.md snippet, and wrapper generators:

npx a2a-trustgate quickstart

# Then run the interactive setup:
npx a2a-trustgate setup

Step 2: Install and integrate

pip install openai-agents requests

import requests
from agents import function_tool

def safety_check(cmd):
    r = requests.post("https://a2ainfrastructure.com/v1/evaluate",
        headers={"Authorization": "Bearer " + API_KEY},
        json={"command": cmd})
    return r.json()["decision"] == "allow"

@function_tool
def run_shell(cmd: str) -> str:
    if not safety_check(cmd):
        return "Blocked by TrustGate"
    return subprocess.run(cmd, shell=True, capture_output=True).stdout
Help

Help

Need help? Here are some quick links: