AI Agent Frameworks Compared: When to Use One and When to Write Your Own
An overview of agent frameworks and SDKs: what they provide (tools, memory, orchestration, tracing), trade-offs versus plain code, and how to choose.
Published December 1, 2026
There are dozens of agent frameworks and SDKs, from provider-specific agent SDKs to graph-based orchestration libraries and multi-agent toolkits. They can speed you up or bury a simple loop under abstractions. The right choice depends on how complex your orchestration really is and how much control you need.
The concept
Frameworks typically provide tool definitions and calling, conversation and memory management, orchestration (graphs, state machines, multi-agent handoffs), integrations with model providers and vector stores, streaming, and tracing. Graph-based frameworks model agents as nodes and edges with explicit state, which makes complex flows with branching, retries and human approval steps easier to reason about.
The cost is abstraction. When something goes wrong, you debug the framework as well as your prompt. Many experienced teams start with direct API calls and a simple loop, adopt a framework once they need durable state, complex branching or multi-agent coordination, and keep their core logic (tools, prompts, evals) framework-independent.
Categories
| Category | Examples | Good for |
|---|---|---|
| Provider agent SDKs | Vendor SDKs for building agents with their models | Fast start, tight provider integration |
| Graph / state-machine orchestration | LangGraph and similar | Complex flows, durable state, human-in-the-loop |
| Multi-agent toolkits | CrewAI, AutoGen and similar | Role-based agent teams |
| Data / RAG frameworks | LlamaIndex and similar | Document ingestion and retrieval pipelines |
| Plain code | Your loop + model SDK | Simple agents, full control |
The ecosystem moves quickly; evaluate current versions.
Decision guide
- Can a single prompt or a workflow solve it? Write plain code
- Need tools + a loop? A model SDK and 50 lines are enough
- Need durable state, branching, approvals, retries? Consider a graph framework
- Need many cooperating agents? Evaluate multi-agent toolkits carefully
- Whatever you choose, keep tools and evals portable
Architecture that ages well
Practical examples
Plain-code agent loop size
Often all you need.
# ~40 lines: build messages, call model with tools, execute tool calls, append results, repeat with limits.
# Add: tracing decorator, retries, approval hook for risky tools.Graph-style flow (pseudo-code)
Explicit nodes and edges make complex flows visible.
graph = Graph(state=TicketState)
graph.add_node("classify", classify_ticket)
graph.add_node("draft_reply", draft_reply)
graph.add_node("human_review", wait_for_approval)
graph.add_edge("classify", "draft_reply")
graph.add_conditional_edge("draft_reply", lambda s: "human_review" if s.risky else "send")Keep tools framework-agnostic
Plain functions with schemas can be wrapped by any framework.
def get_order(order_id: str) -> dict:
"""Look up an order by ID."""
...
TOOL_SCHEMAS = {"get_order": schema_from_signature(get_order)}Common mistakes
- Adopting a heavy framework for a single prompt with one tool.
- Locking prompts, tools and evals into framework-specific formats.
- Upgrading framework versions without rerunning evals.
- Choosing based on GitHub stars rather than your orchestration needs.
Key takeaways
- Frameworks help with state, orchestration and tracing for complex agents.
- Plain code is often enough and easier to debug.
- Adopt a framework when concrete needs appear.
- Keep tools, prompts and evals portable.
FAQ
Which framework is best?
There is no universal best; match the framework to your flow complexity, language and hosting, and prototype with real tasks.
Do frameworks lock me into a model provider?
Most support multiple providers, but provider SDKs naturally favour their own models.
Are frameworks production-ready?
Many are used in production; check release cadence, breaking-change history and observability support.