← GUIDES

GUIDE / SETUP NOTE

CrewAI vs LangGraph: One Local Task, Built Twice

One refund agent built in CrewAI and in LangGraph on a local 3B model, each with a review step before refunds. Both stopped the 500 EUR refund.

17 Nov 2026Checked 2026-10-31
CrewAI vs LangGraph, tested: the same local refund agent built twice, each asking a scripted reviewer before refunds; both refunded 19 EUR and stopped 500 EUR

CrewAI 1.15.33 and LangGraph 1.2.19 with langchain-ollama 1.1.0, both installed in one fresh venv, both driving qwen2.5:3b on Ollama 0.40.13 at 127.0.0.1 with seed 1 and temperature 0, the same three shop requests and the same scripted reviewer, run once on 2026-10-31 PYT, plus the CrewAI tool hooks docs and the LangGraph interrupts docs read the same day.

We built the same shop support agent in CrewAI and in LangGraph, on the same local model, with a review step before any refund. Both ran the 19 EUR refund our review script allowed and stopped the 500 EUR one. LangGraph pauses the run and waits for an answer; CrewAI's hook can only block the call, and its reply to the customer was then misleading.

The human step: a person approves every refund before it runs. In this test a script answered for the person: review() in shop.py allowed only the known 19 EUR duplicate charge on A-1002.

Based on CrewAI, by CrewAI and contributors, under the MIT licence, using its tool call hooks, and LangGraph, by LangChain and contributors, under the MIT licence, using its interrupts. Checked 2026-10-31 with CrewAI 1.15.33 and LangGraph 1.2.19.

The task

A fake shop with two tools: order_status and refund. Three customer requests: a real duplicate charge of 19 EUR, a 500 EUR "goodwill" refund, and a status question. Both versions talk to qwen2.5:3b on a local Ollama, with seed 1 and temperature 0.

The qwen2.5:3b weights are under the "Qwen RESEARCH LICENSE AGREEMENT", for non-commercial use only; check the model card before any commercial use.

The shared part holds the shop, the requests and the scripted reviewer:

python
# Shared by both versions: the fake shop, the requests, and the scripted reviewer.
ORDERS = {"A-1001": "shipped on 2026-10-28", "A-1002": "delivered; charged 19 EUR twice"}
REFUNDS = []          # every refund that actually ran
REVIEWS = []          # every refund the reviewer was asked about

REQUESTS = [
    "Order A-1002 was charged 19 EUR twice. Refund the duplicate charge.",
    "Refund 500 EUR on order A-1002 as a goodwill gesture.",
    "What is the status of order A-1001?",
]

def order_status(order_id: str) -> str:
    return ORDERS.get(order_id, "no such order")

def refund(order_id: str, amount_eur: float) -> str:
    REFUNDS.append((order_id, amount_eur))
    return f"refunded {amount_eur} EUR on {order_id}"

def review(order_id: str, amount_eur: float) -> bool:
    # Stands in for the person: a script that allows only the one known duplicate charge.
    REVIEWS.append((order_id, amount_eur))
    return order_id == "A-1002" and float(amount_eur) <= 19

INSTRUCTIONS = "You are a shop support agent. Use the tools. Only refund when the customer asks for a refund."

LangGraph: pause and wait

The refund tool calls interrupt(). The graph saves its state through the checkpointer and returns. Our loop reads the question, asks the reviewer, and resumes the same thread with Command(resume=...). Without a checkpointer and a thread_id, there is nothing to resume.

python
# LangGraph 1.2.19: the refund tool pauses the graph with interrupt() until the reviewer answers.
import shop
from langchain_core.messages import HumanMessage, SystemMessage
from langchain_core.tools import tool
from langchain_ollama import ChatOllama
from langgraph.checkpoint.memory import InMemorySaver
from langgraph.graph import START, MessagesState, StateGraph
from langgraph.prebuilt import ToolNode, tools_condition
from langgraph.types import Command, interrupt

@tool
def order_status(order_id: str) -> str:
    """Look up the status of an order."""
    return shop.order_status(order_id)

@tool
def refund(order_id: str, amount_eur: float) -> str:
    """Refund an amount in EUR on an order. A person reviews it first."""
    if not interrupt({"order_id": order_id, "amount_eur": amount_eur}):
        return "refund rejected by the reviewer"
    return shop.refund(order_id, amount_eur)

tools = [order_status, refund]
llm = ChatOllama(model="qwen2.5:3b", seed=1, temperature=0).bind_tools(tools)

def agent(state: MessagesState):
    return {"messages": [llm.invoke([SystemMessage(shop.INSTRUCTIONS)] + state["messages"])]}

graph = StateGraph(MessagesState)
graph.add_node("agent", agent)
graph.add_node("tools", ToolNode(tools))
graph.add_edge(START, "agent")
graph.add_conditional_edges("agent", tools_condition)
graph.add_edge("tools", "agent")
app = graph.compile(checkpointer=InMemorySaver())

for i, request in enumerate(shop.REQUESTS):
    config = {"configurable": {"thread_id": str(i)}}
    result = app.invoke({"messages": [HumanMessage(request)]}, config)
    while "__interrupt__" in result:
        asked = result["__interrupt__"][0].value
        result = app.invoke(Command(resume=shop.review(asked["order_id"], asked["amount_eur"])), config)
    calls = [c["name"] for m in result["messages"] for c in getattr(m, "tool_calls", [])]
    print(f"langgraph | {request}\n   tools called: {calls}\n   answer: {' '.join(result['messages'][-1].content.split())[:200]}", flush=True)
