跳到正文
DEV Community· Sam Amderson·· 45 分鐘前AI 評分63

如何比較 LangGraph、CrewAI、Microsoft Agent Framework、OpenAI Agents SDK 和 Google ADK 的企業效能

Comparing Leading AI Frameworks for Enterprise Performance

AI 導讀

Sam Amderson 提出以成功任務成本、重複步驟率、故障恢復率及治理開銷評估企業 AI 框架,並提供可按自身工作負載計分的 Python 評分表。文章整理 LangGraph、CrewAI、Microsoft Agent Framework、OpenAI Agents SDK 和 Google ADK 的編排、狀態恢復及內建控制差異。

正文

An enterprise AI frameworks comparison usually ranks tools by features or raw speed, and that is why the results mislead.

Speed barely separates the leading options, because the model call dominates each run. In one recent benchmark, six mainstream frameworks averaged between 6.79 and 8.39 seconds per run.

What separates them is behavior under failure: repeated steps, wasted tokens and lost state.

This guide defines four measures that expose those gaps, checks five frameworks against them, and ends with a complete Python scorecard that you can run on your own workload data.

What Should an Enterprise AI Frameworks Comparison Actually Measure?

A fair enterprise AI frameworks comparison starts with the unit of work, not the token. Enterprises pay for finished tasks.

A run that loops, fails or loses state still spends money and delivers nothing. So the sheet needs measures tied to completed outcomes, collected over many runs on the same model and the same tasks.

Use four measures, and treat them as a framework selection scorecard:

  • Cost per successful task: total spend divided by successful runs. Failed and repeated runs raise it.
  • Repeat-step rate: the share of runs where the agent repeated a step or a tool call.
  • Crash recovery rate: the share of injected crashes where the run resumed from saved state instead of restarting.
  • Governance overhead: the extra seconds per run once tracing, approvals and audit logging are switched on.

The last measure matters more than teams expect. Oversight should scale with autonomy.

Diagram of four scorecard measures feeding one weighted score: cost per successful task at 35 percent, repeat-step rate at 25 percent, crash recovery rate at 25 percent, and governance overhead at 15 percent, which produce ranked frameworks.

A read-only agent needs light review, while an agent with production write access needs audit trails, approval gates and rollback controls.

Each control, from observability tracing to human-in-the-loop approval, adds latency and code.

Measure that cost per framework, along with token overhead from extra prompts and traces, so the cheapest option on paper does not become the most expensive after your security team signs off.

Quick check: Is cost per token the same as cost per successful task?
No. Token cost counts every run, including the ones that fail or loop. Cost per successful task divides total spend by finished runs, so wasted attempts show up in the number.

How Do LangGraph, CrewAI, Microsoft Agent Framework, OpenAI Agents SDK and Google ADK Compare?

The table summarizes what each project's official documentation says about orchestration, state and built-in controls. It does not rank them, because the right ranking depends on your measures and your weights.

Framework Orchestration model State and recovery Built-in controls
LangGraph Stateful graphs Checkpointer plus thread ID; persistent store needed in production Human-in-the-loop through checkpoints
CrewAI Flows control the app; Crews run role-based agents State management inside Flows Enterprise security features listed
Microsoft Agent Framework Graph workflows: sequential, concurrent, branching Workflow checkpointing; sessions for agents Human-in-the-loop, telemetry; docs describe a public preview
OpenAI Agents SDK Agents with handoffs Sessions for working memory; durable runs need an external engine Guardrails, tracing, human-in-the-loop, MCP
Google ADK Sequential, loop, parallel and graph workflows Sessions with rewind and migration Evaluation tooling, MCP support, A2A

Public numbers add context. Any AI agent framework benchmark has limits, and AIMultiple ran 6,500 runs across 13 frameworks on one model in October 2026.

Among four of the five frameworks above, average cost per 1,000 runs ranged from $1.48 for Google ADK to $1.88 for Microsoft Agent Framework. Failure behavior varied far more than cost.

In that benchmark, 64% of Microsoft Agent Framework runs hit an error and repeated steps, while Google ADK never repeated a step on one task.

Those results come from one model and five tasks. Treat them as a prompt to test, not a verdict.

