Skip to content

AxmeAI/openai-agents-human-approval

Repository files navigation

OpenAI Agents Human Approval

OpenAI Agents SDK can pause for approval. But who reminds the human? Who escalates? AXME adds the missing pieces.

Alpha - Built with AXME (AXP Intent Protocol). cloud.axme.ai - contact@axme.ai


The Problem

OpenAI Agents SDK lets you build powerful agents with tool use and handoffs. But when your agent processes a $2,500 refund that needs finance approval before issuing - the SDK has no built-in way to pause, notify a human, remind after 5 minutes, escalate after 30, and resume when approved.

OpenAI agent processes refund request
  -> Determines eligibility (structured, reliable, great!)
  -> Now what? Who approves this before the money moves?

Options without AXME:
  1. Poll a database in a loop? (fragile, no reminders, crashes lose state)
  2. Send a Slack message and hope? (no timeout, no escalation, no audit trail)
  3. Build webhook + queue + DB + reminder system? (weeks of infrastructure)

Open issues confirm this gap:


The Solution

# OpenAI Agents SDK does the reasoning
from agents import Agent, Runner

refund_agent = Agent(name="Refund Processor", instructions="Analyze refund eligibility...")
result = Runner.run_sync(refund_agent, refund_prompt)

# AXME handles the human gate
intent_id = client.send_intent({
    "intent_type": "intent.finance.refund_approval.v1",
    "to_agent": "agent://myorg/production/openai-refund-processor",
    "payload": {"refund_id": "REF-2026-3391", "eligibility": result.final_output},
})
approval = client.wait_for(intent_id)  # reminder in 5 min, timeout in 1h

OpenAI does the reasoning. AXME does the waiting.


Quick Start

pip install axme openai-agents
export AXME_API_KEY="your-key"   # Get one: axme login
export OPENAI_API_KEY="sk-..."   # For OpenAI Agents LLM calls
from agents import Agent, Runner
from axme import AxmeClient, AxmeClientConfig
import os

# 1. OpenAI Agents: process refund
refund_agent = Agent(
    name="Refund Processor",
    instructions="Analyze refund eligibility based on order history and policy.",
)

result = Runner.run_sync(refund_agent, "Refund REF-2026-3391: $2499.99 for service_outage")
print(f"Agent assessment: {result.final_output}")

# 2. AXME: human approval before issuing refund
client = AxmeClient(AxmeClientConfig(api_key=os.environ["AXME_API_KEY"]))
intent_id = client.send_intent({
    "intent_type": "intent.finance.refund_approval.v1",
    "to_agent": "agent://myorg/production/openai-refund-processor",
    "payload": {
        "refund_id": "REF-2026-3391",
        "amount": 2499.99,
        "assessment": result.final_output,
    },
})

# Agent suspends. Reminder in 5 min. Timeout in 1 hour.
approval = client.wait_for(intent_id)
print(f"Decision: {approval['status']}")

Before / After

Before: OpenAI Agents with manual polling

# OpenAI agent processes the refund...
result = Runner.run_sync(refund_agent, refund_prompt)

# ...but how does finance approve it?
print(result.final_output)        # Print to console?
input("Press Enter to approve...")  # Block the process?

# No reminders. No timeout. No escalation.
# If the approver is in a meeting, the refund is stuck forever.

After: AXME adds reminders and escalation

result = Runner.run_sync(refund_agent, refund_prompt)

intent_id = client.send_intent({
    "intent_type": "intent.finance.refund_approval.v1",
    "to_agent": "agent://myorg/production/openai-refund-processor",
    "payload": {"refund_id": "REF-2026-3391", "assessment": result.final_output},
})
approval = client.wait_for(intent_id)
# Reminder in 5 min. Escalation in 30 min. Timeout in 1h.

What Each Component Does

Component Role Framework
agent_openai.py Process refund with OpenAI Agents SDK OpenAI Agents
agent.py Simplified agent (no LLM, tests AXME flow) AXME SDK
initiator.py Send refund intent, observe lifecycle AXME SDK
scenario.json Scenario definition (agent + human approval) AXME CLI

OpenAI Agents SDK does the thinking. AXME does the infrastructure.


How It Works

+-----------+  send_intent()   +----------------+  process    +-----------+
|           | ---------------> |                | ----------> |           |
| Initiator |                  |   AXME Cloud   |             |  OpenAI   |
|           | <- wait_for() -- |   (platform)   | <- result   |  Agents   |
|           |                  |                |             |           |
|           |                  |  WAITING for   |             +-----------+
|           |                  |  human approval|
|           |                  |                |  approve    +-----------+
|           |                  |                | <---------- |           |
|           | <- COMPLETED --- |  - remind 5m   |             |  Finance  |
|           |                  |  - timeout 1h  |             |   Team    |
+-----------+                  +----------------+             +-----------+

Run the Full Example

Prerequisites

curl -fsSL https://raw.githubusercontent.com/AxmeAI/axme-cli/main/install.sh | sh
axme login
pip install -r requirements.txt

Terminal 1 - submit the scenario

axme scenarios apply scenario.json

Terminal 2 - start the agent

# macOS
cat ~/Library/Application\ Support/axme/scenario-agents.json | grep -A2 openai-refund-demo

# Linux
cat ~/.config/axme/scenario-agents.json | grep -A2 openai-refund-demo
# Simplified agent (no LLM required)
AXME_API_KEY=<agent-key> python agent.py

# Full OpenAI Agents SDK agent (requires OPENAI_API_KEY)
AXME_API_KEY=<agent-key> OPENAI_API_KEY=sk-... python agent_openai.py

Terminal 1 - approve

axme tasks approve <intent_id>

Verify

axme intents get <intent_id>
# lifecycle_status: COMPLETED

Related


Built with AXME (AXP Intent Protocol).

About

OpenAI Agents SDK can pause for approval. But who reminds the human? Who escalates? AXME adds the missing pieces.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages