Chapter 4

Learn the Direct API Before an Agent Framework

The temptation to start with a framework is strong - it promises "an agent out of the box." But the direct API shows the real protocol: how tool calling and state are actually built. A framework saves code when you need sessions, tracing, handoffs, and human in the loop; it doesn't cancel designing rights, tool schemas, and evals. So understand the protocol first and take a framework deliberately.

The choice comes down conveniently to three options, each with its own price.

Choice · Advantage · Price · When to take

  • Direct API - A transparent cycle, full control, easy portability; You write state, loop, tracing yourself; One agent, 4-10 tools, multi-provider matters
  • OpenAI Agents SDK - Tools, sessions, tracing, handoffs, approvals; Coupling to the SDK's semantics; A complex OpenAI-native system
  • Anthropic Tool Runner - An automatic tool loop and typing; A beta surface; After checking the beta limits on your workload
  • Google ADK - Agents, workflow agents, sessions, evals; A separate runtime model; Google-native orchestration or multi-agent

The logic in every row is the same. The direct API gives a transparent cycle, full control, and easy portability between providers - at the price of writing the state, loop, and tracing yourself; it's optimal for one agent with a few tools where multi-provider matters. The OpenAI Agents SDK gives tools, sessions, tracing, handoffs, and approvals - at the price of coupling to the SDK's semantics. The Anthropic Tool Runner gives an automatic tool loop and typing - at the price of being beta.

And the main caveat, the whole reason to keep the direct API in mind.

A framework is not a standard. Even if three products use the word "agent," their state, lifecycle, tracing, and tool protocol differ. Make your own business contract the common thing, not all of an SDK's internal objects.

That's exactly why the book builds the agent on a unified contract over the direct APIs and shows frameworks as an option. Next - we prepare the project in which that contract will live.

Links