diffox
Blog

What is an agent SDK, and which one should you use when?

When you build an AI agent, what do the Claude Agent SDK, OpenAI Agents SDK and Google ADK decide for you, and when is the API enough? We read their docs.

ShareXLinkedIn

Summary. An agent SDK is a library that runs the agent loop for you: the model calls a tool and carries on from the result. On 5 November 2026 we read the SDKs of Anthropic, OpenAI, Google, GitHub Copilot, Cursor and OpenCode, LangGraph, and the agents the providers run themselves, each in its own documentation.

  • The loop is the same in every SDK. The model asks for a tool, the code runs it, and the result goes back to the model; the work is done when the model stops asking for tools. If you use the API directly, you write this loop, the permission check and the session yourself.
  • The difference is in what the SDK decides for you. It comes down to whose harness it is, which models run, where the session lives and who runs the agent. 6 coding agents offer their harness as an SDK; the OpenAI Agents SDK and Google ADK give you the parts to build the agent from.
  • All three providers offer the same three paths. Anthropic, OpenAI and Google each document them separately: using the API directly, an SDK that runs in your own process, and an agent they run on their own infrastructure. With the last one, the session is kept by the provider.
  • The choice comes down to the job and the model you must use. For an agent that works in a repository, the coding agent’s SDK is the shortest path; for a support agent that touches your own systems, a framework; for a one-step job, the API; for a job that runs for hours, the provider’s agent.

What is an agent SDK?

6coding agents offer their harness as an SDK
3model providers offer the same three paths: the API, an SDK and an agent they run
2languages: Claude Agent SDK and OpenAI Agents SDK (Python, TypeScript)
5languages: Google ADK (Python, TypeScript, Go, Java, Kotlin)

In the harness engineering post we covered the structure built around the model, in the structured outputs post getting JSON at the end of the loop, and in the subagents post splitting up the work. This post takes a step back: if you are going to write your own agent, which library should you start with, what does it give you, and what does it decide for you? Our AI code review tool, diffox, also reviews pull requests with an agent loop; how that loop is built is at the end of the post.

In Anthropic’s definition, an agent is an application that completes a task by planning its own steps and calling tools that read files, run commands or edit code. The model cannot run these tools itself; it only says which tool it wants to call, and with what input. The code that runs the tool, hands the result back to the model and repeats this until the work is done is called the agent loop. In LangChain’s definition, all the code, configuration and execution logic outside the model, the loop included, is called the harness. An agent SDK is a library that comes with this loop and what surrounds it (tools, permissions, context management, the session) ready to use.

Because the loop is the same in every SDK, the SDKs look alike at first glance. The real difference is in the decisions they make for you; before you pick one, ask these four questions:

4 questions before you pick an SDK. The loop is the same in every SDK; the answers to these four differ. 1. Whose harness is it? A coding agent’s, or one you build? 2. Which models run? One provider’s, or any model you like? 3. Where does the session live? On local disk, in your own database, or with the provider. 4. Who runs the agent? Your process, or the provider’s infrastructure?
Compiled from the SDK documentation in this post, 5 November 2026.

The first question separates two kinds of SDK. LangChain’s classification counts the OpenAI Agents SDK and Google ADK as frameworks and the Claude Agent SDK as a harness: a framework gives you abstractions and integrations, while a harness comes with predefined tools, prompts and subagents. LangChain itself builds LangGraph and a harness called Deep Agents; keep that in mind when you read the classification.

What does an agent SDK add to the model’s API?

When you use the API directly, the model does not run your code. Anthropic’s documentation puts it in one sentence: every tool call is a round trip; the model asks, you execute, you report back, the model continues. Google’s function calling documentation says the same: the model does not execute the function itself; you take its name and arguments and execute it in your application. At its simplest, the loop looks like this; the example is written with Anthropic’s Python client:

agent_loop.py
# Example: an agent loop on the API; you write the loop, tool and permission.
import os
import subprocess

import anthropic

