Chapter 21. Agent SDKs: the Claude Agent SDK and the OpenAI Agents SDK
In this section
- Chapter 21. Agent SDKs: the Claude Agent SDK and the OpenAI Agents SDKThe loop from Chapter 20, run for you. Two SDKs show the same ideas in two shapes: a harness used as a library, and an agent with a runner. Every feature is mapped to the line of the Chapter 20 loop it replaces, so nothing is magic. What each SDK takes over, the defaults it chooses for you, and what it still leaves to you: which tools, whose credentials, what it may spend, what counts as done. In TypeScript and Python, written by coding agents, on Claude first, then OpenAI, then an open model.
- 21.1 From your loop to a libraryThe ladder from your own loop to a tool runner, an agent SDK and a hosted runtime: what each rung takes over, and the defaults each one chooses for you.
- 21.2 The mapThe mapping table: every line of your Chapter 20 loop, and where each SDK does it, does it differently, or leaves it to you.
- 21.3 One run, start to finishHow an SDK runs the loop and reports it, as a message stream or as a result with its history, and the four things to collect about every run.
- 21.4 Tools: which the worker can see, and where each call runsThe four kinds of tool and who runs each call, why a worker gets only the tools its job needs, and the four boundaries around a tool call.
- 21.5 Who may run a toolAuthorization in layers, and one rule you write in two shapes: a permission callback that answers at once, and an approval that hands the call back to resume later.
- 21.6 What counts as done, and the limits around itRun limits, resource limits and acceptance checks: a limit only stops a run, and only an acceptance check, such as a guardrail, says its answer may be handed over.
- 21.7 Where the conversation livesThe five places a conversation can live, from your program to the provider's side, what a session file holds, and what is left after a restart.
- 21.8 Where traces goWhere an SDK sends its traces by default, what they hold, and five checks before you turn tracing on for real data.
- 21.9 What an SDK still leaves to youThe runtime an SDK in your own process leaves you: the process, what it inherits, credentials, files and traces, cost and time, upgrades, and what counts as done.
- 21.10 How today's tools realize itThe Claude Agent SDK, the OpenAI Agents SDK and open-source options, as verified November 5, 2026: short dated boxes, the differences that change a design decision, and the invariant.
- Chapter 21 reference: today's agent SDKs, in detailThe companion page to Chapter 21. The full dated boxes for the Claude Agent SDK, the OpenAI Agents SDK and open-source options, what the authors' runs showed on the wire, and the field guide (F0 to F7) that the lab's tasks point to.
- Lab 21: the AP worker on two agent SDKsThe lab for Chapter 21. Coding agents write every file, and you predict and approve. Four sittings, each done right after its part of the chapter. Core path about 4 hours 35 minutes.
- Check yourselfRecall and practice for the whole chapter: the flashcards, sixteen questions with outline answers, and a final quiz round.