Practical guide · Agent engineering
How to choose an AI agent framework
Choose the smallest runtime that can express your workflow, recover its state, pause risky actions, and show you why a run failed. A framework comparison based on feature lists will push you toward whichever project has the longest documentation. A production-shaped proof task gives you evidence you can use.
Published November 26, 2026 · 12 minute read
The short answer
Start without a framework when one model call or a deterministic sequence can finish the job. Add a framework when you need durable state, branching, resumable approvals, coordinated specialists, or inspectable long-running work. Compare no more than three candidates with the same proof task. Force a crash, pause one consequential tool call, resume it, replay a failed case, and inspect the resulting trace. Pick the option with the least application-owned glue and the clearest recovery semantics, then keep your task contracts, tools, eval cases, and telemetry portable.
Decide whether you need a framework
Many products described as agents are a model call with retrieval and one or two tools. Ordinary application code is often easier to test and operate for that shape. A framework earns its place when it owns a difficult control problem rather than wrapping an API you already understand.
| Workflow shape | Start with | Reason |
|---|---|---|
| One response or structured record | Provider SDK and schema validation | There is no durable control flow to manage. |
| Fixed retrieval and generation sequence | Application code or a job runner | Explicit steps are easier to test than dynamic orchestration. |
| Long-running task with checkpoints | Durable workflow or graph runtime | A process restart must not lose completed work. |
| Risky action requiring review | Runtime with pause and resume semantics | Approval must bind to the exact pending action and state. |
| Specialists with routing and handoffs | Agent or workflow framework | The runtime can make transfers and ownership inspectable. |
Translate the job into framework requirements
Provider support and starter examples matter, but they rarely decide whether the system survives production. Score candidates on the behavior your team will have to debug at 2 a.m.
- Control flow: Can you express deterministic steps, conditional branches, bounded loops, parallel work, and explicit stopping rules without hiding them inside prompts?
- Durable state: What is persisted, when is it checkpointed, and what happens if the process dies between a remote side effect and the next checkpoint?
- Human approval: Can execution pause for minutes or days, show the reviewer normalized arguments, expire safely, and resume once without replaying completed writes?
- Observability: Can one trace connect the user task, model turns, retrieval, tool calls, policies, handoffs, cost, and final business outcome?
- Tool boundary: Are schemas typed, results bounded, errors explicit, identity injected by trusted code, and write operations compatible with idempotency?
- Portability: Can you keep domain logic, test cases, traces, and tool implementations usable if the framework, model provider, or storage backend changes?
Map the main framework shapes
The projects below overlap, but they start from different abstractions. The right comparison is between mechanisms your workflow needs, not broad claims that every option supports tools and memory.
| Option | Control model | Useful starting fit | Verify in your proof task |
|---|---|---|---|
| LangGraph | State graph with checkpoints and interrupts | Branching, long-running workflows where persisted graph state is central | Thread storage, replay, interrupt boundaries, and side effects around resumed nodes |
| OpenAI Agents SDK | Agent loop, tools, handoffs, guardrails, sessions, and tracing | OpenAI-centered applications that want a small set of agent primitives | Serialized run state, approval resumption, tracing controls, and non-OpenAI dependencies |
| Google ADK | Agents, workflows, sessions, artifacts, plugins, and resumability | Gemini or Google Cloud teams that want explicit workflow agents beside model-driven agents | Session persistence, resumable invocation behavior, deployment target, and trace export |
| CrewAI Flows | Event-driven flows that coordinate agents and crews | Teams modeling role-based collaboration inside a larger controlled workflow | Persistence, branching, human feedback, replay, and how crew autonomy is bounded |
| Pydantic AI | Typed Python agents with deferred tools and external durable execution integrations | Python teams that want type-driven interfaces and control over the surrounding runtime | Deferred result storage, approval identity, retry behavior, and the chosen durable backend |
| Vercel AI SDK | TypeScript model and tool primitives with workflow patterns | Web product teams that need streaming UI and explicit TypeScript orchestration | Durability provider, resumability, server lifecycle, and how workflow state reaches the UI |
This table is a shortlist generator. Documentation can confirm that a mechanism exists, but only your proof task can show whether it behaves correctly with your database, queue, authentication, deployment model, and failure policy.
Run the crash-and-resume test
Use the same small workflow for every candidate. A support request is a good test: retrieve an account-safe record, call a read tool, draft a resolution, ask for approval before a credit, execute one idempotent write, and store the receipt.
- Write the final-state contract and 20 representative cases before integrating a framework.
- Implement the read path, one conditional branch, one tool failure, and one request that needs clarification.
- Pause before the write. Persist the exact action, normalized arguments, policy version, reviewer decision, and expiry.
- Kill the worker after the external system accepts the write but before the next local checkpoint. Resume without duplicating the effect.
- Export a trace and locate the failed step without reading raw prompts from every successful run.
- Change the model or one tool implementation and rerun the same cases. Framework coupling should not force a rewrite of the task contract.
Use Learnetto's guides to design the agent's tools, implement approval gates, and make retries and side effects safe. These contracts belong to your application even if the framework supplies adapters.
Use the same task for a two-framework bake-off
AI agent framework scorecard
Score observed proof-task behavior from 0 to 5. Set weights before the trial so a polished demo does not outweigh recovery or security requirements.
| Criterion | Suggested weight | Evidence to record |
|---|---|---|
| Correct task outcomes | 25% | Pass rate and critical failure slices across fixed cases |
| Crash recovery and idempotency | 20% | Receipts, checkpoints, resumed state, duplicate-effect count |
| Approval safety | 15% | Argument binding, expiry, reviewer identity, one-time resume |
| Debuggability | 15% | Trace completeness, typed errors, time to diagnose planted failure |
| Application fit | 15% | Glue code, deployment constraints, test setup, storage compatibility |
| Portability and maintenance | 10% | Framework-specific domain code, upgrade effort, replaceable adapters |
| Latency under load | Required threshold | p50 and p95 task latency with the same concurrency |
| Cost per completed task | Required threshold | Model, storage, tracing, and orchestration cost for successful outcomes |
Keep raw measurements beside the score. A single weighted total can hide a zero in a required category. Reject any candidate that duplicates a side effect, resumes an expired approval, or prevents you from determining whether the user's task finished.
Write the exit plan before adoption
Framework code should coordinate domain operations rather than contain them. Put tool implementations, authorization, schemas, business rules, idempotency records, and outcome checks in application-owned modules. Store conversation and workflow state in formats you can inspect and migrate. Export traces through an open interface where practical, and use stable internal IDs for tasks, tools, policies, and releases.
The Model Context Protocol can standardize some tool and context connections, but it does not settle orchestration, authorization, durability, or outcome evaluation. Treat protocol compatibility as one adapter property. Keep the security boundary in trusted application code and test the exact transport and server you deploy.
Decision checklist
- The workflow needs a framework-owned capability that ordinary code does not already provide clearly.
- The same proof task and cases were used for every candidate.
- Crash recovery, resumed approvals, and uncertain writes were tested rather than inferred from docs.
- A trace connects the request to the final business outcome without collecting sensitive content by default.
- Tool authorization and business rules remain outside the model.
- Task contracts, eval cases, tool code, and state can survive a framework change.
- The selected framework passed every mandatory category before weighted preferences were considered.
Build evidence before committing
If you need structured teaching first, compare the best AI agent courses for developers. Then use the production AI engineering learning path and agent observability workflow to turn the proof task into an operable system.