client = anthropic.Anthropic()
tools = [{
    "name": "run",
    "description": "Run a shell command in the project, return its output.",
    "input_schema": {
        "type": "object",
        "properties": {"cmd": {"type": "string"}},
        "required": ["cmd"],
    },
}]
task = "Run npm test and find the cause of the failing test."
messages = [{"role": "user", "content": task}]

while True:
    response = client.messages.create(
        model=os.environ["MODEL"], max_tokens=8000,
        tools=tools, messages=messages,
    )
    messages.append({"role": "assistant", "content": response.content})
    if response.stop_reason != "tool_use":  # no tool call: the work is done
        break
    results = []
    for block in response.content:
        if block.type != "tool_use":
            continue
        if block.input["cmd"] != "npm test":  # permission check is yours too
            output = "This command is not allowed."
        else:
            done = subprocess.run(
                ["npm", "test"], capture_output=True, text=True)
            output = done.stdout + done.stderr
        results.append({"type": "tool_result", "tool_use_id": block.id,
                        "content": output})
    messages.append({"role": "user", "content": results})

print("".join(b.text for b in response.content if b.type == "text"))

This code is a working agent, but it expects you to write everything: when the loop stops, which command is allowed, what happens when the context fills up, how the session is saved and resumed. Agent SDKs come with all of this:

  • The loop and its limits. The Claude Agent SDK runs the loop until the model stops asking for tools; you cap the number of turns with max_turns and the spend with max_budget_usd. According to the documentation, without limits the loop can run long on an open-ended prompt.
  • Built-in tools. The coding agents’ SDKs come with tools to read, edit and search files and to run shell commands; in the Claude Agent SDK these are Claude Code’s own tools: Read, Edit, Grep, Bash, WebFetch and others. The OpenAI Agents SDK, for its part, turns any Python function into a tool and generates its schema itself.
  • Permissions. In the Claude Agent SDK, allowed_tools runs the listed tools without asking, disallowed_tools blocks them, and the permission mode decides the rest. The documentation says to use the mode that allows every call without asking only in isolated environments such as CI or a container. The details are in the sandbox post.
  • Context management. When the context window nears its limit, the Claude Agent SDK summarizes the older history, and the part that stays the same on every turn is cached automatically. Google ADK also says it filters out irrelevant events and summarizes older turns. What a summary loses is covered in the auto compact post.
  • Sessions. The history the agent builds up while it works is saved; when you return to the same session, the agent remembers the files it read and what it did. In the Claude Agent SDK you can also copy a session and try another approach without touching the original.
  • Subagents and handoffs. In the Claude Agent SDK, a subagent returns only its final answer, so the main agent’s context gains a summary, not the subtask’s whole transcript. In the OpenAI Agents SDK, a handoff passes the work to another agent that specializes in that area. The details are in the subagents post.
  • Hooks, guardrails and tracing. Hooks run your own code at set points in the agent’s lifecycle (the hooks post); the OpenAI Agents SDK’s guardrails check the user’s input and the agent’s output. Tracing is on by default in the OpenAI Agents SDK, and the Copilot SDK can be traced with OpenTelemetry. What to name the traces of your own agent is covered in the OpenTelemetry post.
  • Evaluation. ADK suggests judging an agent not only by its final answer but also by the steps it took to get there; it provides metrics that compare against the expected steps and that score with a rubric. The pitfalls of using a model as a judge are covered in the LLM-as-a-judge post.

Here is the same job with the Claude Agent SDK; the loop, the tools and the permission check are the SDK’s:

sdk_agent.py
# Example: same job with the Claude Agent SDK. Loop, tools, permissions built in.
import asyncio

from claude_agent_sdk import ClaudeAgentOptions, ResultMessage, query


async def main():
    options = ClaudeAgentOptions(
        # tools that run without asking; in the shell, only npm test
        allowed_tools=["Read", "Grep", "Glob", "Bash(npm test)"],
        max_turns=20,
    )
    task = "Run npm test and find the cause of the failing test."
    async for message in query(prompt=task, options=options):
        if isinstance(message, ResultMessage):
            print(message.subtype, message.result)


asyncio.run(main())

The Bash(npm test) rule allows only that command in the shell. In the default permission mode, a call that is not on the list and needs approval is denied, because you defined no function to approve it (can_use_tool). The check you wrote by hand in the first example is a one-line setting here. The session is written to disk on its own, too.

How do agent SDKs differ?

The SDKs fall into two groups. The first is a coding agent’s harness. When Anthropic saw that the harness that runs Claude Code could run other kinds of agents too, it renamed the Claude Code SDK to the Claude Agent SDK on 29 September 2025. Today Codex, GitHub Copilot, Cursor, Google Antigravity and OpenCode also offer their agents through an SDK. With these SDKs, an agent that reads files, runs commands and edits code comes ready-made. The second group is frameworks: the OpenAI Agents SDK and Google ADK don’t bring a ready-made agent; they give you the parts to build one. We read the table from each SDK’s own documentation on 5 November 2026:

8 agent SDKs: what comes built in, which languages you write them in, which models they run, where the session lives and where the agent runs
SDKBuilt inLanguagesModelsWhere the session livesWhere it runs
Claude Agent SDKClaude Code’s tools, permissions, sessions and hooksPython, TypeScriptClaude models: Anthropic API, Amazon Bedrock, Google Cloud, Microsoft FoundryJSONL on local disk; in your own system too, if you likeIn your process, as a claude subprocess
Codex SDKCodex’s agent and sandbox settingsTypeScript, PythonOpenAI models; other providers configured in CodexLocally, as a Codex threadOn your machine, with the local Codex app-server
GitHub Copilot SDKCopilot’s agent runtime: planning, tools, file editsTypeScript, Python, Go, .NET, Java, RustThe models in your Copilot subscription, or OpenAI, Anthropic and Ollama with your own keyIn memory by default; on disk once persistence is onOn your side with Copilot CLI, or in GitHub’s cloud
Cursor SDKThe agent that runs in Cursor’s IDE, CLI and web appTypeScript, PythonModels hosted by CursorLocally in SQLite or JSONL; in the cloud, with CursorIn your process, or in a Cursor virtual machine
Antigravity SDKAntigravity’s tools, loop and context managementPythonGemini; Gemma locallyNot stated in the documentationOn your machine, with the compiled runtime that ships with the SDK
OpenCode SDKOpenCode’s agent; the SDK is a client that drives the OpenCode serverTypeScriptMore than 75 providers, and local modelsSQLite on local diskOn your machine, with the OpenCode server
OpenAI Agents SDKBuilding blocks: agent, handoff, guardrail, sessionPython, TypeScriptOpenAI models; others through an OpenAI-compatible endpoint or beta adaptersWhere you choose: SQLite, Redis, SQLAlchemy, Conversations APIIn your application
Google ADKBuilding blocks: agent, tool, workflow; graph-based in 2.0Python, TypeScript, Go, Java, KotlinGemini and Claude; others through LiteLLM, Ollama, vLLMIn memory, in a database or in Google CloudIn your own container or in Google Cloud

Source: each SDK’s own documentation and release notes, 5 November 2026. “Not stated in the documentation”: in the pages we read that day, we found no sentence that describes this. Cursor also has an Agent SDK, in which you define an agent as code and deploy it (below).

The most important column in the table is the models. A coding agent’s SDK usually ties you to that agent’s models: the Claude Agent SDK works with Claude models, which it reaches through Anthropic’s API or through Amazon Bedrock, Google Cloud and Microsoft Foundry. The Antigravity SDK works with Gemini. The Cursor SDK uses the models Cursor hosts; according to its announcement, it can work with any frontier model. With the Copilot SDK you can use, besides your Copilot subscription, OpenAI’s and Anthropic’s models with your own key, or local models in Ollama; OpenCode supports more than 75 providers and local models. The frameworks differ too: ADK runs Claude as well as Gemini, and other models through connectors such as LiteLLM, Ollama and vLLM. The OpenAI Agents SDK works with OpenAI models by default; its documentation describes the Any-LLM and LiteLLM adapters it offers for other providers as beta, and says feature support can vary by provider.

The second big difference is where the session lives. The Claude Agent SDK starts a claude subprocess for each session; the shell, the working directory and the session files sit on that process’s local disk. The documentation says it plainly: hosting the SDK is not like hosting a simple, stateless API service. If the container restarts, the local sessions are gone; to carry on on another machine, you can plug in a session store that also writes the session to your own system. The OpenAI Agents SDK writes the session from the start to the place you choose: SQLite, Redis, a database SQLAlchemy supports, or OpenAI’s Conversations API. In ADK, sessions held in memory are lost when the application restarts; to keep them, you choose a database or Google Cloud.

When you look at what they can do, though, the SDKs are converging. ADK 2.0 moved to an engine that runs agents, tools and functions as the nodes of a workflow graph; it has been generally available in Python since 19 May 2026 and in TypeScript since 21 August 2026. Building the flow as a graph is also the core idea of LangGraph. The OpenAI Agents SDK, too, has sandbox agents that work on real files in an isolated workspace. And according to Anthropic, Claude Code’s harness also runs work outside coding, such as research and note-taking. So the choice is decided less by what the SDKs can do than by the answers to the four questions above.

Cursor has two separate SDKs. The Cursor SDK came out in public beta on 29 April 2026; it runs Cursor’s agent in your process or in a virtual machine in Cursor’s cloud. The Agent SDK became generally available on 20 October 2026: you define the agent as a project (the instructions in a Markdown file, each tool in a file of its own), test it with evals, and deploy it to Cursor’s hosting or to your own infrastructure. According to its documentation, the Agent SDK uses the Cursor SDK harness that also runs Bugbot: you write the instructions and the tools, and Cursor runs the model loop that calls them.

An SDK, the API, or an agent the provider runs?

Type “claude agent sdk vs” into Google’s search box and it suggests endings such as “claude api”, “client sdk” and “managed agents”. These questions are really a choice between three paths, and all three providers describe the three paths separately in their documentation. In OpenAI’s words, the choice comes down to where the loop runs and who manages the state between tasks. According to Anthropic, the options differ in who runs the agent, what comes built in, and how you reach it.

Who runs the loop?. The API directly: Messages API, Responses API, Gemini API. Loop: In your code. Every tool call passes through your code. Agent SDK: Claude Agent SDK, OpenAI Agents SDK, Google ADK. Loop: In your process. The library runs the loop for you. The provider’s agent: Claude Managed Agents, OpenAI Agents API, Gemini managed agents. Loop: With the provider. The session is kept there too.
Source: Anthropic’s, OpenAI’s and Google’s documentation, 5 November 2026. The agent the provider runs is in beta at Anthropic and in preview at Google; requests to OpenAI’s Agents API carry a beta header.

Using the API directly gives you the most control. Anthropic recommends the Messages API to those who want to build their own agent loop and control every detail; OpenAI recommends the Responses API to those who want to keep the loop, tool dispatch and state in their own hands, and for short flows whose main job is to return the model’s answer. There is also a path in between: the tool runner (beta) in Anthropic’s client SDKs handles the loop, error handling and type safety for you. The documentation says to go back to a hand-written loop when you need human approval, custom logging or conditional execution.

With an agent SDK, the loop runs in your process, and you host the agent. Anthropic’s hosting page describes every running agent as a long-lived process tied to local state; allocating resources, storing the session and scaling are therefore your job. In return, you keep the control that Google’s ADK documentation lists: the model, the instructions, the tools (your own function and MCP tools included) and where the work runs. Anthropic’s table has a fourth row too: Claude Code itself, for interactive work. From a language other than Python and TypeScript, you can run the same loop as a subprocess with claude -p.

With an agent the provider runs, the loop and the session are with the provider. Claude Managed Agents is recommended for long-running, asynchronous work; the tools run in a sandbox in Anthropic’s cloud or in a sandbox on your own infrastructure. OpenAI’s Agents API opens Codex’s harness to your application as an API that OpenAI manages; OpenAI handles the sessions, context compaction and recovery. The Gemini API’s managed agents set up, with a single API call, a Linux sandbox in which the agent runs code and manages files; the default agent is the Antigravity agent. An agent you define with Cursor’s Agent SDK can also be deployed to Cursor’s hosting. Whose permissions an agent in the cloud works with is covered in the cloud agents post.

The price of this path is flexibility and data. Google’s ADK documentation states the difference plainly: a managed agent gives you a powerful agent out of the box, but with limited flexibility; when you connect from ADK, the toolset is predefined and server-side, and client-side tools and MCP tools are not supported. The sessions are kept by the provider; neither Claude Managed Agents nor OpenAI’s Agents API is covered by Zero Data Retention (ZDR). In the Gemini API, an environment that goes unused for 7 days is permanently deleted.

Which one should you choose for which job?

We grouped the documentation’s own “when to use” sentences by job:

Which one for which job?. Not a ranking: each job puts a different one of the four questions first. agent in a repo The coding agent’s SDK: File tools, permissions and sessions built in. support agent Framework: Your own tools, handoffs and guardrails. pipeline step The API directly: One call, a fixed schema. hours-long job The provider’s agent: Loop and session live there. long flow awaiting approval Graph: LangGraph or ADK 2.0. your model may change Multi-model option: Like ADK or OpenCode, with many providers.
Compiled from the “when to use” sections of the documentation in this post, 5 November 2026. The jobs are examples.

For an agent that works in a repository, one that fixes a test that broke in CI, triages incoming bug reports or reviews code, the SDK of the coding agent you already use is the shortest path. OpenAI recommends the Codex SDK for controlling Codex in your CI/CD pipeline and building it into your own tools. Cursor gives CI bots that fix failures on their own, workers that sort incoming bug reports, and code review passes as examples for its SDK. LangChain’s table, too, recommends a harness when you want predefined tools such as file operations and a shell, and automatic context management.

For a support agent that touches your own systems, a framework fits better, because the agent works not with a file system but with your services, such as orders, refunds or FAQs. OpenAI’s handoffs documentation gives exactly this example: separate agents for order status, refunds and FAQs, and handoffs that pass the work between them. OpenAI recommends the Agents SDK when you want the runtime to manage turns, tool execution, guardrails, handoffs or sessions.

For a single step in a pipeline (classifying a text or producing a JSON object, say), you often don’t need an SDK. In a post of 19 December 2024, Anthropic recommends starting with LLM APIs directly, because many patterns can be written in a few lines of code. If you do use a framework, it asks you to understand the code underneath: layers of abstraction can hide the prompts and responses and make debugging harder. You can pin down the shape of the answer with structured outputs.

A job that runs for hours with nobody watching it is what the provider’s agent was designed for: Anthropic recommends Managed Agents for long-running and asynchronous work, and OpenAI recommends the Agents API for long jobs in which it manages the agent and saves its progress. The one condition is that you are fine with the session and the data being kept by the provider.

For a long flow that waits for approval and has to pick up where it left off, use a graph: LangGraph describes itself as a low-level orchestration framework for long-running, stateful agents. Durable execution, streaming and human approval come built in; the prompts and the agent architecture are left to you. Its documentation recommends it when you need explicit control over state and flow. The graph-based workflows of ADK 2.0 meet the same need.

A model requirement narrows the choice. If your model is set, that provider’s SDKs are the most direct path: the Claude Agent SDK for Claude, ADK or the Antigravity SDK for Gemini, the Agents SDK or the Codex SDK for OpenAI models. If you may want to switch providers later, an option that runs many models, such as ADK or OpenCode, keeps that door open.

Our AI code review tool, diffox, also reviews a pull request with an agent loop; we wrote the loop in our own code, on the pattern of the first example above. The model reads the repository at the pull request’s latest commit, extracted into a new temporary folder, through four read-only tools: listing a directory, reading a file, grep and glob. It gives its comments through one final tool, a submit_review call bound to a schema. If a tool gets a bad input, the loop does not end; the error goes back to the model as the answer, and the model can try again. If the model stops without calling a tool, the loop asks it once more for the final tool. If a review still doesn’t come, the result is not reported as “no findings”; the review stops with an error. diffox writes the important problems it finds as comments on the changed line that causes the problem; each finding is classed as Critical, Warning or Suggestion, and diffox never blocks a merge.

Frequently asked questions

What is an agent SDK?