Quick check: Should one public benchmark decide the choice?
No. A single benchmark fixes one model, one dataset and one set of tasks. Your tools and failure modes differ, so use it to shortlist candidates and then score your own runs.

How Do You Score Frameworks Against Your Own Workload?

Public benchmarks cannot know your tools, your data or your failure modes, and enterprise AI framework performance depends on all three.

Run the same workflow through each candidate, log every run and score the logs. The script below turns run records into the four measures, scales each one from 0 to 1, applies weights and ranks the frameworks.

Four-step scorecard flow: run logs are summarised into four measures per framework, normalised to a 0 to 1 scale, then ranked by weighted total using weights of 35, 25, 25 and 15, producing ranked frameworks.

Change the weights to match your risk. A regulated team might weight recovery and governance above cost.

"""Weighted scorecard for comparing AI agent frameworks on your own workload.

Input: one record per run, per framework. Replace make_sample_runs with your own logs.
Metrics (all computed per framework):
  cost_per_success  total spend divided by successful runs (lower is better)
  repeat_rate       share of runs that repeated a step (lower is better)
  recovery_rate     share of injected crashes the run resumed from (higher is better)
  governance_cost   extra seconds per run with tracing and approvals on (lower is better)
"""
import random
from dataclasses import dataclass

WEIGHTS = {
    "cost_per_success": 0.35,
    "repeat_rate": 0.25,
    "recovery_rate": 0.25,
    "governance_cost": 0.15,
}
LOWER_IS_BETTER = {"cost_per_success", "repeat_rate", "governance_cost"}


@dataclass
class Run:
    framework: str
    success: bool
    cost_usd: float
    repeated_step: bool
    crash_injected: bool
    resumed_after_crash: bool
    seconds_plain: float
    seconds_governed: float


def make_sample_runs(seed: int = 7, n: int = 100) -> list[Run]:
    """Illustrative placeholder data. It is not a benchmark of any real framework."""
    rng = random.Random(seed)
    profiles = {
        "framework_a": dict(ok=0.93, cost=0.0016, rep=0.10, rec=0.95, gov=0.6),
        "framework_b": dict(ok=0.88, cost=0.0014, rep=0.35, rec=0.40, gov=1.4),
        "framework_c": dict(ok=0.90, cost=0.0019, rep=0.20, rec=0.80, gov=0.9),
    }
    runs = []
    for name, p in profiles.items():
        for _ in range(n):
            crash = rng.random() < 0.30
            base = rng.uniform(6.5, 9.0)
            runs.append(Run(
                framework=name,
                success=rng.random() < p["ok"],
                cost_usd=p["cost"] * rng.uniform(0.8, 1.2),
                repeated_step=rng.random() < p["rep"],
                crash_injected=crash,
                resumed_after_crash=crash and rng.random() < p["rec"],
                seconds_plain=base,
                seconds_governed=base + p["gov"] * rng.uniform(0.8, 1.2),
            ))
    return runs


def summarise(runs: list[Run]) -> dict[str, dict[str, float]]:
    by_fw: dict[str, list[Run]] = {}
    for r in runs:
        by_fw.setdefault(r.framework, []).append(r)
    out = {}
    for name, rs in by_fw.items():
        successes = sum(r.success for r in rs)
        crashes = [r for r in rs if r.crash_injected]
        out[name] = {
            "cost_per_success": sum(r.cost_usd for r in rs) / max(successes, 1),
            "repeat_rate": sum(r.repeated_step for r in rs) / len(rs),
            "recovery_rate": (
                sum(r.resumed_after_crash for r in crashes) / len(crashes)
                if crashes else 0.0
            ),
            "governance_cost": sum(r.seconds_governed - r.seconds_plain for r in rs) / len(rs),
        }
    return out


def normalise(metrics: dict[str, dict[str, float]]) -> dict[str, dict[str, float]]:
    """Min-max scale each metric to 0..1, where 1 is always the best result."""
    scaled = {name: {} for name in metrics}
    for key in WEIGHTS:
        values = [m[key] for m in metrics.values()]
        lo, hi = min(values), max(values)
        for name, m in metrics.items():
            if hi == lo:
                score = 1.0
            elif key in LOWER_IS_BETTER:
                score = (hi - m[key]) / (hi - lo)
            else:
                score = (m[key] - lo) / (hi - lo)
            scaled[name][key] = score
    return scaled


