---
title: "CrewAI vs LangGraph: the same agent run built in both"
description: "CrewAI vs LangGraph on one agent run: trace id, retry, human pause and cost cap built in CrewAI 1.15 and LangGraph 1.2. Glue lines, resume, footprint."
url: "https://madsalt.tech/blog/crewai-vs-langgraph/"
author: "Denys Zaichenko"
author_url: "https://madsalt.tech/about/"
language: "en"
published: 2026-11-06
---

# CrewAI vs LangGraph: the same agent run built in both

TL;DR

I built the same small run in both frameworks: an orchestrator, a research step over three documents, and a writer that fails twice, then waits for a person, then succeeds. LangGraph needed 26 lines of glue code for the trace id, retry, human pause and cost cap; CrewAI needed 30. Retry is native in both and re-runs only the failed step. Pausing and resuming from saved state worked in LangGraph across two separate OS processes; in CrewAI it worked only inside one process, and only after a workaround. The install was 41 packages and 30 MB for LangGraph, 137 packages and 669 MB for CrewAI. In CrewAI's hierarchical process, the writer's final failure never reached my code. Everything here uses a fake model on one machine, so none of it is a production claim.

I'm Denys, a Forward Deployed Engineer. When I search for "CrewAI vs LangGraph" I mostly find feature lists. I wanted to see what each framework asks me to write by hand for four things I need in every multi-agent run: one trace id through every hand-off, a retry, a pause for a human, and a cost cap. So I built the same run in both and counted.

