Comparisons / CrewAI vs OpenAI Agents SDK

CrewAI vs OpenAI Agents SDK: Which Agent Framework to Use?

CrewAI crewai organizes work into agents, tasks, and crews. OpenAI Agents SDK openai's agents sdk (evolved from swarm) provides agent, runner, handoffs, and guardrails. Here is how they compare — and what the same patterns look like in plain Python.

By the numbers

CrewAI

GitHub Stars

48.0k

Forks

6.5k

Language

Python

License

MIT

Created

2023-10-27

Created by

João Moura

github.com/crewAIInc/crewAI

OpenAI Agents SDK

GitHub Stars

20.6k

Forks

3.4k

Language

Python

License

MIT

Created

2025-03-11

Created by

OpenAI

github.com/openai/openai-agents-python

GitHub stats as of April 2026. Stars indicate community interest, not necessarily quality or fit for your use case.

ConceptCrewAIOpenAI Agents SDKPlain Python
AgentAgent(role, goal, backstory, tools, llm)Agent(name, instructions, model, tools)A function with a system prompt and a tools dict
ToolsTool registration with @tool decorator, custom Tool classesPython functions with type hints, auto-converted to schemasA dict: tools[name](**args)
Agent LoopInternal to Agent execution, hidden from userRunner.run() handles the loop internallyA while loop over messages with tool_calls check
Task DelegationCrew(agents, tasks, process=sequential/hierarchical)A task queue processed in a while loop with a budget cap
MemoryShortTermMemory, LongTermMemory, EntityMemoryA dict injected into the system prompt
StateTask output passed between agents via Crew orchestrationA dict tracking tool calls and results
HandoffsHandoff between Agent objects for multi-agent routingCall a different agent function based on the LLM's tool choice
GuardrailsInputGuardrail and OutputGuardrail with tripwire patternTwo lists of rule functions checked before and after the LLM
ContextTyped context object passed through the agent lifecycleA state dict updated inside the loop

What both do in plain Python

Every concept in the table above — agent, tools, loop, memory, state — maps to a handful of Python primitives: a function, a dict, a list, and a while loop. Both CrewAI and OpenAI Agents SDK wrap these primitives in their own class hierarchies and APIs. The underlying pattern is the same ~60 lines of code. The difference is how much ceremony each framework adds on top.

When to use CrewAI

CrewAI shines for multi-agent setups where you want named roles ("researcher", "writer"). But the core mechanics — tool dispatch, the agent loop, task scheduling — are the same patterns you can build in plain Python.

What CrewAI does

CrewAI models multi-agent systems as a crew of specialists. Each Agent has a role ("Senior Researcher"), a goal ("Find the best data sources"), a backstory that shapes its behavior, and a set of tools it can use. Tasks define discrete units of work with expected outputs. The Crew orchestrates execution — sequentially, hierarchically, or with a custom process. CrewAI also provides memory systems (short-term, long-term, entity) and delegation, where one agent can hand off subtasks to another. The mental model is a team of people collaborating on a project. For prototyping multi-agent workflows where you want to reason about roles and responsibilities, it provides a clean vocabulary.

The plain Python equivalent

An Agent in CrewAI is a function with a system prompt that includes the role, goal, and backstory. The tools dict maps names to callables. Task delegation is a list of tasks processed in order — each task calls the assigned agent function with the task description appended to the messages. Hierarchical execution is a manager agent that decides which sub-agent to call next (just another tool choice). Memory is a dict injected into the system prompt. The entire crew pattern — multiple agents, task queue, delegation — is a for-loop over tasks, where each iteration calls the right agent function. No Crew class, no process kwarg. Just functions calling functions with a shared state dict passed between them.

Full CrewAI comparison →

When to use OpenAI Agents SDK

The Agents SDK is the thinnest framework on this list — it barely abstracts beyond what you'd write yourself. Use it when you want OpenAI's conventions and auto-schema generation. Skip it when you want full control or use non-OpenAI models.

What the OpenAI Agents SDK does

The Agents SDK (formerly Swarm) is OpenAI's opinionated take on agent architecture. It provides four primitives: Agent (system prompt + tools + model), Runner (the agent loop), handoffs (routing between agents), and guardrails (input/output validation). The key feature is auto-schema generation — write a Python function with type hints and the SDK converts it to a JSON tool schema automatically. Runner.run() handles the loop: call the model, check for tool calls, execute them, repeat. Handoffs let one agent transfer control to another by returning a special tool call. It's deliberately thin. OpenAI designed it as a reference implementation showing how agents should work with their API, not as a batteries-included framework.

The plain Python equivalent

The Agents SDK is already close to plain Python, which says something. Agent is a function that takes messages and returns a completion — the system prompt is the first message, tools are a dict. Runner.run() is a while loop: call openai.chat.completions.create(), check if the response has tool_calls, execute the matching functions from your tools dict, append results to messages, repeat until the model responds without tool_calls. Handoffs are an if-statement: if the model calls a "transfer_to_research" tool, call the research agent function instead. Guardrails are two lists of validation functions — run the input rules before calling the LLM, run the output rules after. The auto-schema generation is the only piece that takes more than a few lines to replicate.

Full OpenAI Agents SDK comparison →

Or build your own in 60 lines

Both CrewAI and OpenAI Agents SDK implement the same 8 patterns. An agent is a function. Tools are a dict. The loop is a while loop. The whole thing composes in ~60 lines of Python.

No framework. No dependencies. No opinions. Just the code.

Build it from scratch →