[ ABORT TO HUD ]
SEQ. 1
SEQ. 2
SEQ. 3
SEQ. 4
SEQ. 5
SEQ. 6
SEQ. 7

OpenAI Agents SDK

👥 Multi-Agent Systems15 min100 BASE XP⌨ HANDS-ON LAB

Production Agent Framework from OpenAI

The OpenAI Agents SDK (open-source, Python) provides a lightweight, opinionated framework for building production agents with core primitives: Agents, Handoffs, Guardrails, and Tracing. In April 2026, it introduced Native Sandboxing (isolated filesystems and shell execution) and the Long-Horizon Harness for multi-step workflows. Unlike heavier frameworks, it embraces minimal abstraction — just enough structure to build reliable systems.

Core Primitives

PrimitivePurposeKey Concept
AgentA configured LLM with instructions, tools, and modelThe basic unit — wraps a system prompt + tool set
HandoffTransfer control from one agent to anotherTriage agent routes to specialized agents (billing, support, etc.)
GuardrailInput/output validation that runs in parallel with the agentCatches policy violations, PII leaks, or off-topic responses before they reach the user
TracingBuilt-in observability for every agent runAutomatic logging of LLM calls, tool executions, handoffs, and guardrail checks

Handoffs Pattern

The Handoffs pattern is the SDK's signature feature. A triage agent evaluates the user's request and hands off to a specialist agent with full context transfer:

from agents import Agent, handoff, Runner

billing_agent = Agent(
    name="Billing Specialist",
    instructions="Handle billing inquiries. Access the billing database.",
    tools=[lookup_invoice, process_refund]
)

tech_agent = Agent(
    name="Technical Support",
    instructions="Debug technical issues. Access logs and documentation.",
    tools=[search_docs, check_status]
)

triage_agent = Agent(
    name="Triage",
    instructions="Route the customer to the right specialist.",
    handoffs=[handoff(billing_agent), handoff(tech_agent)]
)

# Agents-as-Tools: use an agent as a tool (returns result to caller)
triage_agent_v2 = Agent(
    name="Coordinator",
    tools=[billing_agent.as_tool(), tech_agent.as_tool()]
)

result = await Runner.run(triage_agent, "I was double-charged")
# → Triage hands off to Billing Specialist automatically

Guardrails System

Guardrails run in parallel with the agent. If a guardrail trips, the agent's response is blocked before reaching the user:

  • Input Guardrails: Validate user messages (block jailbreaks, detect PII)
  • Output Guardrails: Validate agent responses (check for policy violations, hallucinated data)

Handoffs vs Agents-as-Tools

PatternControl FlowBest For
HandoffControl transfers TO the new agent (caller loses control)Full delegation — "you handle this"
Agent-as-ToolCaller invokes agent, gets result backSub-task — "do this and report back"
💡 Key Insight: The Agents SDK is intentionally minimal. It doesn't try to be a graph engine or workflow orchestrator — it focuses on the agent-to-agent handoff pattern and built-in guardrails, making it ideal for customer-facing multi-agent support systems.
⌨ HANDS-ON LABRun Your First Agents SDK Agent
⭐ +150 XP

Minimal abstraction, maximum speed. Install the OpenAI Agents SDK, set your key, and execute a one-file agent with Runner.run_sync.

1Install the openai-agents package from PyPI.
2Export your OpenAI API key so the SDK can authenticate.
3Run a hello-world agent script (Agent + Runner.run_sync from the agents package).
lab-sandbox — simulated environment
INFINITY LAB SANDBOX v2.6 — simulated shell
Type the command for the current objective. Helpers: "hint", "solution", "clear".
$
OBJECTIVE 1 / 3 — type "hint" if stuck
SYNAPSE VERIFICATION
QUERY 1 // 3
What is the key difference between a 'Handoff' and 'Agent-as-Tool' in the OpenAI Agents SDK?
There is no difference
Handoff transfers full control to the new agent; Agent-as-Tool invokes the agent and returns the result to the caller
Agent-as-Tool is faster
Handoff only works with GPT-5
OpenAI Agents SDK Tutorial | Multi-Agent Systems — AI Agents Academy