Skip to main content

Forge Verify guardrail for OpenAI Agents SDK — verify every tool call before execution

Project description

forge-openai

Forge Verify guardrail for the OpenAI Agents SDK. Verifies every AI agent tool call against your policies before execution.

Install

pip install forge-openai

Quick Start

import os
from agents import Agent, Runner, function_tool
from forge_openai import forge_tool_guardrail, forge_protect

os.environ["VERITERA_API_KEY"] = "vt_live_..."
os.environ["OPENAI_API_KEY"] = "sk-..."

# Define your tools
@function_tool
def send_payment(amount: float, recipient: str) -> str:
    """Send a payment to a recipient."""
    return f"Sent ${amount} to {recipient}"

@function_tool
def delete_record(record_id: str) -> str:
    """Delete a database record."""
    return f"Deleted {record_id}"

@function_tool
def read_balance() -> str:
    """Check account balance."""
    return "Balance: $50,000"

# Protect all tools with Forge — one line
agent = Agent(
    name="finance-bot",
    instructions="You help with financial operations.",
    tools=forge_protect(
        send_payment, delete_record, read_balance,
        policy="finance-controls",
        skip_actions=["read_balance"],  # read-only tools don't need verification
    ),
)

# Run the agent — Forge checks every tool call automatically
result = await Runner.run(agent, "Send $500 to vendor@acme.com")

How It Works

  1. Your agent decides to call a tool (e.g. send_payment)
  2. Before execution, Forge checks the action against your policies
  3. If approved: the tool runs normally
  4. If denied: the LLM receives a denial message and can explain why to the user

No tool ever executes without verification. Every decision is logged with a cryptographic proof.

Per-Tool Guardrail

from forge_openai import forge_tool_guardrail

guardrail = forge_tool_guardrail(policy="email-controls")

@function_tool(tool_input_guardrails=[guardrail])
def send_email(to: str, subject: str, body: str) -> str:
    """Send an email."""
    return f"Email sent to {to}"

Full Control

from forge_openai import ForgeGuardrail

forge = ForgeGuardrail(
    api_key="vt_live_...",
    agent_id="prod-finance-bot",
    policy="finance-controls",
    fail_closed=True,
    skip_actions=["read_balance", "get_time"],
    on_blocked=lambda action, reason, result: print(f"BLOCKED: {action}{reason}"),
    on_verified=lambda action, result: print(f"APPROVED: {action}"),
)

agent = Agent(
    name="finance-bot",
    tools=forge.protect(send_payment, delete_record),
    input_guardrails=[forge.input_guardrail()],  # also screen agent input
)

Environment Variables

Variable Description
VERITERA_API_KEY Your Forge API key (starts with vt_live_ or vt_test_)

License

MIT — Veritera AI

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

forge_openai-0.1.0.tar.gz (5.3 kB view details)

Uploaded Source

Built Distribution

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

forge_openai-0.1.0-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

Details for the file forge_openai-0.1.0.tar.gz.

File metadata

  • Download URL: forge_openai-0.1.0.tar.gz
  • Upload date:
  • Size: 5.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.1

File hashes

Hashes for forge_openai-0.1.0.tar.gz
Algorithm Hash digest
SHA256 dd030a7455f5f83d09885dd3315954a0ccb1b330533abb2a8c5d03712b1e5101
MD5 b8abdd1e51708699a7203752d1f27cae
BLAKE2b-256 9f983db94d506fb931324016bd4dc28350876147a846ca6fb25003603ba82ea0

See more details on using hashes here.

File details

Details for the file forge_openai-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: forge_openai-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.1

File hashes

Hashes for forge_openai-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7d7a8475a3cf4fdaf77a72d2f96c20991f75905a7d4c2e443348f884cf1f9e38
MD5 daa0a86e7b526396da268765eab07ea7
BLAKE2b-256 11637ad02bb16e407b485c5bb1fb5eee3a492d311789b4caadcca66d5c0d1fa7

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