AI Agent Framework Comparison
Choose LangGraph for explicit workflow state, routing and recovery. Choose DSPy to optimize a model-driven task against examples and a metric. Compare these approaches with LangChain, CrewAI, Microsoft frameworks, agent SDKs and Haystack below.
By Gregor Maric. Maintainer documentation checked on .
DSPy vs LangGraph: Which Problem Are You Solving?
DSPy focuses on modular model programs and optimization. LangGraph focuses on orchestration and execution state. They overlap in agent building, but the first decision is whether your bottleneck is answer quality or workflow control.
| Your requirement | Start with DSPy when… | Start with LangGraph when… |
|---|---|---|
| Main task | You need to improve extraction, classification, retrieval or tool-use behavior against a defined scoring function. | You need to route work across steps, preserve state, pause for approval or resume a long-running process. |
| What you define | Input/output signatures, modules, representative examples and a metric; then evaluate an optimizer. | Shared state, nodes, edges, persistence and interruption points; then test execution and recovery. |
| Evidence of success | Better task scores on held-out examples within your inference and optimization budget. | Correct task completion, preserved approvals and safe recovery after timeouts, failures or restarts. |
| Example | Extract order details from varied customer emails and compare field accuracy against a baseline. | Validate an order, request human approval, call a business system and recover without duplicating the order. |
Can you use both? Yes, as an application design: a LangGraph node can call a DSPy program. For example, optimize the extraction step with DSPy and orchestrate validation and approval with LangGraph. This composition still needs integration tests; it does not transfer optimization gains or recovery guarantees automatically.
Capability references: DSPy overview, DSPy metrics and evaluation, DSPy optimizer selection and LangGraph overview.
AI Agent Framework Comparison Table
Use this table to shortlist a framework by its documented role. The selection guidance is editorial judgment. Production suitability depends on your application, pinned package versions and deployment tests; a framework name does not establish an SLA, compliance or reliability.
| Framework or SDK | Languages reviewed | Documented role | Consider it for | Check before choosing |
|---|---|---|---|---|
| LangChain | Python, TypeScript | Configurable agent loop, model and tool integrations | A higher-level starting point for a tool-using agent | Provider behavior, middleware and required custom workflow control |
| LangGraph | Python, TypeScript | Stateful orchestration with persistence, streaming and interrupts | Explicit routing, long-running work and human approval | Checkpoint storage, replay behavior and external side effects |
| DSPy | Python | Signatures, modules and metric-driven optimizers | Systematic improvement of a measurable model task | Representative data, metric quality and held-out results |
| CrewAI | Python | Role-based Crews and event-driven Flows | Tasks with clear role boundaries and coordinated work | Whether multiple agents justify extra calls and coordination |
| Microsoft Agent Framework | Python, .NET | Agents, model clients and explicit workflows | New agent projects evaluating the Microsoft stack | Release status and capabilities of the specific language package |
| Semantic Kernel | C#, Python, Java | Model connectors and plugins for existing application functions | Extending an application already using Semantic Kernel | Existing API dependencies and the Agent Framework migration path |
| Microsoft AutoGen | Python; .NET Core API | Layered agent messaging and multi-agent conversations | Reviewing an existing AutoGen implementation | README now describes it as archived; Microsoft recommends Agent Framework for new projects |
| AG2 | Python | Cooperating agents, tools and conversation patterns | Evaluating the independently maintained AG2 project | Current AG2 versus AG2 Classic packages and import names |
| OpenAI Agents SDK | Python, TypeScript | Agent loops, tools, handoffs, guardrails and tracing | An SDK-based application with explicit tool and handoff behavior | Provider and SDK differences; non-OpenAI support does not imply identical features |
| Claude Agent SDK | Python, TypeScript | Claude Code's agent loop, context management and built-in tools | Embedding a Claude agent that works with files, commands and tools | Runtime hosting, tool permissions and sandbox boundaries |
| Haystack | Python | Reusable pipelines, document stores, agents and tools | Retrieval, document question answering and search workflows | Retrieval quality, document freshness and end-to-end answer quality |
Shortlist by Your Team's Next Task
These are starting points for a proof of concept. Compare the same representative task before committing to an architecture.
Ship a Bounded Agent
Start with LangChain or OpenAI Agents SDK for a model-and-tools loop. Evaluate Claude Agent SDK if you need its built-in workspace tools and runtime. Add CrewAI when the task benefits from distinct agent roles. Establish a single-agent baseline first so you can measure the value of coordination.
Control a Business Workflow
Evaluate LangGraph for explicit state and approval steps, or Microsoft Agent Framework alongside your Python or .NET stack. For an existing Semantic Kernel or AutoGen application, inventory integrations and test the migration path before replacing working components.
Improve Answers or Retrieval
Evaluate DSPy when you can define examples and a meaningful task metric. Evaluate Haystack when document ingestion, retrieval and pipeline composition dominate the work. Use AG2 as a separate candidate for agent cooperation experiments, with a pinned package and explicit stopping conditions.
Framework Details That Change the Decision
Check the project, package and runtime you will actually deploy. Similar names and shared ancestry do not guarantee compatible APIs.
LangChain and LangGraph Are Different Layers
- LangChain provides a configurable agent harness and integrations. LangGraph provides lower-level state and control-flow primitives; it does not require LangChain.
- LangGraph supports checkpointing and interrupts. Your deployment still needs a suitable persistence backend and tested handling of repeated or partially completed external actions.
- Use the abstraction level your task needs. A short model-and-tools loop may not need a custom graph.
Sources: LangChain, LangGraph Python and LangGraph TypeScript.
Microsoft AutoGen, AG2 and Agent Framework
- Microsoft AutoGen and AG2 are separate projects. The Microsoft AutoGen README describes AutoGen as archived and no longer maintained by Microsoft, and recommends Microsoft Agent Framework for new projects.
- AG2's current README distinguishes the top-level
ag2package from AG2 Classic, which retains the legacyautogennamespace. Match code examples to the correct repository and version. - Semantic Kernel supports C#, Python and Java; it is not limited to .NET. Existing users should assess the documented Agent Framework migration guidance against their actual features and language.
Sources: Microsoft AutoGen README, AG2 README, Semantic Kernel overview and Microsoft migration guides.
OpenAI Agents SDK and Claude Agent SDK
- OpenAI Agents SDK has Python and TypeScript implementations. Its Python documentation describes non-OpenAI provider support through compatible endpoints and adapters, including LiteLLM; it is not restricted to OpenAI models.
- Provider portability needs testing. Tool calling, structured outputs, hosted tools and tracing behavior can differ by provider and SDK language.
- Claude Agent SDK exposes Claude Code's agent loop, context management, permissions, sessions and tools in Python and TypeScript. Plan hosting and access controls for file and command execution.
- Evaluate SDKs and hosted services separately. Confirm any support contract or SLA for the specific service you buy.
Sources: OpenAI model providers, OpenAI TypeScript SDK and Claude Agent SDK overview.
CrewAI, Haystack and DSPy: Test the Fit
- CrewAI separates role-based Crews from event-driven Flows. Prototype delegation and failure handling with your real task boundaries.
- Haystack provides pipelines and agents as well as retrieval components. Evaluate document retrieval separately from generated answers to locate the cause of errors.
- DSPy optimizers search for improvements against your chosen metric. A higher optimization score is not proof of better performance on unseen cases; reserve held-out data and inspect failure examples.
- Budget optimization calls separately from inference. Changing the model, tools or task distribution calls for a new evaluation.
Sources: CrewAI documentation, Haystack introduction and DSPy optimizer guide.
How to Evaluate Your Shortlist
This is a proposed evaluation protocol, not a test we have run across these frameworks. Set acceptance thresholds before you see the results.
- Fix the task and baseline. Use representative normal, edge and failure cases. Keep model version, tool access, dataset and inference budget comparable; record any differences.
- Measure useful completion. Score whether the task was completed correctly, required fields were valid and answers were supported by the supplied evidence. Review failed cases, not just an average.
- Measure operating cost and delay. Record model/tool calls, tokens, billed usage and end-to-end latency, including slow cases. Track optimization cost separately.
- Test control and recovery. Interrupt a run, fail a tool, restart a worker and deny an approval. Verify state recovery, stopping limits and that retries do not repeat an external write.
- Review deployment constraints. Check permissions, sensitive data in traces, storage and model-provider locations, package licenses, maintenance status and the service support terms you need.
- Keep a reproducible decision record. Save versions, configuration, prompts or compiled program, examples and results. Re-run relevant cases after dependency or model changes.
Scope of this comparison: This page summarizes the linked maintainer documentation and provides selection guidance. It does not report a cross-framework benchmark, rank community size or promise faster delivery, lower cost, compliance or production reliability. Validate the selected package and deployment with the production checklist.
Ready to Deploy Your Agent?
Use your shortlist to build a representative proof of concept, record the results, and work through deployment and incident checks before release.