An agent SDK is a library that runs the agent loop, in which a model calls a tool and carries on from the result, so that you don’t have to write it. Besides the loop, it brings tools, permissions, context management and sessions. There are two kinds: the Claude Agent SDK, Codex SDK, GitHub Copilot SDK, Cursor SDK, Antigravity SDK and OpenCode SDK let you use a coding agent’s harness from your own code, while the OpenAI Agents SDK and Google ADK give you the parts to build the agent from. All of them have a Python or TypeScript version.

What is the difference between the Claude Agent SDK, Claude Code and the Claude API?

With the Claude API (the Messages API), the model only says which tool it wants to call; the code that runs the tool and keeps the loop going is yours. The tool runner (beta) in Anthropic’s client SDKs can run this loop for you. The Claude Agent SDK lets you use Claude Code’s harness from Python and TypeScript, with its file, shell and web tools, permissions, sessions, hooks and subagents; behind the scenes it runs Claude Code as a subprocess. Claude Code itself is the terminal interface for daily, interactive work. If you want Anthropic to run the agent, the fourth path is Claude Managed Agents (beta).

What is the difference between the OpenAI Agents SDK and the Claude Agent SDK?

The Claude Agent SDK comes with Claude Code’s agent ready to use: tools, permissions, context management and sessions work out of the box; it runs Claude models and writes the session to local disk. The OpenAI Agents SDK gives you a small set of building blocks: agent, handoff, guardrail and session; you build the tools and the flow. It runs OpenAI models by default, with beta adapters for other providers; it writes the session where you choose, such as SQLite, Redis or a database, and tracing is on by default. The documentation’s own examples show the difference: the Claude Agent SDK’s quickstart is an agent that finds and fixes the bugs in a file, and OpenAI’s handoffs page is a customer support app.

What is Google ADK?

Google ADK (Agent Development Kit) is Google’s open-source agent framework. You can write it in Python, TypeScript, Go, Java and Kotlin. Besides Gemini, it runs Claude, and other models through connectors such as LiteLLM, Ollama and vLLM. You build the agent, the tools and the workflow; since version 2.0, workflows run on a graph-based engine, and that version has been generally available in Python since 19 May 2026. It has tools that evaluate an agent not only by its final answer but also by the steps it took. You can run the agent in your own container or in Google Cloud (Agent Runtime, Cloud Run, GKE). The harness of Antigravity, Google’s coding agent, is a separate library: the Antigravity SDK.

LangGraph or an agent SDK?

They are different layers. LangGraph describes itself as a low-level orchestration framework for long-running, stateful agents: you build the flow as a graph of nodes and edges; durable execution, streaming and human approval are built in, but it doesn’t impose prompts or an agent architecture on you. Its documentation points those who want a higher-level agent loop to LangChain’s agents or to Deep Agents. If you need explicit control over state and flow, choose LangGraph; if you want an agent that works on files with ready-made tools, a coding agent’s SDK is the shorter path. Google ADK also moved to graph-based workflows with version 2.0.

Does the Claude Agent SDK work with my subscription?

Not if you are building a product. According to Anthropic’s documentation, developers who build products or services with the Agent SDK should use an API key from the Claude Console or a supported cloud provider (Amazon Bedrock, Google Cloud, Microsoft Foundry). Anthropic does not allow third-party developers to offer claude.ai login in their own applications, or to send requests with Free, Pro, Max or Ultra plan credentials on behalf of their users. The same page says the usage limits of these plans assume ordinary, individual use of Claude Code and the Agent SDK. The GitHub Copilot SDK, on the other hand, works with a Copilot subscription (Copilot Free included) or with your own key.

How does diffox’s review agent work?

Our AI code review tool, diffox, reviews a pull request with an agent loop written in its own code. The model reads the repository at the pull request’s latest commit through four read-only tools (directory listing, file reading, grep, glob) and gives its comments through one final tool bound to a schema. If no review comes back, the result is not reported as “no findings”; the review stops with an error. diffox writes the important problems it finds as comments on the changed line that causes the problem; each finding is classed as Critical, Warning or Suggestion, and diffox never blocks a merge.