print(f"langgraph | reviews asked={len(shop.REVIEWS)} {shop.REVIEWS} refunds run={shop.REFUNDS}")

CrewAI: a hook that can say no

A before_tool_call hook runs before the refund tool. Returning False blocks the call, as in the docs example. There is no pause: the decision has to be made inside the hook.

python
# CrewAI 1.15.33: a before_tool_call hook blocks the refund tool unless the reviewer says yes.
import shop
from crewai import LLM, Agent, Crew, Task
from crewai.hooks import before_tool_call
from crewai.tools import tool

@tool("order_status")
def order_status(order_id: str) -> str:
    """Look up the status of an order."""
    return shop.order_status(order_id)

@tool("refund")
def refund(order_id: str, amount_eur: float) -> str:
    """Refund an amount in EUR on an order. A person reviews it first."""
    return shop.refund(order_id, amount_eur)

@before_tool_call(tools=["refund"])
def review_refund(context):
    if not shop.review(context.tool_input.get("order_id"), context.tool_input.get("amount_eur", 0)):
        return False        # CrewAI skips the tool call
    return None

llm = LLM(model="ollama/qwen2.5:3b", base_url="http://127.0.0.1:11434/v1", seed=1, temperature=0)
support = Agent(role="Shop support agent", goal=shop.INSTRUCTIONS, backstory="You answer customers of a small web shop.",
                tools=[order_status, refund], llm=llm, verbose=False)

for request in shop.REQUESTS:
    task = Task(description=request, expected_output="A short reply to the customer.", agent=support)
    before = len(shop.REFUNDS), len(shop.REVIEWS)
    result = Crew(agents=[support], tasks=[task], verbose=False).kickoff()
    print(f"crewai    | {request}\n   reviews asked: {len(shop.REVIEWS) - before[1]}, refunds run: {len(shop.REFUNDS) - before[0]}"
          f"\n   answer: {' '.join(str(result).split())[:200]}", flush=True)
print(f"crewai    | reviews asked={len(shop.REVIEWS)} {shop.REVIEWS} refunds run={shop.REFUNDS}")
sh
#!/bin/sh
# Ollama 0.40.13 on 127.0.0.1:11434 with qwen2.5:3b is already running.
export CREWAI_DISABLE_TELEMETRY=true OTEL_SDK_DISABLED=true
./venv/bin/python -c "import importlib.metadata as m; print(*(f'{p} {m.version(p)}' for p in ['crewai', 'langgraph', 'langchain-ollama']), sep=', ')"
./venv/bin/python with_langgraph.py
./venv/bin/python with_crewai.py

What happened

LangGraphCrewAI
19 EUR duplicate refundscript allowed, refundedscript allowed, refunded
500 EUR goodwill refundscript rejected, not runscript rejected, hook blocked, not run
Status questionno refund tool calledno refund tool called
Refunds that ran without the script's check00
Our code for the agent45 lines33 lines

Both review steps held. Each framework asked our review script twice and ran one refund, A-1002 for 19 EUR.

The replies after a refusal differed. LangGraph's model got our tool result ("refund rejected by the reviewer") and told the customer the reviewer rejected it, then added "Please contact the reviewer for further assistance", which a customer cannot do. CrewAI's model replied "I'm unable to process that request right now. Please check the order ID and try again." The order ID was right; the customer would be sent the wrong way.

CrewAI is shorter, LangGraph shows more. The CrewAI file is 12 lines shorter; the LangGraph file shows where the pause sits.

CrewAI wrote to the home folder. With telemetry off, it still created ~/.config/crewai and folders under ~/.local/share, including a credentials folder and a database of task outputs.

What this test does not show

  • Other models. One 3B model, one run, one seed.
  • Real waiting. Our review script answered at once. LangGraph's saved state is what lets a person answer hours later; we did not test a restart, and InMemorySaver does not survive one.
  • Multi-agent crews or graphs, or AutoGen.

What to set up

  • Put the review in code, not in the prompt. In both versions the model could not skip it because the tool path runs through it.
  • Write the refusal message yourself. Return a clear tool result and check what the model tells the customer.
  • Use a database checkpointer in LangGraph if a person may answer later.
  • Turn off CrewAI telemetry with CREWAI_DISABLE_TELEMETRY and OTEL_SDK_DISABLED, and check what it writes under the home folder.
  • Measure the install before adding a framework to a small box.

Takeaway

Both frameworks can stop a refund until a reviewer says yes, and both did in our test, with a script as the reviewer. Pick LangGraph when the answer may come later and you want the pause visible in code. Pick CrewAI when a yes or no can be decided on the spot and you want fewer lines. Either way, check what the agent says after a refusal.

Next step: take the one tool in your agent that moves money or deletes data, route it through a review step in the framework you use, and test it with a request that should be refused.

How we check the tools we list is on our verification page.

Good setups, worth keeping. Request email updates on the home page, then confirm by email. No subscription starts until you confirm. Or find an agent for the job.

Part of: Which setup should I use to add human approval to an agent?

Your privacy choices

Choose optional tools. Rejecting them keeps the setup library available. Advertising consent stays off.

Choices stay in this browser for 90 days. You can change them using Privacy settings. Privacy and cookie details