Human-in-the-loop for the OpenAI Agents SDK: a function tool that asks a real human on their phone and blocks on a fail-closed answer.
Project description
pushary-openai-agents
Human-in-the-loop for the OpenAI Agents SDK (Python). A function tool that asks a real human to approve, delivered to their phone, and blocks on a fail-closed answer.
Requires the Pushary Partner plan.
Install
pip install pushary-openai-agents
Set PUSHARY_API_KEY (get it in your dashboard).
Connect a phone once
from pushary_openai_agents import connect
link = connect("user_123") # show this to your end-user; one tap connects their phone
The tool
from agents import Agent, Runner
from pushary_openai_agents import pushary_tool
agent = Agent(
name="Support",
instructions="Call ask_human before issuing any refund.",
tools=[pushary_tool("user_123")],
)
result = await Runner.run(agent, "Refund order 5?")
When the model calls the tool, Pushary delivers the question to that user's phone and
the call blocks until they answer. The tool returns a fail-closed instruction. The
external_id is bound when you build the tool, never taken from the model, so a
prompt-injected agent cannot ask the wrong person.
Durable approvals
For a wait longer than a request can hold, drive your own flow off ask_human with a
callback_url on decisions.create and resolve the signed callback:
from pushary_openai_agents import resolve_pushary_callback, SIGNATURE_HEADER
def callback(request):
cb = resolve_pushary_callback(request.body, request.headers.get(SIGNATURE_HEADER), SECRET)
if not cb:
return ("bad signature", 401)
# look up your parked run by cb["correlationId"], approve/reject, resume
return ("ok", 200)
For TypeScript, use npm i @pushary/openai-agents.
API
connect(external_id, *, api_key=None, base_url=None)— enroll an end-user's phone.pushary_tool(external_id, *, name="ask_human", ...)— an OpenAI Agents function tool bound to that user.ask_human(question, *, external_id, type="confirm", ...)— blocking, returns the decision dict.resolve_pushary_callback(raw_body, signature, secret)— verify + parse a callback for the durable path.describe_answer(type, result),is_affirmative(answer),deterministic_key(parts),SIGNATURE_HEADER.
License
MIT
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 pushary_openai_agents-0.1.0.tar.gz.
File metadata
- Download URL: pushary_openai_agents-0.1.0.tar.gz
- Upload date:
- Size: 6.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9e6ca374d6ea6ed549facb614cc9c1441b805177e769b1c61aa2f6818786d916
|
|
| MD5 |
759529f3ca9bc71c40b646f9bedbde75
|
|
| BLAKE2b-256 |
62b7293f9cdb9c7766f57485fef4b56e138abf753d4e0ef7f764c2f7f95633e3
|
File details
Details for the file pushary_openai_agents-0.1.0-py3-none-any.whl.
File metadata
- Download URL: pushary_openai_agents-0.1.0-py3-none-any.whl
- Upload date:
- Size: 5.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ce51ca2e77f252cc950cb71dfdedcae8948258a9389ca917cdd7a309b655c90e
|
|
| MD5 |
26b341888e40e1e97ffcfff19d9b2a59
|
|
| BLAKE2b-256 |
ef3a0c2ee807833f63e9acfcd5110868830b33874e5c46d13938ab45f5132278
|