The scenario comes from my [multi-agent orchestration dashboard](https://madsalt.tech/work/multi-agent-orchestration/), a prototype on sample data that shows hand-offs between agents under one trace id. The failures I care about are the ones from [what broke in 3,315 agent runs](https://madsalt.tech/blog/multi-agent-orchestration-what-broke/): the seams between agents, not the model.

## How did I run the CrewAI vs LangGraph comparison?

The method, short version. The full list of what I did not test is at the end.

- **Same scenario, two builds.** One shared fake model in `common.py` (16 lines), written once and used by both.
- **No hosted model.** The fake model is deterministic. It raises an error on the first two writer calls and costs a fixed 100 tokens per call. No API key and no model-provider network call.
- **One machine.** A Mac with Apple silicon (arm64), CPython 3.12.14.
- **Versions.** langgraph 1.2.20 and crewai 1.15.36, run on 6 November 2026.
- **Docs first, source second.** I read the official docs for each framework before writing code. Where the docs did not answer (CrewAI's agent retry, its delegation tool, checkpoint restore) I read the installed package source and ran it. Those points are "source read plus a run", not a documented contract.

The timings in this article come from a fake model, so they measure the framework overhead on my laptop and nothing about production performance.

## What did I build in both?

The run: orchestrator, then research (three documents), then writer. The writer fails on attempt 1, is retried once, fails again, and the run pauses for a simulated human approval. After approval it resumes and the writer succeeds.

![The same run in both frameworks. A normal run, and what happens when the writer fails. The run: orchestrator → research, 3 docs → writer → done; When the writer fails twice: writer → retry once → human approves → writer.](https://madsalt.tech/charts/en/crewai-vs-langgraph-scenario.svg)

*Figure 1. The scenario I built in both. Source: my runs with a fake model, 6 November 2026; langgraph 1.2.20, crewai 1.15.36.*

The two builds do not make the same number of model calls, and that is a property of the frameworks, not a flaw in the test. In LangGraph each research document is its own node call: orchestrator, 3 research calls and the writer make 7 calls and 700 tokens. In CrewAI the research task is one agent call, so a full sequential run is researcher 1 plus writer 3 (two failures and the success): 4 calls and 400 tokens. CrewAI's hierarchical variant, where a manager agent delegates, made 7 calls and 700 tokens because the manager's calls count.

My main CrewAI build uses `Process.sequential` with a short hand-written Python `run()` function doing the orchestration. The reason is in the hierarchical section below.

## How much glue code does each need?

I marked every line of both files by purpose and counted non-blank, non-comment lines.

| Lines of code    | LangGraph | CrewAI |
| ---------------- | --------- | ------ |
| Framework wiring | 101       | 89     |
| Trace id         | 4         | 11     |
| Retry            | 4         | 2      |
| Human pause      | 5         | 10     |
| Cost cap         | 13        | 7      |
| Total file       | 127       | 119    |

The four glue categories add up to 26 lines for LangGraph and 30 for CrewAI. That is the comparison I would trust; the wiring row is not. It includes imports, the run harness, the benchmark and cap modes, and in LangGraph about 15 lines for the start and resume modes I used to prove resume across two processes. The CrewAI human-pause count of 10 includes the workaround described below.

![Hand-written glue lines per feature. Orange: CrewAI 1.15.36, blue: LangGraph 1.2.20. Lines of code, non-blank. LangGraph, trace id: 4; CrewAI, trace id: 11; LangGraph, retry: 4; CrewAI, retry: 2; LangGraph, human pause: 5; CrewAI, human pause: 10; LangGraph, cost cap: 13; CrewAI, cost cap: 7.](https://madsalt.tech/charts/en/crewai-vs-langgraph-glue.svg)

*Figure 2. Glue lines I had to write for each feature. LangGraph 26 in total, CrewAI 30. Source: my runs with a fake model, 6 November 2026.*

The totals are close. The distribution is not. LangGraph spends its lines on the cost cap, because it has no meter: I keep `tokens` and `cap` in state and check them in every node. CrewAI spends them on the trace id and the pause.

## How does each one retry a failed agent?

Both have native retry, and both re-run only the part that failed. In neither build did the orchestrator or the researcher run again.

|                          | LangGraph 1.2.20                                                                 | CrewAI 1.15.36                                    |
| ------------------------ | -------------------------------------------------------------------------------- | ------------------------------------------------- |
| Setting                  | `RetryPolicy(max_attempts=2)` on the node                                        | `Agent(max_retry_limit=1)` on the agent           |
| Lives on                 | The node                                                                         | The agent                                         |
| Counting                 | 2 = two total attempts                                                           | 1 = one retry, so two total attempts              |
| Cost of a failed attempt | Lost from state, because a raising node returns no update; I add it back by hand | Counted, because the meter sits in the LLM object |

The counting difference is easy to trip over. `max_attempts=2` and `max_retry_limit=1` mean the same thing.

What happens after the retries are used up is where they split. LangGraph 1.2 has an [`error_handler`](https://docs.langchain.com/oss/python/langgraph/fault-tolerance) on the node that can route the run somewhere else. CrewAI has no such hook: the exception propagates out of `crew.kickoff()` and I catch it in my own code.

```python
g.add_node("writer", writer,
           retry_policy=RetryPolicy(max_attempts=2, initial_interval=0.0, jitter=False, retry_on=LLMFail),
           error_handler=writer_failed, destinations=("human_review", END))

def writer_failed(state, error: NodeError):
    return Command(goto="human_review", update={"tokens": state["tokens"] + COST * 2,
        "trail": [msg(state, "writer", "human_review", f"retries exhausted: {error.error}")]})
```

The CrewAI side of the same thing is one argument on the agent:

```python
writer = Agent(role="Writer", goal="write summary", backstory="writes", llm=llm,
               allow_delegation=False, max_retry_limit=1)
```

CrewAI's retry is simpler to declare. LangGraph's lets the graph decide where to go next.

## Can a person pause the run and resume it later?

This is the human-in-the-loop question, and it was the biggest difference I found.

In LangGraph the human step is a node that calls [`interrupt()`](https://docs.langchain.com/oss/python/langgraph/interrupts). The run really stops, and the saved state says which node is next. I resume with `Command(resume=...)` and a [`thread_id`](https://docs.langchain.com/oss/python/langgraph/persistence), with a SQLite checkpointer holding the state.

```python
def human_review(state):
    answer = interrupt({"question": "approve another try?", "trace_id": state["trace_id"]})
    return Command(goto="writer", update={"trail": [msg(state, "human_review", "writer", f"human said: {answer}")]})
```

I checked resume twice. First in one process with a new graph object and a new SQLite connection. Then across two OS processes: the first printed `paused thread: run-ef3a`, the second printed `next before resume: ('human_review',)` and finally `status: done tokens: 700 trail: 5`.

```python
conn = sqlite3.connect(DB, check_same_thread=False)
graph = make_graph(llm, SqliteSaver(conn))
graph.invoke(Command(resume="approved"), {"configurable": {"thread_id": trace_id}})
```

CrewAI is different. It has `Task(human_input=True)`, but that is a terminal `input()` prompt after the agent answers, not a pause on failure. I read about it in the docs and did not run it. For my scenario the "human step" is my own `except LLMFail` branch in `run()`, so the framework has no pause state at all.

For resume I used CrewAI's checkpoints: `Crew(checkpoint=CheckpointConfig(...))` writes JSON files, and `Crew.from_checkpoint(...)` restores the crew. It resumed within one process, and the researcher was not re-run. I did not test it across processes.

It did not work out of the box, though. Restoring from a checkpoint rebuilt the agents with a built-in provider client for the model name `fake-llm`, and the run failed with:

```
MissingAPIKeyError: <PROVIDER>_API_KEY is required for model 'fake-llm' but is not set or is still the placeholder 'YOUR_API_KEY'
```

I redacted the provider name. The finding is that a custom LLM object does not survive a checkpoint restore. The workaround is three lines per agent, and I did not find it in the docs I read:

```python
restored = Crew.from_checkpoint(CheckpointConfig(location=CKPT, restore_from=newest))
for agent in restored.agents:
    agent.llm = llm
    agent.agent_executor = None
out = restored.kickoff(inputs={"trace_id": TRACE["id"]})
```

If you use the stock model classes, you may never hit this. If you plug in your own model wrapper, you will.

## Where does one trace id get you?

I wanted every hand-off to carry one run-wide id, so a person reading a log can follow the whole run.

LangGraph gives you `thread_id` for free, and I used it as the trace id. The id inside each message is hand-written: a `trace_id` field in state and a `msg()` helper that every node must call. That is 4 lines, but one call per node. The ordered trail lives in a state field and I read it from the final checkpoint:

```
1 run-eeaf orchestrator -> research | [orchestrator] summarise 3 documents
2 run-eeaf research -> writer | 3 summaries
3 run-eeaf writer -> human_review | retries exhausted: fake writer failure #2
4 run-eeaf human_review -> writer | human said: approved
5 run-eeaf writer -> END | [writer] [research] doc-A [research] doc-B ...
```

The two failed writer attempts are invisible in this trail. A node that raises loses its state update, so only the error handler's message shows that anything went wrong.

CrewAI interpolates `{trace_id}` into task descriptions out of the box, but its events do not carry the id. I used a module-level global and an event listener subclass: 11 lines. The trail is per-agent events, not hand-offs:

```
1 Researcher agent_execution_started
2 Writer agent_execution_started
3 Writer error: fake writer failure #1
4 Writer agent_execution_started
5 Writer error: fake writer failure #2
6 human approved (simulated)
7 Writer agent_execution_started
```

This one shows both failures, which the LangGraph trail hides. So each gives you half of what I want: LangGraph gives hand-offs with an id but misses failed attempts; CrewAI sees every attempt but I have to attach the id myself.

## What about a cost cap?

Neither framework gave me a budget setting. I found no built-in budget API in the docs I queried.

In LangGraph I keep `tokens` and `cap` in state and add an `over_cap()` check to each node, ending with `Command(goto=END)`. That is the 13 lines. With the cap at 400, the run stopped before the writer with `stopped: cost cap`, 400 tokens and 4 calls.

In CrewAI I count inside the custom model object and raise an exception:

```python
class FakeCrewLLM(BaseLLM):
    def call(self, messages, tools=None, callbacks=None, available_functions=None,
             from_task=None, from_agent=None, response_model=None):
        role = from_agent.role if from_agent else "Orchestrator"
        if METER.tokens + COST > METER.cap:
            raise BudgetExceeded(f"cap {METER.cap} hit at {METER.tokens}")
        METER.tokens += COST
        text = FAKE.complete(role.lower(), str(messages)[-60:])
        return f"Thought: done\nFinal Answer: {text}"
```

That is 7 lines and it counts failed attempts too. The catch: with the cap at 250 the run stopped with `BudgetExceeded: cap 250 hit at 200`, after the researcher and one failed writer attempt. The framework treated my budget exception as a retryable error and spent the writer's retry slot on it. A cap that burns a retry is not what I wanted, and it is the kind of thing you only see by running it.

A cap stops one run. What a whole agent costs per month, model by model, is in [how much an AI agent costs per month](https://madsalt.tech/blog/how-much-does-an-ai-agent-cost/).

## What does CrewAI's hierarchical process change?

In [CrewAI's hierarchical process](https://docs.crewai.com/v1.15.35/en/learn/hierarchical-process), a manager agent delegates to the others. I ran it with a scripted fake manager that always delegates and then answers.

The writer retried (agent-level retry worked) and failed a second time. The run still ended with `status: done`, the output `delegated task finished` and 700 tokens. Nothing reached `kickoff()`.

The reason is in the source of crewai 1.15.36. In [`crewai/tools/agent_tools/base_agent_tools.py`](https://github.com/crewAIInc/crewAI/blob/1.15.36/lib/crewai/src/crewai/tools/agent_tools/base_agent_tools.py), lines 121-124, the delegation tool wraps `selected_agent.execute_task(...)` in `except Exception` and returns an error string to the manager. So the failure becomes text for the manager model, not an exception for your code. A hand-written pause trigger would have to inspect events or the manager's text.

What I could not test is how a real manager model reacts to that error string. Mine was scripted, so I do not know whether a real one would notice the failure, retry, give up, or report success. That is why my main CrewAI build is sequential: it was the only mode where I could make the writer's failure reach the pause path.

## How do footprint and timing compare?

|                          | LangGraph | CrewAI sequential | CrewAI hierarchical |
| ------------------------ | --------- | ----------------- | ------------------- |
| Median of 5 runs         | 0.0099 s  | 0.0714 s          | 0.0608 s            |
| First run                | 0.015 s   | 1.34 s            | 0.139 s             |
| Packages (`uv pip list`) | 41        | 137               | 137                 |
| site-packages (`du -sh`) | 30 MB     | 669 MB            | 669 MB              |

The timings are in-process loops, warm, after import. Each run includes the pause and resume path and the checkpoint writes. CrewAI's 1.34 s first run was lazy initialisation, it happened once and I did not repeat it. I did not measure process start time with imports. With a fake model these numbers describe framework overhead on one laptop, and they say nothing about a run that waits seconds for a hosted model.

![Installed packages. uv pip list, one Mac, arm64. site-packages: 30 MB vs 669 MB. LangGraph, packages: 41; CrewAI, packages: 137.](https://madsalt.tech/charts/en/crewai-vs-langgraph-footprint.svg)

*Figure 3. Packages in a clean environment: LangGraph 1.2.20 against CrewAI 1.15.36. Source: my install, 6 November 2026.*

The size difference is more useful than the timing. CrewAI pulls in a vector database client, an ONNX runtime and more; the install is 137 packages against 41. If you ship containers or run on small machines, that matters.

One install note, because it cost me time. My default `uv` Python on this Mac was x86_64, and `uv add crewai` failed three times with three different errors: no wheel for `onnxruntime`, then a failed build of `cryptography`, then a failed build of `lancedb`. Pinning around each one only moved the failure. Using the arm64 Homebrew Python fixed it with no pins; LangGraph installed on either architecture.

## Which one for which team?

LangGraph vs CrewAI comes down to how your run behaves when it has to stop. This is my reading of one small experiment, so take it as a starting point.

- **LangGraph** fits when the run has to stop and come back: a human approval, a long wait, a process restart in between. Resume across two processes worked, and routing after a failed retry is native. You write a bit more of the graph yourself. It is also the lighter install. If you came here from "CrewAI vs LangChain", note that LangGraph's docs live on docs.langchain.com and it installs `langchain-core`, so the LangChain family is part of what you take on.
- **CrewAI** fits when you think in roles and tasks and want a crew running quickly. Agent-level retry is a single argument. If you need pause and resume, expect to write more glue code and check your own model wrapper against checkpoint restore.
- **Neither** gave me a cost cap or a complete trace id for free. If you need those for a multi-agent framework in production, plan to write them in either one.
- **Hierarchical CrewAI** deserves a test with your real manager model before you rely on it to surface a failed worker.

## Method, and what I did not test

Sources: [LangGraph, interrupts](https://docs.langchain.com/oss/python/langgraph/interrupts), [LangGraph, fault tolerance](https://docs.langchain.com/oss/python/langgraph/fault-tolerance), [LangGraph, persistence](https://docs.langchain.com/oss/python/langgraph/persistence), [CrewAI, hierarchical process](https://docs.crewai.com/v1.15.35/en/learn/hierarchical-process), [CrewAI source 1.15.36](https://github.com/crewAIInc/crewAI/blob/1.15.36/lib/crewai/src/crewai/tools/agent_tools/base_agent_tools.py).

- **No real model.** No hosted model was called. ReAct parsing, prompt size, real token counts and a real manager reacting to a delegation error are untested. The token "costs" are a fixed 100 per fake call, not measured usage.
- **CrewAI human input and guardrails.** `Task(human_input=True)` and `Task(guardrail=...)` were read in the docs, not run.
- **CrewAI resume** across separate OS processes was not run, nor was its checkpoint with the SQLite provider.
- **Hierarchical mode** cannot reach the pause path (see above), so I ran neither a pause nor a cost-cap case there.
- **LangGraph** was not tested with the async or Postgres checkpointers or the `stream_events` API. LangSmith tracing was not set up; the package is a dependency but I set no key.
- **Scale.** No concurrency, no parallel runs, no memory use, no import time.
- **Other machines.** One Mac, medians of 5 runs. The Intel/x86_64 route for CrewAI failed on wheels, so every result is arm64.
- **Code.** The excerpts and line counts come from throwaway files that are not published.

The trace id and hand-off idea comes from the [multi-agent orchestration case](https://madsalt.tech/work/multi-agent-orchestration/), which runs on sample data. The failures that made me care about these four features are in [what broke in 3,315 agent runs](https://madsalt.tech/blog/multi-agent-orchestration-what-broke/).

## My similar case

For a travel agency I built a package-holiday price benchmark. On one site it went from 8 to 43 dates a minute with no browser to keep alive, and the browser pool refills itself after an outage. See the [travel price intelligence case](https://madsalt.tech/work/travel-price-intelligence/).

If you want the agents built for you rather than a framework to learn, that is my [AI agent development](https://madsalt.tech/services/ai-agent-development/) work.

Building agents and torn between frameworks? Write to me with the job they must do and we'll work out the best setup.

Building an agent for real work?

Tell me what you have now and what you need. I'll reply with the option I'd pick.

[Write to me](https://madsalt.tech/#contact)
