A real human approval tool for the OpenAI Agents SDK
Wrap any @function_tool your agent can call, and the consequential ones stop for a named person before they run. The Runner picks back up the moment it's cleared, and no tool fires without a short-lived credential it can only get after sign-off.
The problem
Handing an agent real tools in the OpenAI Agents SDK takes about four lines. You decorate issue_refund with @function_tool, drop it in the tools list, and the Runner loops until it's done. Then the model decides, on its own, when to call it. One confused turn and refund.create runs for £4,200 instead of £42, or content.publish ships a draft to your live account, and you find out from the RunResult after the fact.
The SDK does have an approval path, but it's built for you, not for a person. needs_approval on a hosted MCP tool pauses the run and hands the decision back to your code; input guardrails run your validation, not a human's judgement. Neither one routes a held refund to a named reviewer, waits for them to actually sign it, or leaves a record you can show later. So teams quietly pull the risky tools off the agent, which is the opposite of why they picked up the Agents SDK.
How ClearedBy handles it
-
01
Guard the tool you're worried about
Pass the consequential @function_tool through guard(), or have it call request_clearance as its first line. It's still an ordinary function tool, so the Runner, your handoffs and the rest of your tools don't change.
-
02
Policy decides in milliseconds
When the model calls the tool, your policy reads the action and its arguments. A £30 refund to a known order clears straight through and the run never pauses. A big amount, a new payee, a publish to a live channel: held, and sent to a named reviewer.
-
03
A person clears it, the Runner waits
The held call lands in a fast keyboard-driven queue, or Slack, or someone's phone. They approve, reject, or send it back. The guarded call doesn't return until there's a verdict, so the run pauses on exactly that turn and nowhere else.
-
04
Every verdict is sealed to whoever signed it
Auto-cleared, approved or rejected, each call writes to a tamper-evident, hash-linked record bound to the person who signed it with a passkey. When someone asks who approved that payout, the answer is in the ledger, not a Slack thread.
import os, httpx
from agents import function_tool
GATE = "https://app.clearedby.com/v1/gate"
AUTH = {"Authorization": f"Bearer {os.environ['CLEAREDBY_API_KEY']}"}
@function_tool
def issue_refund(order: str, amount: float) -> str:
"""Refund an order — gated before it runs."""
r = httpx.post(GATE, headers=AUTH, json={
"action": "refund.create",
"params": {"order": order, "amount": amount},
}).json()
if r["status"] != "cleared": # "pending" => a human is deciding
return f"Refund {r['status']} — not run."
return stripe.refunds.create(order=order, amount=amount)
FAQ
Does this cover the Python SDK and the TypeScript one?
Both. ClearedBy is a standard MCP tool and a thin client, so you can guard a @function_tool in Python or a tool in TypeScript and the Runner executes it the same way it did before.
How is this different from the SDK's own needs_approval and guardrails?
needs_approval and guardrails run your code and resolve in-process; they can't pause for a named human or leave a signed record. ClearedBy routes the held call to a real reviewer, waits for their verdict, and seals it. Keep guardrails for automated checks and use ClearedBy for the calls that need a person on the hook.
Can the model retry or jailbreak its way past the gate?
No. The tool only receives a short-lived credential once a human clears it, so a retry, a reworded prompt or a clever excuse still lands on a hold. The gate doesn't fail open.
What happens with handoffs and sub-agents?
Guard the tool, not the agent. Any sub-agent the Runner hands off to hits the same gate the instant it calls that guarded tool, so you don't wire approval in per agent.
Can I try the openai-agents-sdk-approval-tool without blocking my agent?
Yes. Start in shadow mode with no card. The guard runs every tool as normal and logs what your policy would have held, so you can read the real hold rate before you switch enforcement on.
Related use cases
Let your agents run. Inside the rules you set.
Wrap any @function_tool your agent can call, and the consequential ones stop for a named person before they run. The Runner picks back up the moment it's cleared, and no tool fires without a short-lived credential it can only get after sign-off.