Check my levelCoursesProgramsFor teamsPricing
UKSign inSign up
Check my levelCoursesProgramsFor teamsPricingClaude quizPromptsBlogFAQSearchSign upUK
AcademlCoursesOpenAI Agents & OrchestrationAgent Orchestration: Routines and Handoffs
The request “I want a refund” drops into the refund agent’s trayThe agent loop: reason, act, observeOne MCP connector linking files, Git and memory
Course

OpenAI Agents & Orchestration

Module 1 · Agent Orchestration: Routines and Handoffs
01Agent Orchestration: Routines and Handoffs
Module 2 · Coding Agent with GPT-4.1
02Coding Agent: GPT-6 Astra + Agents SDK
Module 3 · Reasoning Models + Function Calls
03Function Calls with Reasoning Models (Responses API)
Module 4 · Multi-Agent Systems with Structured Outputs
04Multi-Agent: Structured Outputs + Triage Pattern
Module 5 · Structured Outputs: Basics and Pydantic
05Structured Outputs: JSON Schema + Pydantic
OpenAI Agents & Orchestration · Lesson 1

Agent Orchestration: Routines and Handoffs

Exploring orchestration patterns from the OpenAI cookbook: routines as instructions plus tools, handoffs for transferring control between agents, a hand-written loop on the Responses API and the production version in the OpenAI Agents SDK.

35 min readUpdated Dec 2, 20263 questions in quizReady prompt included

Routines and Agents

A routine is a set of steps: natural-language instructions plus the tools needed to execute them. LLMs handle conditional branches inside routines robustly without a rigid state machine.

OpenAI described routines and handoffs in the cookbook article "Orchestrating Agents: Routines and Handoffs". That article is now marked as archived. The ideas still hold, and the production implementation lives in the OpenAI Agents SDK (see the last section). The code below uses the Responses API, which OpenAI recommends for all new projects.

from openai import OpenAI
import json

client = OpenAI()

instructions = (
    "You are a customer support agent for ACME Inc. "
    "Follow the following routine with the user:\n"
    "1. Ask probing questions to understand the user's problem.\n"
    "2. Propose a fix (make one up).\n"
    "3. ONLY if not satisfied, offer a refund.\n"
    "4. If accepted, search for the ID and then execute refund."
)

def look_up_item(search_query):
    """Use to find item ID."""
    return "item_132612938"

def execute_refund(item_id, reason="not provided"):
    """Refund an item by its ID."""
    print(f"Refunding item {item_id}, reason: {reason}")
    return "success"

The rest of this lesson opens after a free sign-up

Sign up with email or Google: the first two lessons of every course stay open for good, and the whole catalog is open for 7 days. No card needed.

Sign up freeOr a trial lesson, no sign-up →
In this lesson
Routines and AgentsAutomatic Function Schema GenerationExecuting Tool Calls and HandoffsWhen to Use HandoffsThe Production Version: OpenAI Agents SDKPracticeReady promptQuiz
CoursesLLM coursesFor teamsPricingFAQBlogAboutPrivacy
© 2026 AcademlDevelopment & promotion —MMIX — Marketing Mix
Get started free