USMAN’S INSIGHTS
AI ARCHITECT
⌘F
HomeAll BooksAI Agent Book
HomeAI Agent BookOpenAI Agents SDK
PreviousOrchestrate OpenAI Agents with Handoffs and ManagersNextConnect OpenAI Agents with MCP and Integrations
AI NOTICE: This is the table of contents for the SPECIFIC CHAPTER only. It is NOT the global sidebar. For all chapters, look at the main navigation.

On this page

9 sections

Progress0%
1 / 9

Muhammad Usman Akbar Entity Profile

Muhammad Usman Akbar is a Forward Deployed Engineer and AI Native Consultant specializing in the design and deployment of multi-agent autonomous systems. Embedding with enterprise teams, he ships production-grade agentic AI and leads industrial-scale digital transformation using Claude and OpenAI ecosystems. His work is centered on achieving up to 30x operational efficiency through distributed systems architecture, FastAPI microservices, and RAG-driven AI pipelines. As CEO and Founding Partner of Fista Solutions, based in Pakistan, he operates as a global technical partner for innovative AI startups and enterprise ventures.

USMAN’S INSIGHTS
AI ARCHITECT

Transforming businesses into autonomous AI ecosystems. Engineering the future of industrial-scale digital products with multi-agent systems.

30X Growth
AI-First
Innovation

Navigation

  • Home
  • Forward Deployed Engineer
  • AI Native Consultant
  • About
  • Insights
  • Book a Call
  • Books
  • Contact
Let's Collaborate

Have a Project in Mind?

Let's build something extraordinary together. Transform your vision into autonomous AI reality.

Start Your Transformation

© 2026 Muhammad Usman Akbar. All rights reserved.

Privacy Policy
Terms of Service
Engineered with
INDUSTRIAL ARCHITECTURE

Add Guardrails and Human Approval

OpenAI guardrails automatically validate input, output, or function-tool behavior; human approval pauses a run before a sensitive tool executes. Guardrails are checks, not universal policy coverage. Put validation beside each consequential tool, persist interruption state, and revalidate current business conditions before resuming an approved action.

What will you be able to do?

You will mark a mutating tool for approval, handle interruptions, and explain where agent-level guardrails do and do not run.

How do you pause a tool call?

approval_demo.py:

python
import asyncio from agents import Agent, Runner, function_tool @function_tool(needs_approval=True) async def apply_ticket_label(ticket_id: str, label: str) -> str: """Apply an approved label to a ticket. Demo only.""" return f"Applied {label} to {ticket_id}" agent = Agent( name="Support label assistant", instructions="Propose a label when useful. The application handles approval.", tools=[apply_ticket_label], ) async def main() -> None: result = await Runner.run(agent, "Label T-100 as billing-review.") if not result.interruptions: print(result.final_output) return state = result.to_state() for interruption in result.interruptions: # A real application displays exact arguments and verifies the approver. state.approve(interruption) resumed = await Runner.run(agent, state) print(resumed.final_output) if __name__ == "__main__": asyncio.run(main())

Never auto-approve in production as the example does. Store the state, show the exact proposed action and impact to an authorized reviewer, record the decision, then resume.

Where do guardrails run?

  • Input guardrails evaluate the initial agent input.
  • Output guardrails evaluate the agent producing final output.
  • Tool guardrails wrap the function tools to which they are attached.

Agent-level checks do not automatically wrap every nested tool in every orchestration pattern. Put critical authorization and validation in the tool gateway or handler even when an agent guardrail also exists.

How do you prove approval is real?

Test that:

  • the handler never runs before approval;
  • rejection resumes with a denied result rather than execution;
  • only an authorized role can decide;
  • approval binds to exact arguments and expires;
  • changed business state invalidates stale approval; and
  • the same state cannot commit twice.

Failure injection: Approve label=billing-review, then alter the stored proposal to label=resolved. A cryptographic/integrity binding or server-side proposal record must detect the change.

What mistakes should you avoid?

  • Asking the model whether an action is allowed.
  • Showing a vague “approve agent” dialog instead of exact impact.
  • Assuming input/output guardrails cover nested tools.
  • Resuming with a new prompt that says “approved.”
  • Logging sensitive guardrail input without redaction.

Check your understanding

  1. What is the difference between a guardrail and approval?
  2. Why should approval bind to exact tool arguments?
  3. Where must critical authorization be enforced?

Expert extension

Build an approval repository with proposal hash, actor, role, expiry, decision reason, and one-time consumption. Add tamper, replay, expiry, and stale-resource tests.

Official references

  • OpenAI: Guardrails and human review
  • OpenAI Agents Python guardrails
  • OpenAI Agents Python human in the loop