def rank(runs: list[Run]) -> list[tuple[str, float]]:
    metrics = summarise(runs)
    scaled = normalise(metrics)
    totals = {
        name: sum(WEIGHTS[k] * s[k] for k in WEIGHTS) for name, s in scaled.items()
    }
    return sorted(totals.items(), key=lambda item: item[1], reverse=True)


if __name__ == "__main__":
    sample = make_sample_runs()
    for name, m in summarise(sample).items():
        print(
            f"{name}: cost/success=${m['cost_per_success']:.4f} "
            f"repeat={m['repeat_rate']:.0%} recovery={m['recovery_rate']:.0%} "
            f"governance=+{m['governance_cost']:.2f}s"
        )
    print()
    for place, (name, score) in enumerate(rank(sample), start=1):
        print(f"{place}. {name}  score={score:.2f}")

The sample data inside the script is illustrative placeholder data, not a benchmark of any real framework. Running it prints one summary line per framework, then the ranking:

framework_a: cost/success=$0.0017 repeat=8% recovery=97% governance=+0.58s
framework_b: cost/success=$0.0017 repeat=38% recovery=50% governance=+1.39s
framework_c: cost/success=$0.0021 repeat=22% recovery=79% governance=+0.92s

1. framework_a  score=1.00
2. framework_c  score=0.38
3. framework_b  score=0.34

The same four measures work when you weigh a framework build against a platform-led option, as in the debate over AI-native engineering vs traditional development. Score both on one sheet, with the same weights, so the result stays honest.

Quick check: How many runs per framework are enough?
AIMultiple used 100 runs per task per framework. Use that as a floor for stable rates, and rerun after every version bump, because behavior changes between releases.

Which Failure Modes Only Appear in Production?

Production AI agent frameworks face failure modes that demos hide, and three of them matter most. Each one raises cost per successful task while leaving the average latency chart unchanged.

Three production failure modes mapped to scorecard measures: repeated steps map to repeat-step rate, retry loops map to cost per successful task, and lost state maps to crash recovery rate, with fault tests revealing all three.

First, repeated steps. In the AIMultiple data, CrewAI repeated steps in 85% of Task 5 runs, and the longest LangGraph Task 3 run made 25 tool calls, 16 of them repeats.

Second, retry loops that multiply cost. An academic benchmark for AI-native systems found that self-healing mechanisms can act as cost multipliers on unviable workflows. Cap retries per task and alert on token spend per run.

Third, lost state and weak tool-call reliability. LangGraph needs a checkpointer and a thread ID to save state.

Production use calls for a persistent store such as PostgresSaver or SqliteSaver, because InMemorySaver loses checkpoints on restart.

State checkpointing is the base of durable execution; the OpenAI Agents SDK leaves durable execution to an external engine such as Temporal.

Distributed designs add a fourth cost. The same study found that agent-to-agent architectures mask latency but pay a reliability tax.

Test for all of these on purpose. Kill a worker mid-run, return a tool error and delay a response, then watch what each framework does.

Any serious enterprise AI frameworks comparison includes these fault tests, because they show what the average never will.

Quick check: Does a durable checkpointer fix repeated steps?
No. A checkpointer restores state after a crash or an approval pause. Repeated steps come from planning and tool use, so only repeat-step rate measured over many runs will catch them.

Run Three Fault Tests Before You Commit to a Framework

Pick one real workflow and run it through two or three candidates with the same model and the same tools. Log every run.

Inject three faults on purpose: a worker crash mid-run, a failing tool and a slow response.

Record cost per successful task, repeat-step rate, recovery rate and governance overhead.

Set your weights before you look at the totals, so the result reflects your risk and not your hopes.

Rerun the test after every major version change, because framework behavior shifts between releases.

Weigh vendor lock-in too: open protocols such as MCP lower the cost of leaving. Keep the logs, since an auditor or a CTO will ask how you chose.

If a plain function can do the job, skip the framework entirely, as Microsoft's own documentation advises. Then write down the result in one page: the weights, the four measures per framework, and the faults you injected.

That page becomes your selection record, and the next team can rerun it instead of starting from opinions.

來源:DEV Community · dev.to