Skip to main content
All writing

Integration guides2 min read

Human Approval for OpenAI Agents SDK Tools, From Anywhere

The Agents SDK can pause a run for approval and hand you the interruptions. Delivering them to a person who isn't watching is still your job. Here is a tool that does it.

The OpenAI Agents SDK has approval built in. Mark a function_tool with needs_approval and the run stops at that call: result.interruptions lists what is waiting, you approve or reject each item on the run state, and you resume with Runner.run. You can even serialize the state and resume in another process.

What the SDK can't do is find a person. If the agent runs unattended, someone has to see the question, decide, and get the answer back to the run. The Vibez.now request API covers that: the tool submits a request, it appears on your Requests page and phone, and the tool continues only once you approve.

The agent

The tool awaits ask_human before it runs anything. ask_human comes from vibez_approval.py, a standard-library helper shown in full in the LangChain guide on this blog; copy it next to this file. Set VIBEZ_API_KEY from Settings in Vibez.now.

openai_agents_agent.py
"""An OpenAI Agents SDK agent whose shell tool waits for your approval on Vibez.now.

    pip install openai-agents
    VIBEZ_API_KEY=... OPENAI_API_KEY=... python examples/python/openai_agents_agent.py

Written for openai-agents 0.24 (checked against its docs in November 2026). Don't set a `timeout=` on the tool shorter
than the approval window, or the SDK gives up before the person answers.
"""

import asyncio

from agents import Agent, Runner, function_tool

from vibez_approval import ask_human


@function_tool
async def run_command(command: str) -> str:
    """Run a shell command. A person approves every command before it runs.

    Args:
        command: The shell command to run.
    """
    if not await ask_human(f"Run: {command[:80]}", command, source="openai-agents"):
        return f'Not approved: "{command}" was not run.'
    proc = await asyncio.create_subprocess_shell(
        command, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.STDOUT
    )
    out, _ = await proc.communicate()
    return out.decode()


agent = Agent(
    name="Ops",
    instructions="Use run_command when you need the shell.",
    tools=[run_command],
)


async def main():
    result = await Runner.run(agent, "How much disk space is free here?")
    print(result.final_output)


if __name__ == "__main__":
    asyncio.run(main())

Watch the tool timeout

function_tool accepts timeout= in seconds. If you set one, make it longer than the approval window, or the SDK will give up on the tool while the person is still deciding.

needs_approval or a waiting tool?

needs_approvalWaiting tool
What pausesThe whole run returns with interruptionsOnly this tool call
Delivering the questionYour codeVibez.now: web, iOS, webhooks
Resumingapprove/reject on RunState, then Runner.runAutomatic
Good forApps with their own approval UIUnattended scripts and workers

Unanswered requests expire after the window you choose and come back rejected, and any error counts as not approved, so a broken connection never lets a command through.

Does the OpenAI Agents SDK have built-in tool approval?

Yes. function_tool takes needs_approval, and the run returns interruptions that you approve or reject on the run state before resuming.

Do async tools work with function_tool?

Yes. An async def decorated with function_tool is awaited by the runner, so it can wait for an approval without blocking other work.

What happens if the approval API is unreachable?

ask_human returns False, so the tool reports that the command was not approved and does not run it.

Keep reading