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
- Your agent decides to call a tool (e.g.
send_payment) - Before execution, Forge checks the action against your policies
- If approved: the tool runs normally
- 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dd030a7455f5f83d09885dd3315954a0ccb1b330533abb2a8c5d03712b1e5101
|
|
| MD5 |
b8abdd1e51708699a7203752d1f27cae
|
|
| BLAKE2b-256 |
9f983db94d506fb931324016bd4dc28350876147a846ca6fb25003603ba82ea0
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7d7a8475a3cf4fdaf77a72d2f96c20991f75905a7d4c2e443348f884cf1f9e38
|
|
| MD5 |
daa0a86e7b526396da268765eab07ea7
|
|
| BLAKE2b-256 |
11637ad02bb16e407b485c5bb1fb5eee3a492d311789b4caadcca66d5c0d1fa7
|