AI Agent da chuyen tu cac ban demo nghien cuu sang he thong production. Du kien hon 60% ung dung AI doanh nghiep se bao gom cac thanh phan agentic vao nam 2026. Nhung viec xay dung Agent tu dau - quan ly tool loop, state, memory, xu ly loi va phoi hop multi-agent - rat phuc tap. Do la ly do framework ra doi.
Bon framework thong tri nam 2026: LangGraph, CrewAI, OpenAI Agents SDK va Claude Agent SDK. Moi framework co cach tiep can hoan toan khac nhau cho cung mot van de: trao cho LLM kha nang suy luan, lap ke hoach, su dung cong cu va hop tac.
Tong quan
| Khia canh | LangGraph | CrewAI | OpenAI Agents SDK | Claude Agent SDK |
|---|---|---|---|---|
| Nha phat trien | LangChain | CrewAI Inc. | OpenAI | Anthropic |
| Kien truc | Dua tren do thi | Dua tren vai tro | Dua tren ban giao | Vong lap tu chu |
| Triet ly | Kiem soat toi da | Hop tac nhom | Truu tuong toi thieu | Cho Agent mot may tinh |
| Ngon ngu | Python, TypeScript | Python | Python | Python, TypeScript |
| Ho tro model | Bat ky (OpenAI, Claude, local) | Bat ky | Bat ky (bat chap ten goi) | Chi Claude |
| GitHub stars | ~29k | ~40k | ~21k | ~6k |
| Phu hop nhat cho | Workflow phuc tap co state | Chuyen mon hoa multi-agent | Routing va triage | Lap trinh va tac vu nang ve file |
LangGraph: Nha xay dung do thi
LangGraph mo hinh hoa workflow cua Agent duoi dang do thi co huong co chu ky. Ban dinh nghia cac node (ham thuc hien cong viec) va edge (chuyen tiep giua chung, co the la co dieu kien). State chay qua do thi va duoc luu tru thong qua checkpointing.
Day la framework ro rang va kiem soat duoc nhat - ban tu tay noi tung buoc.
Khai niem cot loi
- StateGraph: dinh nghia do thi voi state co kieu
- Nodes: ham Python chuyen doi state
- Edges: ket noi giua cac node, co the co dieu kien
- Checkpointing: luu tru tich hop cho workflow chay dai
Vi du code
from langgraph.graph import StateGraph, MessagesState, START, END from langchain_openai import ChatOpenAI llm = ChatOpenAI(model="gpt-4o") def call_agent(state: MessagesState): response = llm.invoke(state["messages"]) return {"messages": [response]} def should_continue(state: MessagesState): last = state["messages"][-1] if last.tool_calls: return "tools" return END def call_tools(state: MessagesState): # Execute tool calls and return results results = [] for tool_call in state["messages"][-1].tool_calls: result = execute_tool(tool_call) results.append(result) return {"messages": results} graph = StateGraph(MessagesState) graph.add_node("agent", call_agent) graph.add_node("tools", call_tools) graph.add_edge(START, "agent") graph.add_conditional_edges("agent", should_continue, {"tools": "tools", END: END}) graph.add_edge("tools", "agent") app = graph.compile() result = app.invoke({"messages": [{"role": "user", "content": "What's the weather?"}]})
Diem manh
- Kiem soat chi tiet tung buoc va tung chuyen tiep
- Checkpointing va human-in-the-loop tich hop
- Ho tro TypeScript day du
- Hoat dong voi bat ky LLM provider nao
- Phu hop nhat cho workflow phuc tap co phan nhanh dieu kien va vong lap
Diem yeu
- Duong cong hoc tap doc - can hieu cac khai niem ly thuyet do thi
- Dai dong cho use case don gian - agent co ban can nhieu boilerplate hon cac framework khac
- Debug luong do thi co the kho khan neu khong co LangSmith
Gia ca
Open-source (MIT). LangSmith (nen tang observability quan ly) co cac goi tra phi cho giam sat production.
CrewAI: Nha to chuc nhom
CrewAI su dung phep an du cua con nguoi: ban tap hop mot crew gom cac agent chuyen biet, moi agent co role, goal va backstory. Cac agent hop tac tren cac task su dung tool, duoc dieu phoi boi process (tuan tu, phan cap hoac dong thuan).
Hay nghi ve no nhu viec tuyen mot doi ngu ma moi thanh vien co mot chuc danh va chuyen mon cu the.
Khai niem cot loi
- Agent: persona co role, goal, backstory va tool
- Task: nhiem vu co mo ta, dau ra ky vong va agent duoc chi dinh
- Crew: nhom agent lam viec cung nhau
- Process: chien luoc thuc thi (tuan tu, phan cap, dong thuan)
- Flow: lop orchestration huong su kien de ket noi nhieu crew
Vi du code
from crewai import Agent, Task, Crew, Process researcher = Agent( role="Senior Research Analyst", goal="Find comprehensive data about the given topic", backstory="You have 10 years of experience in technology research. " "You are thorough and always verify facts from multiple sources.", tools=[web_search_tool], verbose=True, ) writer = Agent( role="Technical Writer", goal="Create clear, engaging technical content", backstory="You write for a developer audience. " "Your articles are practical and include code examples.", tools=[file_tool], verbose=True, ) research_task = Task( description="Research the latest developments in WebAssembly in 2026. " "Focus on WASI, Component Model, and production use cases.", expected_output="A structured research document with key findings and sources.", agent=researcher, ) writing_task = Task( description="Write a blog post based on the research. " "Include code examples and Mermaid diagrams.", expected_output="A complete blog post in Markdown format.", agent=writer, context=[research_task], # Writer receives researcher's output ) crew = Crew( agents=[researcher, writer], tasks=[research_task, writing_task], process=Process.sequential, verbose=True, ) result = crew.kickoff() print(result.raw)
Diem manh
- Truu tuong dua tren vai tro truc quan - de suy luan
- Hon 100 tool integration tich hop
- Bo nho chia se giua cac agent (ngan han, dai han, entity)
- Cong dong lon nhat (~40k GitHub stars)
- Process phan cap voi agent "quan ly" uy quyen va xac nhan
Diem yeu
- Kiem soat it chi tiet hon LangGraph - ban dinh nghia vai tro, khong phai duong thuc thi chinh xac
- Process phan cap co the kho du doan khi cac agent bat dong
- Debug cuoc hoi thoai multi-agent kho hon luong single-agent
Gia ca
Open-source core (mien phi). CrewAI Platform: $99/thang (Teams) den $120k/nam (Enterprise). Gia dua tren so crew hoat dong va so lan thuc thi hang thang.
OpenAI Agents SDK: Bo dinh tuyen
OpenAI Agents SDK (nguoi ke thua tinh than cua Swarm) tap trung vao handoff - agent chuyen cuoc hoi thoai cho agent chuyen biet khac. Day la framework toi gian nhat: agent, tool, handoff va guardrail. Chi vay thoi.
Khai niem cot loi
- Agent: model + instructions + tool + handoff
- Handoff: chuyen tiep den agent khac (duoc mo hinh hoa nhu tool ma LLM co the goi)
- Guardrail: xac thuc input/output chay song song voi agent
- Runner: thuc thi agent loop
- Tracing: observability tich hop cho moi cuoc goi LLM, tool va handoff
Vi du code
from agents import Agent, Runner, handoff, InputGuardrail, GuardrailFunctionOutput from pydantic import BaseModel class SafetyCheck(BaseModel): is_safe: bool reason: str async def content_safety(ctx, agent, input_text): result = await Runner.run( Agent(name="Safety", instructions="Check if input is safe. No PII."), input_text, context=ctx, ) output = SafetyCheck.model_validate_json(result.final_output) return GuardrailFunctionOutput( output_info=output, tripwire_triggered=not output.is_safe ) billing_agent = Agent( name="Billing Agent", instructions="You handle billing inquiries. Be precise with numbers.", tools=[lookup_invoice, process_payment], ) refund_agent = Agent( name="Refund Agent", instructions="You process refund requests. Always verify the order first.", tools=[lookup_order, issue_refund], ) triage_agent = Agent( name="Triage Agent", instructions="Route the customer to the right specialist. " "Ask clarifying questions if needed.", handoffs=[billing_agent, refund_agent], input_guardrails=[InputGuardrail(guardrail_function=content_safety)], ) result = await Runner.run(triage_agent, "I need a refund for order #4521") print(result.final_output) # The triage agent routes to refund_agent, which processes the refund
Diem manh
- Mau handoff gon gang - tu nhien cho workflow routing/triage
- Guardrail chay song song voi thuc thi (fail-fast, khong blocking)
- Dashboard tracing tich hop de debug
- Bat chap ten goi, ho tro cac model khong phai cua OpenAI
- Truu tuong toi thieu - de hieu va de mo rong
Diem yeu
- Quan ly state chua truong thanh bang LangGraph
- Khong co persistence hoac checkpointing tich hop
- Ecosystem tool cua ben thu ba nho hon
- Thiet ke lay handoff lam trung tam co the khong phu hop moi kien truc
Gia ca
Open-source (MIT). Ban tra phi theo token cho bat ky model nao su dung.
Claude Agent SDK: Nha phat trien
Claude Agent SDK co cach tiep can khac: thay vi dinh nghia workflow hay role, ban cho agent mot bo cong cu va de no tu tim cach hoan thanh nhiem vu. No su dung cung vong lap tu chu nhu Claude Code - doc, hanh dong, xac minh, lap lai.
Khai niem cot loi
- query(): diem vao chinh khoi dong agent loop
- Cong cu tich hop: Read, Write, Edit, Bash, Glob, Grep, WebSearch, WebFetch
- Custom tool qua MCP: dinh nghia tool la in-process MCP server
- Sub-agent: agent chuyen biet ma agent cha co the uy quyen
- Sessions: duy tri context qua nhieu lan tuong tac
Vi du code
import { tool, createSdkMcpServer, query } from "@anthropic-ai/claude-agent-sdk"; import { z } from "zod"; const searchDocs = tool( "search_docs", "Search the internal documentation for relevant information", { query: z.string().describe("Search query") }, async ({ query }) => { const results = await vectorStore.similaritySearch(query, 5); return { content: [{ type: "text", text: results.map(r => r.pageContent).join("\n\n") }], }; } ); const docsServer = createSdkMcpServer({ name: "docs", version: "1.0.0", tools: [searchDocs], }); for await (const message of query({ prompt: "Find how authentication works in our system and write a summary", options: { mcpServers: { docs: docsServer }, allowedTools: ["Read", "Glob", "Grep", "mcp__docs__search_docs"], }, })) { if (message.type === "result" && message.subtype === "success") { console.log(message.result); } }
Diem manh
- Tich hop MCP cap first-class - ket noi voi bat ky ecosystem MCP server nao
- Cong cu tich hop cho thao tac file, terminal va truy cap web
- Tu dong nen context cho codebase lon
- Sub-agent song song cho cac tac vu phuc tap
- Cung engine voi Claude Code - da duoc thu nghiem thuc te tren workflow phat trien that
Diem yeu
- Chi ho tro model Claude - khong ho tro nhieu provider
- Framework moi hon voi cong dong nho hon
- Can Node.js runtime ngay ca voi Python SDK
- Kiem soat workflow it ro rang hon so voi LangGraph
Gia ca
Open-source. Gia token Claude API tieu chuan. Managed Agents (phien ban hosted): $0.08 moi gio session ngoai chi phi token.
Khi nao chon cai nao
Chon LangGraph neu:
- Ban can kiem soat chinh xac tung buoc cua workflow
- Use case cua ban lien quan den logic dieu kien phuc tap va vong lap
- Ban can persistence va human-in-the-loop checkpoint tich hop
- Ban can su dung nhieu LLM provider trong cung mot workflow
Chon CrewAI neu:
- Ban muon truu tuong dua tren vai tro truc quan
- Nhiem vu cua ban lien quan den nhieu agent co chuyen mon khac nhau
- Ban can cac agent hop tac va truyen context cho nhau
- Ban coi trong cong dong lon nhat va nhieu integration tich hop nhat
Chon OpenAI Agents SDK neu:
- Mau chinh cua ban la dinh tuyen cuoc hoi thoai den chuyen gia
- Ban can guardrail xac thuc input/output song song
- Ban muon truu tuong don gian nhat voi boilerplate toi thieu
- Tracing va observability tich hop la quan trong
Chon Claude Agent SDK neu:
- Agent cua ban can doc, viet va thuc thi code
- Ban muon tich hop MCP server cap first-class
- Ban can agent tu chu co kha nang lap lai va tu sua loi
- Ban da su dung Claude va muon tich hop sau nhat
Co the ket hop cac framework khong?
Co. Mot mau pho bien la su dung mot framework cho orchestration va mot framework khac cho tung agent rieng le:
- LangGraph cho do thi workflow tong the
- CrewAI cho node cu the can hop tac multi-agent
- Claude Agent SDK cho sub-task lien quan den lap trinh qua MCP
- OpenAI Agents SDK cho triage va routing huong toi khach hang
Cac framework nay khong loai tru lan nhau. Hay su dung cai phu hop voi tung phan cua he thong.
Ket luan
Moi framework co mot dinh huong ro rang:
- LangGraph toi uu hoa cho kiem soat - ban quyet dinh tung chuyen tiep
- CrewAI toi uu hoa cho hop tac - cac agent lam viec nhu mot doi
- OpenAI Agents SDK toi uu hoa cho su don gian - truu tuong toi thieu, handoff gon gang
- Claude Agent SDK toi uu hoa cho tu chu - cho no cong cu va de no lam viec
Lua chon dung phu thuoc vao workflow, doi ngu va stack cong nghe hien tai cua ban. Chon cai phu hop voi use case chinh, hoc ky no va dua cac framework khac vao khi ban gap the manh cua chung.