Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pushary_openai_agents-0.1.1.tar.gz (7.1 kB view details)

Uploaded Source

Built Distribution

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

pushary_openai_agents-0.1.1-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

Details for the file pushary_openai_agents-0.1.1.tar.gz.

File metadata

  • Download URL: pushary_openai_agents-0.1.1.tar.gz
  • Upload date:
  • Size: 7.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for pushary_openai_agents-0.1.1.tar.gz
Algorithm Hash digest
SHA256 3825efb8748a7894d054551d73ed828d50d3dfb2d4053d2a2d52ee47ae477ef6
MD5 7bca3d22dceb5398b975095fef583443
BLAKE2b-256 4305a91083452c24b380be851a4f31cfbc05b5826c27e68d1bbe1e7ccc49489c

See more details on using hashes here.

Provenance

The following attestation bundles were made for pushary_openai_agents-0.1.1.tar.gz:

Publisher: release-pypi.yml on aadilghani1/pushary

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pushary_openai_agents-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for pushary_openai_agents-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 cf829b9db0f78f0d8f2137fb6a293b790cc43bac9ad0137f01fe0676a962ed52
MD5 437fd7ccb9324e6dbd7de28872b926e8
BLAKE2b-256 d11c0c8f923683323f7714f39b594f44a5bd071698760efd489f1c34f50fdd24

See more details on using hashes here.

Provenance

The following attestation bundles were made for pushary_openai_agents-0.1.1-py3-none-any.whl:

Publisher: release-pypi.yml on aadilghani1/pushary

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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