Graph Framework, Agent SDK or Plain Code?
Compare a hand-written loop, provider agent SDKs (OpenAI Agents SDK, Claude Agent SDK, Google ADK), a graph framework such as LangGraph and a durable execution engine, and choose by the requirements each one actually serves.
Contentsand lesson path
On this page
- Why it matters
- Four ways to run an agent loop
- A decision guide with conditions
- Check your understanding
- Apply it
- Review prompt
Lessons of Stateful Agent Graphs
- Agents as State Machines Concept · 15 min
- State, Nodes and Reducers Worked example · 20 min
- Lab: Routing, Cycles and Parallel Branches Lab · 25 min
- Checkpoints, Threads and Replay Lab · 25 min
- Graph Framework, Agent SDK or Plain Code? Concept · 15 min
- Check: Trace a Graph Execution Knowledge check · 8 questions
What you will learn
- Explain when a graph framework (for example LangGraph) adds value over a hand-written loop or a vendor agent SDK, and when it adds needless complexity.
Prerequisites: Agent Loops & ReAct
01. Why it matters
In the earlier lessons you built a graph with typed state, routing, cycles and checkpoints. Now you need to decide when that machinery is worth having. Every agent needs the same core: a loop that calls a model, runs the tools it asks for and stops. The tools on offer differ in what they add around that loop, such as pausing for approval, resuming after a crash, handing work to other agents and replaying an earlier step.
If you pick too much framework, you pay in concepts, dependencies and debugging layers for features you never use. If you pick too little, you end up rebuilding persistence, approvals and retries by hand, often with bugs. The right choice depends on your requirements, not on which tool is most popular this month.
One name causes confusion. The OpenAI Assistants API was a hosted, stateful API that kept threads and runs on OpenAI servers. It was shut down on 26 August 2026, and OpenAI points new work to the Responses API with Conversations. The OpenAI Agents SDK is a different product: an open-source library whose agent loop runs in your own process. Do not judge one by the other.
02. Four ways to run an agent loop
1. Plain code. You write the loop yourself on top of a model client library. Every step is visible, a normal debugger works, and you add no new dependencies. You also own everything else: saving state, retries, approval pauses, tracing and any multi-agent logic. This is a good fit while those needs are small.
2. Provider agent SDKs. These are libraries that you run in your own process or container. Each one gives you a ready-made loop and some building blocks around it:
- The OpenAI Agents SDK (Python and TypeScript, MIT licence) has agents, tools, handoffs, agents as tools, guardrails, sessions and built-in tracing. A tool marked with
needs_approvalpauses the run. The pausedRunStatecan be saved withto_json()and resumed later, even in another process. Other providers work through OpenAI-compatible clients or the beta LiteLLM and Any-LLM adapters. However, its hosted tools, such as web search and file search, work only with OpenAI's Responses API: with another model the SDK raises an error at the first model call if a hosted tool is attached, so you remove it or replace it with a function tool. Traces are sent to OpenAI unless you change the trace processor. - The Claude Agent SDK (Python and TypeScript) runs Claude Code's agent loop as a library. It has built-in file, shell and web tools, subagents, hooks, MCP, and permission rules with a
canUseToolcallback for approvals. Sessions are saved to disk, so you can resume or fork them. It runs Claude models only, but you can reach them through the Claude API, Amazon Bedrock, Google Cloud or Microsoft Foundry. - Google ADK (Apache 2.0, with SDKs in Python, TypeScript, Go, Java and Kotlin) offers agents with sub-agents and sequential, parallel and loop workflows. Since ADK 2.0 it also offers graph-based workflows. Gemini is built in, and other models work through adapters such as LiteLLM. Tool confirmation, its human approval step, is stable in Python and still experimental in TypeScript, Go and Kotlin.
3. Graph frameworks such as LangGraph. You declare typed state, nodes and edges. A checkpointer saves the state after every step of a thread. interrupt() pauses the run and Command(resume=...) continues it. Because the history is kept, you can replay or branch from any earlier checkpoint. You pay for this with more concepts and more design work. Note too that on resume the interrupted node runs again from its first line.
4. Durable execution engines such as Temporal. These are not agent libraries. You write workflows as ordinary code, and the engine records an event history. After a crash it replays that history: finished activities are not run again, and timers do not start again. Model calls and tools run as activities. In return, the workflow code itself must be deterministic.
Pause for human approval, resume later
plain loop build it: save state, reload it, re-enter the loop
agent SDK built in: OpenAI needs_approval + RunState; Claude canUseTool;
ADK tool confirmation (Python; experimental in TS, Go, Kotlin)
graph framework built in: interrupt() with a checkpointer and thread_id
durable engine built in: wait for a signal; the wait survives restarts
Resume after the process dies
plain loop build it
agent SDK from the saved session history or a saved RunState
graph framework from the checkpoint saved after the last finished step
durable engine by replaying the event history; done activities not rerun
Go back to an earlier step, change it and branch
plain loop build it
agent SDK not a core feature (Claude sessions can fork a conversation)
graph framework built in: state history, update a checkpoint, run from it
durable engine not its purpose: replay is for recovery
Several agents (handoffs, sub-agents, agents as tools)
plain loop write it
agent SDK built in; routing mostly chosen by the model, except ADK's
fixed sequential, parallel and loop workflows
graph framework subgraphs and routing that you write as code
durable engine write it as workflow code
Models from other providers
plain loop any client you call
agent SDK OpenAI: adapters, some features OpenAI-only; Claude: Claude
models only; ADK: Gemini built in, others via adapters
graph framework any model you can call from a node
durable engine any model you can call from an activity
Waits of hours or days across many external systems
plain loop hard to do safely
agent SDK possible with saved state; scheduling the wake-up is yours
graph framework possible with a durable checkpointer; the wake-up is yours
durable engine the main use caseAll three SDKs run where you run them, and all three support several agents and human approval. The real trade-off lies elsewhere. With an SDK you accept its opinion of the loop: apart from fixed workflows such as ADK's, the model and the handoff rules decide most of the control flow, and you step in through hooks, guardrails and approvals. With a graph framework you write that control flow as code, and you get state that is saved after every step, which you can inspect, edit and branch from. These lines are blurring: ADK now has graph workflows, and LangChain's higher-level agents run on LangGraph. So always compare the specific versions you would use.
03. A decision guide with conditions
Go through these questions in order. Stop at the first one that settles the choice:
- Does a run finish in one sitting, with no approvals and nothing to resume? Use a plain loop, or a provider SDK if you want its tools and tracing. A graph would add structure that nothing uses.
- Are you committed to one provider, and do you want its built-in tools? That provider's SDK is usually the shortest path. Write down what would break if you switched provider, such as hosted tools, trace export or the session format.
- Must the control flow be checked by code rather than chosen by the model? Examples are fixed routing, bounded retry cycles and parallel branches that must join. The same applies if you need to replay or branch from any saved step. In these cases a graph framework earns its cost.
- Does the process wait for hours or days and call many systems whose side effects must survive deploys? Use a durable execution engine, and run the agent steps as activities inside it.
- Do the needs mix? Then combine the tools. A graph node can call an SDK agent, and an activity can run a graph. Keep your domain rules in plain functions so that changing the framework does not mean rewriting them.
Before you commit, run a short spike. Build your hardest requirement, for example "approve a refund, restart the server, resume", in your top two candidates. Then compare the code, the traces and the failure behaviour.
04. Check your understanding
05. Apply it
The practice task for this skill asks you to rebuild your framework-free agent as a graph with checkpoints, kill it mid-run, resume it and replay an earlier step. Before you start, write a one-page decision record for that agent:
- List its requirements as testable statements, for example "after a restart, an approved refund resumes without asking again".
- For each one, note how a plain loop, one provider SDK and LangGraph would meet it. Use the table above, and check the current docs for the versions you would install.
- Choose an option and name the requirement that decided it. Also name the change that would make you switch, for example "if runs start to wait for days, move them onto a durable engine".
After the practice, revisit the record. Were checkpoints, interrupts and replay worth the extra code for this agent? See Checkpoints, Threads and Replay if you need a refresher.
06. Review prompt
Without looking back, answer these questions:
- Name two built-in features that the OpenAI Agents SDK, the Claude Agent SDK and Google ADK all have. Then name one way each is tied to its provider.
- What does a graph framework give you that an agent SDK usually does not, and what does it cost you?
- Why is Temporal a different kind of tool from LangGraph, and when would you use the two together?
- A tool sends an email and runs behind an approval pause. Why can it still send the email twice, and what prevents that?
References
- LangGraph overview
- LangGraph: Persistence
- LangGraph: Interrupts
- LangGraph: Workflows and agents
- OpenAI Agents SDK (Python)
- OpenAI Agents SDK: Human in the loop
- OpenAI Agents SDK: Models
- OpenAI: Migrating from the Assistants API
- Claude Agent SDK overview
- Claude Agent SDK: Sessions
- Agent Development Kit (ADK) documentation
- ADK: Tool confirmation
- Temporal: Workflows
Your progress
Reading state
Sign in to save that you finished reading this lesson.
Prove this skill
8 questions · about 6 minutes · scored automatically. Marking a lesson as read never demonstrates a skill.