spinny:~/writing $ less agentic-ai-frameworks-comparison.md
12AI 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.34Bon 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.56## Tong quan78| Khia canh | LangGraph | CrewAI | OpenAI Agents SDK | Claude Agent SDK |9|--------|-----------|--------|-------------------|-----------------|10| **Nha phat trien** | LangChain | CrewAI Inc. | OpenAI | Anthropic |11| **Kien truc** | Dua tren do thi | Dua tren vai tro | Dua tren ban giao | Vong lap tu chu |12| **Triet ly** | Kiem soat toi da | Hop tac nhom | Truu tuong toi thieu | Cho Agent mot may tinh |13| **Ngon ngu** | Python, TypeScript | Python | Python | Python, TypeScript |14| **Ho tro model** | Bat ky (OpenAI, Claude, local) | Bat ky | Bat ky (bat chap ten goi) | Chi Claude |15| **GitHub stars** | ~29k | ~40k | ~21k | ~6k |16| **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 |1718## LangGraph: Nha xay dung do thi1920LangGraph 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.2122Day la framework ro rang va kiem soat duoc nhat - ban tu tay noi tung buoc.2324```mermaid25graph LR26 Start --> Router[Router Node]27 Router -->|needs research| Research[Research Node]28 Router -->|needs code| Code[Code Node]29 Research --> Synthesize[Synthesize Node]30 Code --> Synthesize31 Synthesize --> End32```3334### Khai niem cot loi3536- **StateGraph**: dinh nghia do thi voi state co kieu37- **Nodes**: ham Python chuyen doi state38- **Edges**: ket noi giua cac node, co the co dieu kien39- **Checkpointing**: luu tru tich hop cho workflow chay dai4041### Vi du code4243```python44from langgraph.graph import StateGraph, MessagesState, START, END45from langchain_openai import ChatOpenAI4647llm = ChatOpenAI(model="gpt-4o")4849def call_agent(state: MessagesState):50 response = llm.invoke(state["messages"])51 return {"messages": [response]}5253def should_continue(state: MessagesState):54 last = state["messages"][-1]55 if last.tool_calls:56 return "tools"57 return END5859def call_tools(state: MessagesState):60 # Execute tool calls and return results61 results = []62 for tool_call in state["messages"][-1].tool_calls:63 result = execute_tool(tool_call)64 results.append(result)65 return {"messages": results}6667graph = StateGraph(MessagesState)68graph.add_node("agent", call_agent)69graph.add_node("tools", call_tools)70graph.add_edge(START, "agent")71graph.add_conditional_edges("agent", should_continue, {"tools": "tools", END: END})72graph.add_edge("tools", "agent")7374app = graph.compile()75result = app.invoke({"messages": [{"role": "user", "content": "What's the weather?"}]})76```7778### Diem manh7980- Kiem soat chi tiet tung buoc va tung chuyen tiep81- Checkpointing va human-in-the-loop tich hop82- Ho tro TypeScript day du83- Hoat dong voi bat ky LLM provider nao84- Phu hop nhat cho workflow phuc tap co phan nhanh dieu kien va vong lap8586### Diem yeu8788- Duong cong hoc tap doc - can hieu cac khai niem ly thuyet do thi89- Dai dong cho use case don gian - agent co ban can nhieu boilerplate hon cac framework khac90- Debug luong do thi co the kho khan neu khong co LangSmith9192### Gia ca9394Open-source (MIT). LangSmith (nen tang observability quan ly) co cac goi tra phi cho giam sat production.9596## CrewAI: Nha to chuc nhom9798CrewAI 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).99100Hay nghi ve no nhu viec tuyen mot doi ngu ma moi thanh vien co mot chuc danh va chuyen mon cu the.101102```mermaid103graph TD104 Crew[Crew Manager] --> R[Researcher\nRole: Find data\nTools: WebSearch]105 Crew --> W[Writer\nRole: Write content\nTools: FileWrite]106 Crew --> E[Editor\nRole: Review quality\nTools: FileRead]107 R --> Task1[Research Task]108 W --> Task2[Writing Task]109 E --> Task3[Review Task]110 Task1 --> Task2 --> Task3111```112113### Khai niem cot loi114115- **Agent**: persona co role, goal, backstory va tool116- **Task**: nhiem vu co mo ta, dau ra ky vong va agent duoc chi dinh117- **Crew**: nhom agent lam viec cung nhau118- **Process**: chien luoc thuc thi (tuan tu, phan cap, dong thuan)119- **Flow**: lop orchestration huong su kien de ket noi nhieu crew120121### Vi du code122123```python124from crewai import Agent, Task, Crew, Process125126researcher = Agent(127 role="Senior Research Analyst",128 goal="Find comprehensive data about the given topic",129 backstory="You have 10 years of experience in technology research. "130 "You are thorough and always verify facts from multiple sources.",131 tools=[web_search_tool],132 verbose=True,133)134135writer = Agent(136 role="Technical Writer",137 goal="Create clear, engaging technical content",138 backstory="You write for a developer audience. "139 "Your articles are practical and include code examples.",140 tools=[file_tool],141 verbose=True,142)143144research_task = Task(145 description="Research the latest developments in WebAssembly in 2026. "146 "Focus on WASI, Component Model, and production use cases.",147 expected_output="A structured research document with key findings and sources.",148 agent=researcher,149)150151writing_task = Task(152 description="Write a blog post based on the research. "153 "Include code examples and Mermaid diagrams.",154 expected_output="A complete blog post in Markdown format.",155 agent=writer,156 context=[research_task], # Writer receives researcher's output157)158159crew = Crew(160 agents=[researcher, writer],161 tasks=[research_task, writing_task],162 process=Process.sequential,163 verbose=True,164)165166result = crew.kickoff()167print(result.raw)168```169170### Diem manh171172- Truu tuong dua tren vai tro truc quan - de suy luan173- Hon 100 tool integration tich hop174- Bo nho chia se giua cac agent (ngan han, dai han, entity)175- Cong dong lon nhat (~40k GitHub stars)176- Process phan cap voi agent "quan ly" uy quyen va xac nhan177178### Diem yeu179180- Kiem soat it chi tiet hon LangGraph - ban dinh nghia vai tro, khong phai duong thuc thi chinh xac181- Process phan cap co the kho du doan khi cac agent bat dong182- Debug cuoc hoi thoai multi-agent kho hon luong single-agent183184### Gia ca185186Open-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.187188## OpenAI Agents SDK: Bo dinh tuyen189190OpenAI 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.191192```mermaid193graph LR194 User --> Triage[Triage Agent]195 Triage -->|billing question| Billing[Billing Agent]196 Triage -->|refund request| Refund[Refund Agent]197 Triage -->|technical issue| Support[Support Agent]198 Billing --> Response[Response]199 Refund --> Response200 Support --> Response201```202203### Khai niem cot loi204205- **Agent**: model + instructions + tool + handoff206- **Handoff**: chuyen tiep den agent khac (duoc mo hinh hoa nhu tool ma LLM co the goi)207- **Guardrail**: xac thuc input/output chay song song voi agent208- **Runner**: thuc thi agent loop209- **Tracing**: observability tich hop cho moi cuoc goi LLM, tool va handoff210211### Vi du code212213```python214from agents import Agent, Runner, handoff, InputGuardrail, GuardrailFunctionOutput215from pydantic import BaseModel216217class SafetyCheck(BaseModel):218 is_safe: bool219 reason: str220221async def content_safety(ctx, agent, input_text):222 result = await Runner.run(223 Agent(name="Safety", instructions="Check if input is safe. No PII."),224 input_text,225 context=ctx,226 )227 output = SafetyCheck.model_validate_json(result.final_output)228 return GuardrailFunctionOutput(229 output_info=output, tripwire_triggered=not output.is_safe230 )231232billing_agent = Agent(233 name="Billing Agent",234 instructions="You handle billing inquiries. Be precise with numbers.",235 tools=[lookup_invoice, process_payment],236)237238refund_agent = Agent(239 name="Refund Agent",240 instructions="You process refund requests. Always verify the order first.",241 tools=[lookup_order, issue_refund],242)243244triage_agent = Agent(245 name="Triage Agent",246 instructions="Route the customer to the right specialist. "247 "Ask clarifying questions if needed.",248 handoffs=[billing_agent, refund_agent],249 input_guardrails=[InputGuardrail(guardrail_function=content_safety)],250)251252result = await Runner.run(triage_agent, "I need a refund for order #4521")253print(result.final_output)254# The triage agent routes to refund_agent, which processes the refund255```256257### Diem manh258259- Mau handoff gon gang - tu nhien cho workflow routing/triage260- Guardrail chay song song voi thuc thi (fail-fast, khong blocking)261- Dashboard tracing tich hop de debug262- Bat chap ten goi, ho tro cac model khong phai cua OpenAI263- Truu tuong toi thieu - de hieu va de mo rong264265### Diem yeu266267- Quan ly state chua truong thanh bang LangGraph268- Khong co persistence hoac checkpointing tich hop269- Ecosystem tool cua ben thu ba nho hon270- Thiet ke lay handoff lam trung tam co the khong phu hop moi kien truc271272### Gia ca273274Open-source (MIT). Ban tra phi theo token cho bat ky model nao su dung.275276## Claude Agent SDK: Nha phat trien277278Claude 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.279280```mermaid281graph TD282 Prompt[User Prompt] --> Loop[Autonomous Agent Loop]283 Loop --> Reason[Reason about next step]284 Reason --> Act[Execute tool]285 Act --> Verify[Check result]286 Verify -->|not done| Loop287 Verify -->|done| Output[Final output]288```289290### Khai niem cot loi291292- **query()**: diem vao chinh khoi dong agent loop293- **Cong cu tich hop**: Read, Write, Edit, Bash, Glob, Grep, WebSearch, WebFetch294- **Custom tool qua MCP**: dinh nghia tool la in-process MCP server295- **Sub-agent**: agent chuyen biet ma agent cha co the uy quyen296- **Sessions**: duy tri context qua nhieu lan tuong tac297298### Vi du code299300```typescript301import { tool, createSdkMcpServer, query } from "@anthropic-ai/claude-agent-sdk";302import { z } from "zod";303304const searchDocs = tool(305 "search_docs",306 "Search the internal documentation for relevant information",307 { query: z.string().describe("Search query") },308 async ({ query }) => {309 const results = await vectorStore.similaritySearch(query, 5);310 return {311 content: [{ type: "text", text: results.map(r => r.pageContent).join("\n\n") }],312 };313 }314);315316const docsServer = createSdkMcpServer({317 name: "docs",318 version: "1.0.0",319 tools: [searchDocs],320});321322for await (const message of query({323 prompt: "Find how authentication works in our system and write a summary",324 options: {325 mcpServers: { docs: docsServer },326 allowedTools: ["Read", "Glob", "Grep", "mcp__docs__search_docs"],327 },328})) {329 if (message.type === "result" && message.subtype === "success") {330 console.log(message.result);331 }332}333```334335### Diem manh336337- Tich hop MCP cap first-class - ket noi voi bat ky ecosystem MCP server nao338- Cong cu tich hop cho thao tac file, terminal va truy cap web339- Tu dong nen context cho codebase lon340- Sub-agent song song cho cac tac vu phuc tap341- Cung engine voi Claude Code - da duoc thu nghiem thuc te tren workflow phat trien that342343### Diem yeu344345- Chi ho tro model Claude - khong ho tro nhieu provider346- Framework moi hon voi cong dong nho hon347- Can Node.js runtime ngay ca voi Python SDK348- Kiem soat workflow it ro rang hon so voi LangGraph349350### Gia ca351352Open-source. Gia token Claude API tieu chuan. Managed Agents (phien ban hosted): $0.08 moi gio session ngoai chi phi token.353354## Khi nao chon cai nao355356```mermaid357graph TD358 Start{What's your priority?}359 Start -->|Full control over workflow| LG[LangGraph]360 Start -->|Multi-agent collaboration| CA[CrewAI]361 Start -->|Routing and triage| OA[OpenAI Agents SDK]362 Start -->|Coding and file automation| CS[Claude Agent SDK]363364 LG --> LGU[Complex stateful workflows\nConditional branching\nHuman-in-the-loop]365 CA --> CAU[Team of specialized agents\nResearch + writing pipelines\nContent generation]366 OA --> OAU[Customer service routing\nMulti-step handoffs\nInput validation]367 CS --> CSU[Code generation and review\nFile-heavy automation\nMCP tool ecosystem]368```369370### Chon LangGraph neu:371- Ban can kiem soat chinh xac tung buoc cua workflow372- Use case cua ban lien quan den logic dieu kien phuc tap va vong lap373- Ban can persistence va human-in-the-loop checkpoint tich hop374- Ban can su dung nhieu LLM provider trong cung mot workflow375376### Chon CrewAI neu:377- Ban muon truu tuong dua tren vai tro truc quan378- Nhiem vu cua ban lien quan den nhieu agent co chuyen mon khac nhau379- Ban can cac agent hop tac va truyen context cho nhau380- Ban coi trong cong dong lon nhat va nhieu integration tich hop nhat381382### Chon OpenAI Agents SDK neu:383- Mau chinh cua ban la dinh tuyen cuoc hoi thoai den chuyen gia384- Ban can guardrail xac thuc input/output song song385- Ban muon truu tuong don gian nhat voi boilerplate toi thieu386- Tracing va observability tich hop la quan trong387388### Chon Claude Agent SDK neu:389- Agent cua ban can doc, viet va thuc thi code390- Ban muon tich hop MCP server cap first-class391- Ban can agent tu chu co kha nang lap lai va tu sua loi392- Ban da su dung Claude va muon tich hop sau nhat393394## Co the ket hop cac framework khong?395396Co. Mot mau pho bien la su dung mot framework cho orchestration va mot framework khac cho tung agent rieng le:397398- **LangGraph** cho do thi workflow tong the399- **CrewAI** cho node cu the can hop tac multi-agent400- **Claude Agent SDK** cho sub-task lien quan den lap trinh qua MCP401- **OpenAI Agents SDK** cho triage va routing huong toi khach hang402403Cac framework nay khong loai tru lan nhau. Hay su dung cai phu hop voi tung phan cua he thong.404405## Ket luan406407Moi framework co mot dinh huong ro rang:408409- **LangGraph** toi uu hoa cho kiem soat - ban quyet dinh tung chuyen tiep410- **CrewAI** toi uu hoa cho hop tac - cac agent lam viec nhu mot doi411- **OpenAI Agents SDK** toi uu hoa cho su don gian - truu tuong toi thieu, handoff gon gang412- **Claude Agent SDK** toi uu hoa cho tu chu - cho no cong cu va de no lam viec413414Lua 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.415
:So sanh Agentic AI Framework: LangGraph vs CrewAI vs OpenAI Agents SDK vs Claude Agent SDKlines 1-415 (END) — press q to close