Phase 14: Agent Engineering

OpenAI Agents SDK: Handoffs, Guardrails, Tracing

OpenAI Agents SDK is the lightweight multi-agent framework built on the Responses API. Five primitives: Agent, Handoff, Guardrail, Session, Tracing. Handoffs are tools named transferto . Guardrails trip on input or output. Tracing is on by default. Name the five primitives of the OpenAI Agents SDK. Explain handoffs: why they are modeled as tools, what name shape the model sees, and how context transfers. Distinguish input guardrails, output guardrails, and tool guardrails; explain runinparallel vs blocking mode. Implement a stdlib runtime with handoffs + guardrails + span-style tracing. Agents that cannot delegate cleanly end up stuffing everything into one prompt. Agents without guardrails ship PII, policy-violating output, or loop forever. OpenAI's SDK codifies the three primitives that make multi-agent work tractable. Agent. LLM + instructions + tools + handoffs. Handoff. Delegation to another agent. Represented to the model as a tool named transferto . Guardrail. Validation on input (first agent only), output (last agent only), or tool invocation (per function tool). Session. Automatic conversation history across turns. Tracing. Built-in spans for LLM generations, tool calls, handoffs, guardrails. The model sees transfertobillingagent in its tool list. Calling it signals the runtime to: Copy the conversation context (or collapse it via nesthandoffhistory beta). Initialize the target agent with its instructions. Continue the run with the target agent. This is the supervisor pattern…

OpenAI Agents SDK: Handoffs, Guardrails, Tracing: OpenAI Agents SDK is the lightweight multi-agent framework built on the Responses API. Five primitives:…

This free lesson is part of the AI Engineering from Scratch curriculum. Read the full explanation, run the lesson code, and verify the result in the interactive reader or from the repository source.

Browse the complete course catalog or open this lesson on GitHub.